MIFOSX-97: iterate for serialization parts of platform infrastructure and for codes resource.
This commit is contained in:
+1
-1
@@ -13,9 +13,9 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.accounting.api.commands.GLAccountCommand;
|
||||
import org.mifosplatform.accounting.api.commands.GLClosureCommand;
|
||||
import org.mifosplatform.accounting.api.infrastructure.AccountingApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonParserHelper;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.JsonParserHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
+1
-1
@@ -8,9 +8,9 @@ import java.util.Set;
|
||||
import org.mifosplatform.accounting.api.data.GLAccountData;
|
||||
import org.mifosplatform.accounting.api.data.GLClosureData;
|
||||
import org.mifosplatform.accounting.api.infrastructure.AccountingApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.GoogleGsonSerializerHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
+10
-11
@@ -7,8 +7,8 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.commands.domain.CommandSource;
|
||||
import org.mifosplatform.commands.service.ChangeDetectionService;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.codes.serialization.CodeCommandFromCommandJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
@@ -20,15 +20,15 @@ public class CodeCommandHandler implements CommandSourceHandler {
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final ChangeDetectionService changeDetectionService;
|
||||
private final PortfolioCommandDeserializerService commandDeserializerService;
|
||||
private final CodeCommandFromCommandJsonDeserializer fromCommandJsonDeserializer;
|
||||
private final CodeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
public CodeCommandHandler(final PlatformSecurityContext context, final ChangeDetectionService changeDetectionService,
|
||||
final PortfolioCommandDeserializerService commandDeserializerService, final CodeWritePlatformService writePlatformService) {
|
||||
final CodeCommandFromCommandJsonDeserializer fromCommandJsonDeserializer, final CodeWritePlatformService writePlatformService) {
|
||||
this.context = context;
|
||||
this.changeDetectionService = changeDetectionService;
|
||||
this.commandDeserializerService = commandDeserializerService;
|
||||
this.fromCommandJsonDeserializer = fromCommandJsonDeserializer;
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CodeCommandHandler implements CommandSourceHandler {
|
||||
final LocalDate asToday = new LocalDate();
|
||||
|
||||
final Long resourceId = commandSource.resourceId();
|
||||
final CodeCommand command = this.commandDeserializerService.deserializeCodeCommand(resourceId, commandSource.json(), false);
|
||||
final CodeCommand command = this.fromCommandJsonDeserializer.commandFromCommandJson(resourceId, commandSource.json());
|
||||
|
||||
CommandSource commandSourceResult = commandSource.copy();
|
||||
|
||||
@@ -57,8 +57,7 @@ public class CodeCommandHandler implements CommandSourceHandler {
|
||||
commandSource.resourceId(), commandSource.json());
|
||||
commandSourceResult.updateJsonTo(jsonOfChangesOnly);
|
||||
|
||||
final CodeCommand changesOnly = this.commandDeserializerService
|
||||
.deserializeCodeCommand(resourceId, jsonOfChangesOnly, false);
|
||||
final CodeCommand changesOnly = this.fromCommandJsonDeserializer.commandFromCommandJson(resourceId, jsonOfChangesOnly);
|
||||
this.writePlatformService.updateCode(changesOnly);
|
||||
|
||||
commandSourceResult.markAsChecked(maker, asToday);
|
||||
@@ -83,24 +82,24 @@ public class CodeCommandHandler implements CommandSourceHandler {
|
||||
final AppUser checker = context.authenticatedUser();
|
||||
|
||||
Long resourceId = commandSourceResult.resourceId();
|
||||
final CodeCommand command = this.commandDeserializerService.deserializeCodeCommand(resourceId, commandSourceResult.json(), true);
|
||||
final CodeCommand command = this.fromCommandJsonDeserializer.commandFromCommandJson(resourceId, commandSourceResult.json(), true);
|
||||
|
||||
if (commandSourceResult.isCreate()) {
|
||||
final List<String> allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "CREATE_CODE_MAKER");
|
||||
context.authenticatedUser().validateHasPermissionTo("CREATE_USER_MAKER", allowedPermissions);
|
||||
context.authenticatedUser().validateHasPermissionTo("CREATE_CODE_MAKER", allowedPermissions);
|
||||
|
||||
resourceId = this.writePlatformService.createCode(command);
|
||||
commandSourceResult.updateResourceId(resourceId);
|
||||
commandSourceResult.markAsChecked(checker, new LocalDate());
|
||||
} else if (commandSourceResult.isUpdate()) {
|
||||
final List<String> allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "UPDATE_CODE_MAKER");
|
||||
context.authenticatedUser().validateHasPermissionTo("UPDATE_USER_MAKER", allowedPermissions);
|
||||
context.authenticatedUser().validateHasPermissionTo("UPDATE_CODE_MAKER", allowedPermissions);
|
||||
|
||||
this.writePlatformService.updateCode(command);
|
||||
commandSourceResult.markAsChecked(checker, new LocalDate());
|
||||
} else if (commandSourceResult.isDelete()) {
|
||||
final List<String> allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "DELETE_CODE_MAKER");
|
||||
context.authenticatedUser().validateHasPermissionTo("DELETE_USER_MAKER", allowedPermissions);
|
||||
context.authenticatedUser().validateHasPermissionTo("DELETE_CODE_MAKER", allowedPermissions);
|
||||
|
||||
this.writePlatformService.deleteCode(command);
|
||||
commandSourceResult.markAsChecked(checker, new LocalDate());
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.commands.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.portfolio.client.command.ClientCommand;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
|
||||
@@ -15,12 +15,12 @@ public class ChangeDetectionServiceJdbc implements ChangeDetectionService {
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
|
||||
@Autowired
|
||||
public ChangeDetectionServiceJdbc(
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final ClientReadPlatformService clientReadPlatformService) {
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
|
||||
+27
-29
@@ -2,6 +2,7 @@ package org.mifosplatform.infrastructure.codes.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -18,14 +19,13 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.codes.serialization.CodeCommandFromApiJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -36,26 +36,30 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class CodesApiResource {
|
||||
|
||||
/**
|
||||
* The set of parameters that are supported in response for {@link CodeData}
|
||||
* .
|
||||
*/
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "name", "systemDefined"));
|
||||
private final String resourceNameForPermissions = "CODE";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final CodeReadPlatformService readPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CodeCommandFromApiJsonDeserializer fromApiJsonDeserializer;
|
||||
private final DefaultToApiJsonSerializer<CodeData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public CodesApiResource(final PlatformSecurityContext context, final CodeReadPlatformService readPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CodeCommandFromApiJsonDeserializer fromApiJsonDeserializer, final DefaultToApiJsonSerializer<CodeData> toApiJsonSerializer,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
}
|
||||
|
||||
@@ -66,12 +70,10 @@ public class CodesApiResource {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<CodeData> codes = this.readPlatformService.retrieveAllCodes();
|
||||
|
||||
return this.apiJsonSerializerService.serializeCodeDataToJson(prettyPrint, responseParameters, codes);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, codes, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -82,13 +84,12 @@ public class CodesApiResource {
|
||||
final List<String> allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "CREATE_CODE");
|
||||
context.authenticatedUser().validateHasPermissionTo("CREATE_CODE", allowedPermissions);
|
||||
|
||||
final CodeCommand command = this.apiDataConversionService.convertApiRequestJsonToCodeCommand(null, apiRequestBodyAsJson);
|
||||
final String commandSerializedAsJson = this.commandSerializerService.serializeCommandToJson(command);
|
||||
final String commandSerializedAsJson = this.fromApiJsonDeserializer.serializedCommandJsonFromApiJson(apiRequestBodyAsJson);
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "codes", null,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -97,12 +98,10 @@ public class CodesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retreiveOffice(@PathParam("codeId") final Long codeId, @Context final UriInfo uriInfo) {
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final CodeData code = this.readPlatformService.retrieveCode(codeId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeCodeDataToJson(prettyPrint, responseParameters, code);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, code, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -114,13 +113,12 @@ public class CodesApiResource {
|
||||
final List<String> allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "UPDATE_CODE");
|
||||
context.authenticatedUser().validateHasPermissionTo("UPDATE_CODE", allowedPermissions);
|
||||
|
||||
final CodeCommand command = this.apiDataConversionService.convertApiRequestJsonToCodeCommand(codeId, apiRequestBodyAsJson);
|
||||
final String commandSerializedAsJson = this.commandSerializerService.serializeCommandToJson(command);
|
||||
final String commandSerializedAsJson = this.fromApiJsonDeserializer.serializedCommandJsonFromApiJson(codeId, apiRequestBodyAsJson);
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "codes", codeId,
|
||||
commandSerializedAsJson);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -134,6 +132,6 @@ public class CodesApiResource {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "codes", codeId, "{}");
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
}
|
||||
+19
-17
@@ -9,7 +9,9 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
|
||||
/**
|
||||
* Immutable command for creating or updating details of a code.
|
||||
* <p>Immutable command for creating or updating details of a code.</p>
|
||||
*
|
||||
* <p>Transient fields are not intended for serialization.</p>
|
||||
*/
|
||||
public class CodeCommand {
|
||||
|
||||
@@ -26,22 +28,6 @@ public class CodeCommand {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean isNameChanged() {
|
||||
return this.parametersPassedInRequest.contains("name");
|
||||
}
|
||||
|
||||
public boolean isApprovedByChecker() {
|
||||
return this.makerCheckerApproval;
|
||||
}
|
||||
|
||||
public void validateForCreate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
@@ -62,4 +48,20 @@ public class CodeCommand {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean isNameChanged() {
|
||||
return this.parametersPassedInRequest.contains("name");
|
||||
}
|
||||
|
||||
public boolean isApprovedByChecker() {
|
||||
return this.makerCheckerApproval;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -20,7 +20,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "m_code", uniqueConstraints = { @UniqueConstraint(columnNames = { "code_name" }, name = "code_name") })
|
||||
public class Code extends AbstractPersistable<Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "code_name", length = 100)
|
||||
private String name;
|
||||
|
||||
@@ -45,6 +44,10 @@ public class Code extends AbstractPersistable<Long> {
|
||||
this.systemDefined = false;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isSystemDefined() {
|
||||
return this.systemDefined;
|
||||
}
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package org.mifosplatform.infrastructure.codes.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromApiJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Implementation of {@link FromApiJsonDeserializer} for {@link CodeCommand}'s.
|
||||
*/
|
||||
@Component
|
||||
public final class CodeCommandFromApiJsonDeserializer implements FromApiJsonDeserializer<CodeCommand> {
|
||||
|
||||
/**
|
||||
* The parameters supported for this command.
|
||||
*/
|
||||
private final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("name"));
|
||||
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
private final CodeCommandFromCommandJsonDeserializer fromCommandJsonDeserializer;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
|
||||
@Autowired
|
||||
public CodeCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper,
|
||||
final CodeCommandFromCommandJsonDeserializer fromCommandJsonDeserializer,
|
||||
final CommandSerializer commandSerializerService) {
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
this.fromCommandJsonDeserializer = fromCommandJsonDeserializer;
|
||||
this.commandSerializerService = commandSerializerService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand commandFromApiJson(final String json) {
|
||||
return commandFromApiJson(null, json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand commandFromApiJson(final Long codeId, final String json) {
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
|
||||
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||
|
||||
return this.fromCommandJsonDeserializer.commandFromCommandJson(codeId, json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializedCommandJsonFromApiJson(final String json) {
|
||||
final CodeCommand command = commandFromApiJson(json);
|
||||
return this.commandSerializerService.serializeCommandToJson(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializedCommandJsonFromApiJson(final Long codeId, final String json) {
|
||||
final CodeCommand command = commandFromApiJson(codeId, json);
|
||||
return this.commandSerializerService.serializeCommandToJson(command);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package org.mifosplatform.infrastructure.codes.serialization;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromCommandJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public final class CodeCommandFromCommandJsonDeserializer implements FromCommandJsonDeserializer<CodeCommand> {
|
||||
|
||||
private final FromJsonHelper fromJsonHelper;
|
||||
|
||||
@Autowired
|
||||
public CodeCommandFromCommandJsonDeserializer(final FromJsonHelper fromApiJsonHelper) {
|
||||
this.fromJsonHelper = fromApiJsonHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand commandFromCommandJson(final String commandAsJson) {
|
||||
return commandFromCommandJson(null, commandAsJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand commandFromCommandJson(final Long codeId, final String commandAsJson) {
|
||||
return commandFromCommandJson(codeId, commandAsJson, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand commandFromCommandJson(Long codeId, String commandAsJson, boolean makerCheckerApproval) {
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final JsonElement element = fromJsonHelper.parse(commandAsJson);
|
||||
final String name = fromJsonHelper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||
|
||||
return new CodeCommand(parametersPassedInRequest, makerCheckerApproval, codeId, name);
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -97,7 +97,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
final Code code = retrieveCodeBy(command.getName());
|
||||
final Code code = retrieveCodeBy(command.getId());
|
||||
if (code.isSystemDefined()) {
|
||||
throw new SystemDefinedCodeCannotBeChangedException();
|
||||
}
|
||||
@@ -114,4 +114,10 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
if (code == null) { throw new CodeNotFoundException(name); }
|
||||
return code;
|
||||
}
|
||||
|
||||
private Code retrieveCodeBy(final Long codeId) {
|
||||
final Code code = this.codeRepository.findOne(codeId);
|
||||
if (code == null) { throw new CodeNotFoundException(codeId.toString()); }
|
||||
return code;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Used to process the query parameters provided in a API request to see features of
|
||||
* the RESTful API are being asked for such as:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>Pretty printing through pretty=true, defaults to false</li>
|
||||
* <li>Partial response through fields=id, name etc, when empty, the full data
|
||||
* is returned by default.</li>
|
||||
* </ul
|
||||
*/
|
||||
@Component
|
||||
public class ApiRequestParameterHelper {
|
||||
|
||||
public ApiRequestJsonSerializationSettings process(final MultivaluedMap<String, String> queryParameters) {
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(queryParameters);
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(queryParameters);
|
||||
|
||||
return ApiRequestJsonSerializationSettings.from(prettyPrint, responseParameters);
|
||||
}
|
||||
}
|
||||
+2
-17
@@ -6,8 +6,8 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.data.DocumentData;
|
||||
@@ -152,8 +152,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
|
||||
private static final Set<String> LOAN_CHARGES_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("chargeOptions"));
|
||||
|
||||
private static final Set<String> CODE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "codename"));
|
||||
|
||||
private static final Set<String> MAKER_CHECKER_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "taskName", "madeOnDate"));
|
||||
|
||||
private static final Set<String> SAVINGS_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "status", "externalId",
|
||||
@@ -489,6 +487,7 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, staff.toArray(new StaffData[staff.size()]));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public String serializeEntityIdentifier(final EntityIdentifier identifier) {
|
||||
final Set<String> DATA_PARAMETERS = new HashSet<String>(Arrays.asList("entityId"));
|
||||
@@ -527,20 +526,6 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
return helper.serializedJsonFrom(gsonDeserializer, documentData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeCodeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<CodeData> codes) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CODE_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, codes.toArray(new CodeData[codes.size()]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeCodeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final CodeData code) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(CODE_DATA_PARAMETERS,
|
||||
prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeMakerCheckerDataToJson(final boolean prettyPrint, final Set<String> responseParameters,
|
||||
final Collection<CommandSourceData> entries) {
|
||||
|
||||
-3
@@ -1,6 +1,5 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.organisation.monetary.command.CurrencyCommand;
|
||||
import org.mifosplatform.organisation.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.organisation.office.command.OfficeCommand;
|
||||
@@ -97,8 +96,6 @@ public interface PortfolioApiDataConversionService {
|
||||
|
||||
ClientIdentifierCommand convertApiRequestJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json);
|
||||
|
||||
CodeCommand convertApiRequestJsonToCodeCommand(Long resourceIdentifier, String json);
|
||||
|
||||
SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier, String json);
|
||||
|
||||
GuarantorCommand convertJsonToGuarantorCommand(Long resourceIdentifier, Long loanId, String json);
|
||||
|
||||
+1
-17
@@ -17,11 +17,11 @@ import java.util.Set;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.JsonParserHelper;
|
||||
import org.mifosplatform.organisation.monetary.command.CurrencyCommand;
|
||||
import org.mifosplatform.organisation.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.organisation.office.command.OfficeCommand;
|
||||
@@ -1515,22 +1515,6 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
return this.portfolioCommandDeserializerService.deserializeClientIdentifierCommand(resourceIdentifier, clientId, json, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand convertApiRequestJsonToCodeCommand(final Long resourceIdentifier, final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
final Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
final Set<String> supportedParams = new HashSet<String>(Arrays.asList("name"));
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
// no difference between api request json format and internal command
|
||||
// json format.
|
||||
return this.portfolioCommandDeserializerService.deserializeCodeCommand(resourceIdentifier, json, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier, String json) {
|
||||
|
||||
|
||||
+6
-5
@@ -4,7 +4,6 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
@@ -128,6 +127,12 @@ public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff);
|
||||
|
||||
/**
|
||||
* @deprecated see
|
||||
* {@link CodesToApiJsonSerializer#serialize(EntityIdentifier)}
|
||||
* for example for what to use now.
|
||||
*/
|
||||
@Deprecated
|
||||
String serializeEntityIdentifier(EntityIdentifier identifier);
|
||||
|
||||
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
@@ -140,10 +145,6 @@ public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, DocumentData documentData);
|
||||
|
||||
String serializeCodeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CodeData> codes);
|
||||
|
||||
String serializeCodeDataToJson(boolean prettyPrint, Set<String> responseParameters, CodeData code);
|
||||
|
||||
String serializeMakerCheckerDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CommandSourceData> entries);
|
||||
|
||||
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account);
|
||||
|
||||
+1
-15
@@ -7,8 +7,8 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.JsonParserHelper;
|
||||
import org.mifosplatform.organisation.monetary.command.CurrencyCommand;
|
||||
import org.mifosplatform.organisation.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.organisation.office.command.OfficeCommand;
|
||||
@@ -126,20 +126,6 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo
|
||||
repeatPassword, email, officeId, notSelectedRoles, roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand deserializeCodeCommand(final Long codeId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||
|
||||
return new CodeCommand(parametersPassedInRequest, makerCheckerApproval, codeId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffCommand deserializeStaffCommand(final Long staffId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
|
||||
|
||||
-3
@@ -1,6 +1,5 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.organisation.monetary.command.CurrencyCommand;
|
||||
import org.mifosplatform.organisation.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.organisation.office.command.OfficeCommand;
|
||||
@@ -35,8 +34,6 @@ public interface PortfolioCommandDeserializerService {
|
||||
|
||||
UserCommand deserializeUserCommand(Long userId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
CodeCommand deserializeCodeCommand(Long codeId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
StaffCommand deserializeStaffCommand(Long staffId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
FundCommand deserializeFundCommand(Long fundId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* Implementation of {@link PortfolioCommandSerializerService} that serializes
|
||||
* the commands into JSON using google-gson.
|
||||
*/
|
||||
@Service
|
||||
public class PortfolioCommandSerializerServiceJson implements PortfolioCommandSerializerService {
|
||||
|
||||
private final GoogleGsonSerializerHelper helper;
|
||||
|
||||
@Autowired
|
||||
public PortfolioCommandSerializerServiceJson(final GoogleGsonSerializerHelper helper) {
|
||||
this.helper = helper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeCommandToJson(Object command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false,
|
||||
new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
}
|
||||
+102
-96
@@ -4,117 +4,123 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiParameterError {
|
||||
|
||||
/**
|
||||
* A developer friendly plain English description of why the HTTP error response was returned from the API.
|
||||
*/
|
||||
private String developerMessage;
|
||||
|
||||
/**
|
||||
* A user friendly plain English description of why the HTTP error response was returned from the API that can be presented to end users.
|
||||
*/
|
||||
private String defaultUserMessage;
|
||||
|
||||
/**
|
||||
* A code that can be used for globalisation support by client applications of the API.
|
||||
*/
|
||||
private String userMessageGlobalisationCode;
|
||||
|
||||
/**
|
||||
* The name of the field or parameter passed to the API that this error relates to.
|
||||
*/
|
||||
private String parameterName;
|
||||
|
||||
/**
|
||||
* The actual value of the parameter (if any) as passed to API.
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* Arguments related to the user error message.
|
||||
*/
|
||||
private List<ApiErrorMessageArg> args = new ArrayList<ApiErrorMessageArg>();
|
||||
/**
|
||||
* A developer friendly plain English description of why the HTTP error
|
||||
* response was returned from the API.
|
||||
*/
|
||||
private String developerMessage;
|
||||
|
||||
public static ApiParameterError generalError(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
/**
|
||||
* A user friendly plain English description of why the HTTP error response
|
||||
* was returned from the API that can be presented to end users.
|
||||
*/
|
||||
private String defaultUserMessage;
|
||||
|
||||
public static ApiParameterError resourceIdentifierNotFound(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
/**
|
||||
* A code that can be used for globalisation support by client applications
|
||||
* of the API.
|
||||
*/
|
||||
private String userMessageGlobalisationCode;
|
||||
|
||||
public static ApiParameterError parameterError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final String parameterName, final Object... defaultUserMessageArgs) {
|
||||
ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
error.setParameterName(parameterName);
|
||||
return error;
|
||||
}
|
||||
|
||||
protected ApiParameterError() {
|
||||
//
|
||||
}
|
||||
/**
|
||||
* The name of the field or parameter passed to the API that this error
|
||||
* relates to.
|
||||
*/
|
||||
private String parameterName;
|
||||
|
||||
private ApiParameterError(final String globalisationMessageCode, final String defaultUserMessage, final Object[] defaultUserMessageArgs) {
|
||||
this.userMessageGlobalisationCode = globalisationMessageCode;
|
||||
this.developerMessage = defaultUserMessage;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
|
||||
List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
|
||||
if (defaultUserMessageArgs != null) {
|
||||
for (Object object : defaultUserMessageArgs) {
|
||||
messageArgs.add(ApiErrorMessageArg.from(object));
|
||||
}
|
||||
}
|
||||
this.args = messageArgs;
|
||||
|
||||
this.parameterName="id";
|
||||
}
|
||||
/**
|
||||
* The actual value of the parameter (if any) as passed to API.
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
public String getDeveloperMessage() {
|
||||
return developerMessage;
|
||||
}
|
||||
/**
|
||||
* Arguments related to the user error message.
|
||||
*/
|
||||
private List<ApiErrorMessageArg> args = new ArrayList<ApiErrorMessageArg>();
|
||||
|
||||
public void setDeveloperMessage(String developerMessage) {
|
||||
this.developerMessage = developerMessage;
|
||||
}
|
||||
public static ApiParameterError generalError(String globalisationMessageCode, String defaultUserMessage,
|
||||
Object... defaultUserMessageArgs) {
|
||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
}
|
||||
public static ApiParameterError resourceIdentifierNotFound(String globalisationMessageCode, String defaultUserMessage,
|
||||
Object... defaultUserMessageArgs) {
|
||||
return new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
|
||||
public void setDefaultUserMessage(String defaultUserMessage) {
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
}
|
||||
public static ApiParameterError parameterError(final String globalisationMessageCode, final String defaultUserMessage,
|
||||
final String parameterName, final Object... defaultUserMessageArgs) {
|
||||
ApiParameterError error = new ApiParameterError(globalisationMessageCode, defaultUserMessage, defaultUserMessageArgs);
|
||||
error.setParameterName(parameterName);
|
||||
return error;
|
||||
}
|
||||
|
||||
public String getUserMessageGlobalisationCode() {
|
||||
return userMessageGlobalisationCode;
|
||||
}
|
||||
protected ApiParameterError() {
|
||||
//
|
||||
}
|
||||
|
||||
public void setUserMessageGlobalisationCode(String userMessageGlobalisationCode) {
|
||||
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
|
||||
}
|
||||
private ApiParameterError(final String globalisationMessageCode, final String defaultUserMessage, final Object[] defaultUserMessageArgs) {
|
||||
this.userMessageGlobalisationCode = globalisationMessageCode;
|
||||
this.developerMessage = defaultUserMessage;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
List<ApiErrorMessageArg> messageArgs = new ArrayList<ApiErrorMessageArg>();
|
||||
if (defaultUserMessageArgs != null) {
|
||||
for (Object object : defaultUserMessageArgs) {
|
||||
messageArgs.add(ApiErrorMessageArg.from(object));
|
||||
}
|
||||
}
|
||||
this.args = messageArgs;
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
this.parameterName = "id";
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
public String getDeveloperMessage() {
|
||||
return developerMessage;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
public void setDeveloperMessage(String developerMessage) {
|
||||
this.developerMessage = developerMessage;
|
||||
}
|
||||
|
||||
public List<ApiErrorMessageArg> getArgs() {
|
||||
return args;
|
||||
}
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
}
|
||||
|
||||
public void setArgs(List<ApiErrorMessageArg> args) {
|
||||
this.args = args;
|
||||
}
|
||||
public void setDefaultUserMessage(String defaultUserMessage) {
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
}
|
||||
|
||||
public String getUserMessageGlobalisationCode() {
|
||||
return userMessageGlobalisationCode;
|
||||
}
|
||||
|
||||
public void setUserMessageGlobalisationCode(String userMessageGlobalisationCode) {
|
||||
this.userMessageGlobalisationCode = userMessageGlobalisationCode;
|
||||
}
|
||||
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public List<ApiErrorMessageArg> getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public void setArgs(List<ApiErrorMessageArg> args) {
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A class to encapsulate settings we allow on API that affect how JSON is to be
|
||||
* serialized for the response to api call.
|
||||
*/
|
||||
public class ApiRequestJsonSerializationSettings {
|
||||
|
||||
private final boolean prettyPrint;
|
||||
private final Set<String> parametersForPartialResponse;
|
||||
|
||||
public ApiRequestJsonSerializationSettings(final boolean prettyPrint, final Set<String> parametersForPartialResponse) {
|
||||
this.prettyPrint = prettyPrint;
|
||||
this.parametersForPartialResponse = parametersForPartialResponse;
|
||||
}
|
||||
|
||||
public static ApiRequestJsonSerializationSettings from(final boolean prettyPrint, final Set<String> parametersForPartialResponse) {
|
||||
|
||||
// FIXME - kw - rather than always creating new objects for this could
|
||||
// just send by common ones like, prettyprint=false, empty response
|
||||
// parameters
|
||||
return new ApiRequestJsonSerializationSettings(prettyPrint, parametersForPartialResponse);
|
||||
}
|
||||
|
||||
public boolean isPrettyPrint() {
|
||||
return this.prettyPrint;
|
||||
}
|
||||
|
||||
public Set<String> getParametersForPartialResponse() {
|
||||
return this.parametersForPartialResponse;
|
||||
}
|
||||
|
||||
public boolean isPartialResponseRequired() {
|
||||
return !this.parametersForPartialResponse.isEmpty();
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,4 +1,5 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
|
||||
/**
|
||||
* Service for serializing commands into another format.
|
||||
@@ -7,9 +8,9 @@ package org.mifosplatform.infrastructure.core.api;
|
||||
* Known implementations:
|
||||
* </p>
|
||||
*
|
||||
* @see PortfolioCommandSerializerServiceJson
|
||||
* @see CommandSerializerDefaultToJson
|
||||
*/
|
||||
public interface PortfolioCommandSerializerService {
|
||||
public interface CommandSerializer {
|
||||
|
||||
String serializeCommandToJson(Object command);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Implementation of {@link CommandSerializer} that serializes
|
||||
* the commands into JSON using google-gson.
|
||||
*/
|
||||
@Component
|
||||
public class CommandSerializerDefaultToJson implements CommandSerializer {
|
||||
|
||||
private final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff;
|
||||
|
||||
@Autowired
|
||||
public CommandSerializerDefaultToJson(final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff) {
|
||||
this.excludeNothingWithPrettyPrintingOff = excludeNothingWithPrettyPrintingOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeCommandToJson(Object command) {
|
||||
return excludeNothingWithPrettyPrintingOff.serialize(command);
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* An abstract helper implementation of {@link ToApiJsonSerializer} for
|
||||
* resources to serialize their Java data objects into JSON.
|
||||
*/
|
||||
@Component
|
||||
public final class DefaultToApiJsonSerializer<T> implements ToApiJsonSerializer<T> {
|
||||
|
||||
private final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff;
|
||||
private final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOn;
|
||||
private final GoogleGsonSerializerHelper helper;
|
||||
|
||||
@Autowired
|
||||
public DefaultToApiJsonSerializer(
|
||||
final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOff,
|
||||
final ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson excludeNothingWithPrettyPrintingOn,
|
||||
final GoogleGsonSerializerHelper helper) {
|
||||
this.excludeNothingWithPrettyPrintingOff = excludeNothingWithPrettyPrintingOff;
|
||||
this.excludeNothingWithPrettyPrintingOn = excludeNothingWithPrettyPrintingOn;
|
||||
this.helper = helper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(final Object object) {
|
||||
return this.excludeNothingWithPrettyPrintingOff.serialize(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(final ApiRequestJsonSerializationSettings settings, final Collection<T> collection,
|
||||
final Set<String> supportedResponseParameters) {
|
||||
final Gson delegatedSerializer = findAppropriateSerializer(settings, supportedResponseParameters);
|
||||
return serializeWithSettings(delegatedSerializer, settings, collection.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(final ApiRequestJsonSerializationSettings settings, final T singleObject,
|
||||
final Set<String> supportedResponseParameters) {
|
||||
final Gson delegatedSerializer = findAppropriateSerializer(settings, supportedResponseParameters);
|
||||
return serializeWithSettings(delegatedSerializer, settings, singleObject);
|
||||
}
|
||||
|
||||
private String serializeWithSettings(final Gson gson, final ApiRequestJsonSerializationSettings settings, final Object... dataObject) {
|
||||
String json = null;
|
||||
if (gson != null) {
|
||||
json = helper.serializedJsonFrom(gson, dataObject);
|
||||
} else {
|
||||
if (settings.isPrettyPrint()) {
|
||||
json = this.excludeNothingWithPrettyPrintingOn.serialize(dataObject);
|
||||
} else {
|
||||
json = serialize(dataObject);
|
||||
}
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
private Gson findAppropriateSerializer(final ApiRequestJsonSerializationSettings settings, final Set<String> supportedResponseParameters) {
|
||||
Gson gson = null;
|
||||
if (settings.isPartialResponseRequired()) {
|
||||
gson = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(supportedResponseParameters,
|
||||
settings.isPrettyPrint(), settings.getParametersForPartialResponse());
|
||||
}
|
||||
return gson;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.api.JodaDateTimeAdapter;
|
||||
import org.mifosplatform.infrastructure.core.api.JodaLocalDateAdapter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
/**
|
||||
* <p>A google gson implementation of {@link ExcludeNothingJsonSerializer} contract.</p>
|
||||
*
|
||||
* <p>It serializes all fields of any Java {@link Object} passed to it.</p>
|
||||
*/
|
||||
@Component
|
||||
public final class ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson {
|
||||
|
||||
private final Gson gson;
|
||||
|
||||
public ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson() {
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
||||
builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter());
|
||||
|
||||
this.gson = builder.create();
|
||||
}
|
||||
|
||||
public String serialize(final Object result) {
|
||||
return this.gson.toJson(result);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.api.JodaDateTimeAdapter;
|
||||
import org.mifosplatform.infrastructure.core.api.JodaLocalDateAdapter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
/**
|
||||
* <p>A google gson implementation of {@link ExcludeNothingJsonSerializer} contract.</p>
|
||||
*
|
||||
* <p>It serializes all fields of any Java {@link Object} passed to it.</p>
|
||||
*/
|
||||
@Component
|
||||
public final class ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson {
|
||||
|
||||
private final Gson gson;
|
||||
|
||||
public ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson() {
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
||||
builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter());
|
||||
builder.setPrettyPrinting();
|
||||
|
||||
this.gson = builder.create();
|
||||
}
|
||||
|
||||
public String serialize(final Object result) {
|
||||
return this.gson.toJson(result);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface FromApiJsonDeserializer<T> {
|
||||
|
||||
T commandFromApiJson(final String json);
|
||||
|
||||
T commandFromApiJson(final Long resourceId, final String json);
|
||||
|
||||
String serializedCommandJsonFromApiJson(final String json);
|
||||
|
||||
String serializedCommandJsonFromApiJson(final Long resourceId, final String json);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public interface FromCommandJsonDeserializer<T> {
|
||||
|
||||
T commandFromCommandJson(final String json);
|
||||
|
||||
T commandFromCommandJson(final Long resourceId, final String json);
|
||||
|
||||
T commandFromCommandJson(final Long resourceId, final String json, final boolean makerCheckerApproval);
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
@Component
|
||||
public class FromJsonHelper {
|
||||
|
||||
private final Gson gsonConverter;
|
||||
private final JsonParserHelper helperDelegator;
|
||||
private final JsonParser parser;
|
||||
|
||||
public FromJsonHelper() {
|
||||
this.gsonConverter = new Gson();
|
||||
helperDelegator = new JsonParserHelper();
|
||||
parser = new JsonParser();
|
||||
}
|
||||
|
||||
public void checkForUnsupportedParameters(final Type typeOfMap, final String json, final Set<String> supportedParams) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
List<String> unsupportedParameterList = new ArrayList<String>();
|
||||
for (String providedParameter : requestMap.keySet()) {
|
||||
if (!supportedParams.contains(providedParameter)) {
|
||||
unsupportedParameterList.add(providedParameter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!unsupportedParameterList.isEmpty()) { throw new UnsupportedParameterException(unsupportedParameterList); }
|
||||
}
|
||||
|
||||
public JsonElement parse(final String json) {
|
||||
return parser.parse(json);
|
||||
}
|
||||
|
||||
public String extractStringNamed(final String parameterName, final JsonElement element, final Set<String> parametersPassedInRequest) {
|
||||
return helperDelegator.extractStringNamed(parameterName, element, parametersPassedInRequest);
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -1,4 +1,4 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -6,6 +6,9 @@ import java.util.Set;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.api.JodaDateTimeAdapter;
|
||||
import org.mifosplatform.infrastructure.core.api.JodaLocalDateAdapter;
|
||||
import org.mifosplatform.infrastructure.core.api.ParameterListExclusionStrategy;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -17,7 +20,7 @@ import com.google.gson.GsonBuilder;
|
||||
* Helper class for serialization of java objects into JSON using google-gson.
|
||||
*/
|
||||
@Service
|
||||
public class GoogleGsonSerializerHelper {
|
||||
public final class GoogleGsonSerializerHelper {
|
||||
|
||||
public Gson createGsonBuilder(final boolean prettyPrint) {
|
||||
final GsonBuilder builder = new GsonBuilder();
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosplatform.infrastructure.core.api;
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package org.mifosplatform.infrastructure.core.serialization;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ToApiJsonSerializer<T> {
|
||||
|
||||
String serialize(final Object object);
|
||||
|
||||
String serialize(final ApiRequestJsonSerializationSettings settings, Collection<T> collection, Set<String> supportedResponseParameters);
|
||||
|
||||
String serialize(final ApiRequestJsonSerializationSettings settings, T single, Set<String> supportedResponseParameters);
|
||||
}
|
||||
+1
-1
@@ -12,10 +12,10 @@ import java.util.Set;
|
||||
import javax.sql.rowset.CachedRowSet;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonParserHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.JsonParserHelper;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnHeader;
|
||||
|
||||
+3
-3
@@ -17,8 +17,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.command.CurrencyCommand;
|
||||
import org.mifosplatform.organisation.monetary.data.ConfigurationData;
|
||||
@@ -38,7 +38,7 @@ public class CurrenciesApiResource {
|
||||
private final OrganisationCurrencyReadPlatformService readPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
@@ -46,7 +46,7 @@ public class CurrenciesApiResource {
|
||||
final OrganisationCurrencyReadPlatformService readPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -18,8 +18,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.organisation.office.data.OfficeTransactionData;
|
||||
@@ -40,7 +40,7 @@ public class OfficeTransactionsApiResource {
|
||||
private final OfficeReadPlatformService readPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
@@ -48,7 +48,7 @@ public class OfficeTransactionsApiResource {
|
||||
final OfficeReadPlatformService readPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.command.OfficeCommand;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
@@ -43,7 +43,7 @@ public class OfficesApiResource {
|
||||
private final OfficeReadPlatformService readPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
@@ -51,7 +51,7 @@ public class OfficesApiResource {
|
||||
final OfficeReadPlatformService readPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -22,8 +22,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeLookup;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -53,13 +53,13 @@ public class StaffApiResource {
|
||||
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
|
||||
@Autowired
|
||||
public StaffApiResource(final PlatformSecurityContext context, final StaffReadPlatformService readPlatformService,
|
||||
final OfficeReadPlatformService officeReadPlatformService, final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
@@ -41,7 +41,7 @@ public class ChargesApiResource {
|
||||
private final PlatformSecurityContext context;
|
||||
private final ChargeReadPlatformService readPlatformService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ChargesApiResource {
|
||||
public ChargesApiResource(final PlatformSecurityContext context,
|
||||
final ChargeReadPlatformService readPlatformService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
|
||||
+3
-3
@@ -23,8 +23,8 @@ import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformServi
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
@@ -46,7 +46,7 @@ public class ClientIdentifiersApiResource {
|
||||
private final ClientReadPlatformService clientReadPlatformService;
|
||||
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ClientIdentifiersApiResource {
|
||||
public ClientIdentifiersApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
|
||||
final CodeValueReadPlatformService codeValueReadPlatformService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
|
||||
+3
-3
@@ -30,9 +30,9 @@ import org.mifosplatform.infrastructure.core.api.ApiConstants;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.FileUtils;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeLookup;
|
||||
@@ -68,7 +68,7 @@ public class ClientsApiResource {
|
||||
private final ClientWritePlatformService clientWritePlatformService;
|
||||
private final OfficeReadPlatformService officeReadPlatformService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioCommandsReadPlatformService commandSourceReadPlatformService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
@@ -77,7 +77,7 @@ public class ClientsApiResource {
|
||||
public ClientsApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
|
||||
final ClientWritePlatformService clientWritePlatformService, final OfficeReadPlatformService officeReadPlatformService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioCommandsReadPlatformService commandsReadPlatformService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
|
||||
+3
-3
@@ -20,8 +20,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
@@ -41,14 +41,14 @@ public class FundsApiResource {
|
||||
private final FundReadPlatformService readPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public FundsApiResource(final PlatformSecurityContext context, final FundReadPlatformService readPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -24,10 +24,10 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
@@ -90,7 +90,7 @@ public class LoansApiResource {
|
||||
private final GuarantorReadPlatformService guarantorReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
@@ -102,7 +102,7 @@ public class LoansApiResource {
|
||||
final GuarantorReadPlatformService guarantorReadPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.loanReadPlatformService = loanReadPlatformService;
|
||||
|
||||
+3
-3
@@ -20,9 +20,9 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
||||
@@ -54,7 +54,7 @@ public class LoanProductsApiResource {
|
||||
private final LoanDropdownReadPlatformService dropdownReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
@@ -63,7 +63,7 @@ public class LoanProductsApiResource {
|
||||
final FundReadPlatformService fundReadPlatformService, final LoanDropdownReadPlatformService dropdownReadPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.loanProductReadPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -18,8 +18,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.useradministration.command.PermissionsCommand;
|
||||
import org.mifosplatform.useradministration.data.PermissionUsageData;
|
||||
@@ -39,7 +39,7 @@ public class PermissionsApiResource {
|
||||
private final PermissionReadPlatformService permissionReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
@@ -48,7 +48,7 @@ public class PermissionsApiResource {
|
||||
final PermissionReadPlatformService readPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.permissionReadPlatformService = readPlatformService;
|
||||
|
||||
+3
-3
@@ -24,8 +24,8 @@ import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.useradministration.command.RoleCommand;
|
||||
import org.mifosplatform.useradministration.command.RolePermissionCommand;
|
||||
@@ -50,7 +50,7 @@ public class RolesApiResource {
|
||||
private final PermissionReadPlatformService permissionReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandsReadPlatformService commandSourceReadPlatformService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final PortfolioCommandDeserializerService commandDeserializerService;
|
||||
@@ -62,7 +62,7 @@ public class RolesApiResource {
|
||||
final PermissionReadPlatformService permissionReadPlatformService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandsReadPlatformService commandSourceReadPlatformService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
final PortfolioCommandDeserializerService commandDeserializerService) {
|
||||
|
||||
+3
-3
@@ -22,8 +22,8 @@ import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformSer
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.serialization.CommandSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeLookup;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -46,14 +46,14 @@ public class UsersApiResource {
|
||||
private final OfficeReadPlatformService officeReadPlatformService;
|
||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||
private final PortfolioCommandSerializerService commandSerializerService;
|
||||
private final CommandSerializer commandSerializerService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public UsersApiResource(final PlatformSecurityContext context, final AppUserReadPlatformService readPlatformService,
|
||||
final OfficeReadPlatformService officeReadPlatformService, final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioCommandSerializerService commandSerializerService,
|
||||
final CommandSerializer commandSerializerService,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosplatform.useradministration.domain;
|
||||
package org.mifosplatform.useradministration.exception;
|
||||
|
||||
public class PasswordMustBeDifferentException extends RuntimeException {
|
||||
// basic runtime exception
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosplatform.useradministration.domain;
|
||||
package org.mifosplatform.useradministration.exception;
|
||||
|
||||
public class UsernameMustBeDifferentException extends RuntimeException {
|
||||
// basic runtime exception
|
||||
Reference in New Issue
Block a user