diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java b/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java deleted file mode 100644 index e2b66886d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/DataValidatorBuilder.java +++ /dev/null @@ -1,305 +0,0 @@ -package org.mifosng.platform; - -import java.math.BigDecimal; -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.ApiParameterError; -import org.springframework.util.ObjectUtils; - -public class DataValidatorBuilder { - - private final List dataValidationErrors; - private String resource; - private String parameter; - private Object value; - private boolean ignoreNullValue = false; - - public DataValidatorBuilder(List dataValidationErrors) { - this.dataValidationErrors = dataValidationErrors; - } - - public DataValidatorBuilder reset() { - return new DataValidatorBuilder(dataValidationErrors).resource(resource); - } - - public DataValidatorBuilder resource(final String resource) { - this.resource = resource; - return this; - } - - public DataValidatorBuilder parameter(final String parameter) { - this.parameter = parameter; - return this; - } - - public DataValidatorBuilder value(Object value) { - this.value = value; - return this; - } - - public DataValidatorBuilder ignoreIfNull() { - this.ignoreNullValue = true; - return this; - } - - - public DataValidatorBuilder andNotBlank(String linkedParameterName, String linkedValue) { - if (value == null && linkedValue == null && ignoreNullValue) { - return this; - } - - if (StringUtils.isBlank(linkedValue)) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(linkedParameterName).append(".cannot.be.empty.when.").append(parameter).append(".is.populated"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" cannot be empty when ").append(parameter).append(" is populated."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), linkedParameterName, linkedValue, value); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder equalToParameter(String linkedParameterName, Object linkedValue) { - if (value == null && linkedValue == null && ignoreNullValue) { - return this; - } - - if (value != null && !value.equals(linkedValue)) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(linkedParameterName).append(".not.equal.to.").append(parameter); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is not equal to ").append(parameter).append("."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), linkedParameterName, linkedValue, value); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder notSameAsParameter(String linkedParameterName, Object linkedValue) { - if (value == null && linkedValue == null && ignoreNullValue) { - return this; - } - - if (value != null && value.equals(linkedValue)) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(linkedParameterName).append(".same.as.").append(parameter); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is same as ").append(parameter).append("."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), linkedParameterName, linkedValue, value); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder trueOrFalseRequired(boolean trueOfFalseFieldProvided) { - if (!trueOfFalseFieldProvided && !ignoreNullValue) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".must.be.true.or.false"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be set as true or false."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder notNull() { - if (value == null && !ignoreNullValue) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be blank."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder notBlank() { - if (value == null && ignoreNullValue) { - return this; - } - - if (value == null || StringUtils.isBlank(value.toString())) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be blank."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder notExceedingLengthOf(Integer maxLength) { - if (value == null && ignoreNullValue) { - return this; - } - - if (value != null && value.toString().trim().length() > maxLength) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".exceeds.max.length"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" exceeds max length of ").append(maxLength).append("."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, maxLength, value.toString()); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder inMinMaxRange(Integer min, Integer max) { - if (value == null && ignoreNullValue) { - return this; - } - - if (value != null) { - Integer number = Integer.valueOf(value.toString()); - if (number < min || number > max) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".is.not.within.expected.range"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be between ").append(min).append(" and ").append(max).append("."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, min, max); - dataValidationErrors.add(error); - } - } - return this; - } - - public DataValidatorBuilder positiveAmount() { - if (value == null && ignoreNullValue) { - return this; - } - - if (value != null) { - BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString())); - if (number.compareTo(BigDecimal.ZERO) <= 0) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.greater.than.zero"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than 0."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0); - dataValidationErrors.add(error); - } - } - return this; - } - - public DataValidatorBuilder zeroOrPositiveAmount() { - if (value == null && ignoreNullValue) { - return this; - } - - if (value != null) { - BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString())); - if (number.compareTo(BigDecimal.ZERO) < 0) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.zero.or.greater"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than or equal to 0."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0); - dataValidationErrors.add(error); - } - } - return this; - } - - public DataValidatorBuilder integerGreaterThanZero() { - if (value == null && ignoreNullValue) { - return this; - } - - if (value != null) { - Integer number = Integer.valueOf(value.toString()); - if (number < 1) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.greater.than.zero"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than 0."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0); - dataValidationErrors.add(error); - } - } - return this; - } - - public DataValidatorBuilder longGreaterThanZero() { - if (value == null && ignoreNullValue) { - return this; - } - - if (value != null) { - Long number = Long.valueOf(value.toString()); - if (number < 1) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.greater.than.zero"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than 0."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0); - dataValidationErrors.add(error); - } - } - return this; - } - - public DataValidatorBuilder arrayNotEmpty() { - if (value == null && ignoreNullValue) { - return this; - } - - Object[] array = (Object[]) value; - if (ObjectUtils.isEmpty(array)) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.empty"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be empty. You must select at least one."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder anyOfNotNull(Object... object) { - boolean hasData = false; - for (Object obj : object) { - if (obj != null) { - hasData = true; - break; - } - } - - if (!hasData) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".no.parameters.for.update"); - StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), "id"); - dataValidationErrors.add(error); - } - return this; - } - - public DataValidatorBuilder inValidValue(String parameterValueCode, Object invalidValue) { - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".invalid.").append(parameterValueCode); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" has an invalid value."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, invalidValue); - dataValidationErrors.add(error); - return this; - } - - public DataValidatorBuilder mustBeBlankWhenParameterProvided(String parameterName, Object parameterValue) { - if (value == null && ignoreNullValue) { - return this; - } - - if (value == null && parameterValue != null) { - return this; - } - - if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null && StringUtils.isNotBlank(parameterValue.toString())) { - return this; - } - - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot also be provided when ").append(parameterName).append(" is populated."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, value, parameterName, parameterValue); - dataValidationErrors.add(error); - return this; - } - - public DataValidatorBuilder comapareMinimumAndMaximumAmounts(BigDecimal minimumBalance,BigDecimal maximumBalance){ - if(minimumBalance!=null&&maximumBalance!=null) - if(maximumBalance.compareTo(minimumBalance)==-1){ - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".is.not.within.expected.range"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ").append(minimumBalance).append(" should less than maximum amount ").append(maximumBalance).append("."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, minimumBalance, maximumBalance); - dataValidationErrors.add(error); - return this; - } - return this; - } - public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(BigDecimal min,BigDecimal max){ - if(min!=null&&max!=null) - if(max.compareTo(min)==-1){ - StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".is.not.within.expected.range"); - StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min).append(" should less than max number ").append(max).append("."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, min, max); - dataValidationErrors.add(error); - return this; - } - return this; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/InvalidSqlException.java b/mifosng-provider/src/main/java/org/mifosng/platform/InvalidSqlException.java deleted file mode 100644 index e87d4fe5f..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/InvalidSqlException.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.mifosng.platform; - -import java.sql.SQLException; - -public class InvalidSqlException extends RuntimeException { - - private final String sql; - - public InvalidSqlException(SQLException e, String sql) { - super(e); - this.sql = sql; - } - - public String getSql() { - return sql; - } -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java deleted file mode 100755 index b5806fe42..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientIdentifiersApiResource.java +++ /dev/null @@ -1,191 +0,0 @@ -package org.mifosng.platform.api; - -import java.util.Collection; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.mifosng.platform.api.commands.ClientIdentifierCommand; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.data.ClientIdentifierData; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.client.service.ClientReadPlatformService; -import org.mifosng.platform.client.service.ClientWritePlatformService; -import org.mifosng.platform.exceptions.DuplicateClientIdentifierException; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; -import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; -import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -@Path("/clients/{clientId}/identifiers") -@Component -@Scope("singleton") -public class ClientIdentifiersApiResource { - - @Autowired - private ClientReadPlatformService clientReadPlatformService; - - @Autowired - private CodeValueReadPlatformService codeValueReadPlatformService; - - @Autowired - private ClientWritePlatformService clientWritePlatformService; - - @Autowired - private PortfolioApiDataConversionService apiDataConversionService; - - @Autowired - private PortfolioApiJsonSerializerService apiJsonSerializerService; - - @Autowired - private PlatformSecurityContext context; - - private final String entityType = "CLIENTIDENTIFIER"; - - @GET - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAllClientIdentifiers( - @Context final UriInfo uriInfo, - @PathParam("clientId") final Long clientId) { - - context.authenticatedUser().validateHasReadPermission(entityType); - - final Set responseParameters = ApiParameterHelper - .extractFieldsForResponseIfProvided(uriInfo - .getQueryParameters()); - final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); - - final Collection clientIdentifiers = this.clientReadPlatformService.retrieveClientIdentifiers(clientId); - - return this.apiJsonSerializerService - .serializeClientIdentifierDataToJson(prettyPrint, - responseParameters, clientIdentifiers); - } - - @GET - @Path("template") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String newClientDetails(@Context final UriInfo uriInfo) { - - context.authenticatedUser().validateHasReadPermission(entityType); - - final Set responseParameters = ApiParameterHelper - .extractFieldsForResponseIfProvided(uriInfo - .getQueryParameters()); - final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); - - Collection codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues(); - ClientIdentifierData clientIdentifierData = ClientIdentifierData.template(codeValues); - - return this.apiJsonSerializerService - .serializeClientIdentifierDataToJson(prettyPrint, - responseParameters, clientIdentifierData); - } - - @POST - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public Response createClientIdentifier( - @PathParam("clientId") final Long clientId, - final String jsonRequestBody) { - - try { - final ClientIdentifierCommand command = this.apiDataConversionService.convertJsonToClientIdentifierCommand(null, clientId, jsonRequestBody); - - Long clientIdentifierId = this.clientWritePlatformService.addClientIdentifier(command); - - return Response.ok().entity(new EntityIdentifier(clientIdentifierId)).build(); - } - catch (DuplicateClientIdentifierException e) { - DuplicateClientIdentifierException rethrowas = e; - if (e.getDocumentTypeId() != null) { - // need to fetch client info - ClientData clientInfo = this.clientReadPlatformService.retrieveClientByIdentifier(e.getDocumentTypeId(), e.getIdentifierKey()); - rethrowas = new DuplicateClientIdentifierException(clientInfo.displayName(), clientInfo.officeName(), e.getIdentifierType(), e.getIdentifierKey()); - } - throw rethrowas; - } - } - - @GET - @Path("{identifierId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String getClientIdentifier( - @PathParam("clientId") final Long clientId, - @PathParam("identifierId") final Long clientIdentifierId, - @Context final UriInfo uriInfo) { - - context.authenticatedUser().validateHasReadPermission(entityType); - - final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); - final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); - final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); - - ClientIdentifierData clientIdentifierData = this.clientReadPlatformService.retrieveClientIdentifier(clientId, clientIdentifierId); - if (template) { - final Collection codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues(); - clientIdentifierData = ClientIdentifierData.template(clientIdentifierData, codeValues); - } - - return this.apiJsonSerializerService - .serializeClientIdentifierDataToJson(prettyPrint, - responseParameters, clientIdentifierData); - } - - @PUT - @Path("{identifierId}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - public Response updateClientIdentifer( - @PathParam("clientId") final Long clientId, - @PathParam("identifierId") final Long clientIdentifierId, - final String jsonRequestBody) { - - try { - final ClientIdentifierCommand command = this.apiDataConversionService.convertJsonToClientIdentifierCommand(clientIdentifierId, clientId, jsonRequestBody); - - final EntityIdentifier identifier = this.clientWritePlatformService.updateClientIdentifier(command); - - return Response.ok().entity(identifier).build(); - } - catch (DuplicateClientIdentifierException e) { - DuplicateClientIdentifierException reThrowAs = e; - if (e.getDocumentTypeId() != null) { - ClientData clientInfo = this.clientReadPlatformService.retrieveClientByIdentifier(e.getDocumentTypeId(), e.getIdentifierKey()); - reThrowAs = new DuplicateClientIdentifierException(clientInfo.displayName(), clientInfo.officeName(), e.getIdentifierType(), e.getIdentifierKey()); - } - throw reThrowAs; - } - } - - @DELETE - @Path("{identifierId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public Response deleteClientIdentifier( - @PathParam("identifierId") final Long clientIdentifierId) { - - this.clientWritePlatformService.deleteClientIdentifier(clientIdentifierId); - - return Response.ok(new EntityIdentifier(clientIdentifierId)).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java index 9f62e2f6c..827a0876a 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java @@ -30,16 +30,16 @@ import org.mifosng.platform.api.commands.UndoStateTransitionCommand; import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositPermissionData; import org.mifosng.platform.api.data.DepositProductLookup; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.exceptions.UnrecognizedQueryParamException; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosng.platform.saving.service.DepositAccountReadPlatformService; import org.mifosng.platform.saving.service.DepositAccountWritePlatformService; import org.mifosng.platform.savingproduct.service.DepositProductReadPlatformService; import org.mifosng.platform.savingproduct.service.SavingsDepositEnumerations; +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.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java index 515db9bc7..4569ff00c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositProductsApiResource.java @@ -21,16 +21,16 @@ import javax.ws.rs.core.UriInfo; import org.mifosng.platform.api.commands.DepositProductCommand; import org.mifosng.platform.api.data.DepositProductData; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosng.platform.savingproduct.service.DepositProductReadPlatformService; import org.mifosng.platform.savingproduct.service.DepositProductWritePlatformService; import org.mifosng.platform.savingproduct.service.SavingsDepositEnumerations; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService; +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.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/DocumentManagementApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/DocumentManagementApiResource.java index 5d2dc6bf9..70c1c9bf5 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/DocumentManagementApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/DocumentManagementApiResource.java @@ -24,13 +24,13 @@ import javax.ws.rs.core.UriInfo; import org.mifosng.platform.api.commands.DocumentCommand; import org.mifosng.platform.api.data.DocumentData; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.ApiConstants; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; import org.mifosng.platform.documentmanagement.service.DocumentReadPlatformService; import org.mifosng.platform.documentmanagement.service.DocumentWritePlatformService; -import org.mifosng.platform.infrastructure.FileUtils; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.ApiConstants; +import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.service.FileUtils; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java index 36ccccfd0..e84e8c7f4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java @@ -21,19 +21,19 @@ import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.api.data.ClientLookup; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; import org.mifosng.platform.api.data.GroupData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.client.service.ClientReadPlatformService; import org.mifosng.platform.group.service.GroupReadPlatformService; import org.mifosng.platform.group.service.GroupWritePlatformService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; +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.data.EntityIdentifier; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.data.ClientLookup; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java index a87afb67a..956c3b532 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java @@ -18,13 +18,13 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.mifosng.platform.api.commands.GuarantorCommand; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.GuarantorData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; import org.mifosng.platform.guarantor.GuarantorReadPlatformService; import org.mifosng.platform.guarantor.GuarantorWritePlatformService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; +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.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java index 41fb014c5..af87479d7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java @@ -28,8 +28,6 @@ import org.mifosng.platform.api.commands.LoanStateTransitionCommand; import org.mifosng.platform.api.commands.LoanTransactionCommand; import org.mifosng.platform.api.commands.UndoStateTransitionCommand; import org.mifosng.platform.api.data.DisbursementData; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.GuarantorData; import org.mifosng.platform.api.data.LoanAccountData; import org.mifosng.platform.api.data.LoanBasicDetailsData; @@ -37,22 +35,24 @@ import org.mifosng.platform.api.data.LoanChargeData; import org.mifosng.platform.api.data.LoanPermissionData; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanTransactionData; -import org.mifosng.platform.api.data.StaffAccountSummaryCollectionData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.exceptions.UnrecognizedQueryParamException; import org.mifosng.platform.guarantor.GuarantorReadPlatformService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosng.platform.loan.service.CalculationPlatformService; import org.mifosng.platform.loan.service.LoanReadPlatformService; import org.mifosng.platform.loan.service.LoanWritePlatformService; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +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.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand; import org.mifosplatform.infrastructure.staff.data.BulkTransferLoanOfficerData; +import org.mifosplatform.infrastructure.staff.data.StaffAccountSummaryCollectionData; import org.mifosplatform.infrastructure.staff.data.StaffData; import org.mifosplatform.infrastructure.staff.service.StaffReadPlatformService; import org.mifosplatform.portfolio.charge.data.ChargeData; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java index 4d748be2f..246d1cbc4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingProductsApiResource.java @@ -20,12 +20,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.SavingProductData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosng.platform.savingproduct.domain.SavingFrequencyType; import org.mifosng.platform.savingproduct.domain.SavingInterestCalculationMethod; import org.mifosng.platform.savingproduct.domain.SavingProductType; @@ -37,6 +32,11 @@ import org.mifosng.platform.savingproduct.service.SavingProductReadPlatformServi import org.mifosng.platform.savingproduct.service.SavingProductWritePlatformService; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService; +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.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingsAccountApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingsAccountApiResource.java index 775d38c9f..cf507ceb7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingsAccountApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/SavingsAccountApiResource.java @@ -19,13 +19,13 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.mifosng.platform.api.commands.SavingAccountCommand; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.SavingAccountData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosng.platform.saving.service.SavingAccountReadPlatformService; import org.mifosng.platform.saving.service.SavingAccountWritePlatformService; +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.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ClientIdentifierCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ClientIdentifierCommand.java deleted file mode 100755 index fb4bca3ae..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ClientIdentifierCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.mifosng.platform.api.commands; - -import java.util.Set; - -/** - * Immutable command for creating or updating details of a client identifier. - */ -public class ClientIdentifierCommand { - - private final Long id; - private final Long clientId; - private final Long documentTypeId; - - private final String documentKey; - private final String description; - - private final Set modifiedParameters; - - public ClientIdentifierCommand(final Set modifiedParameters, - final Long id, final Long clientId, final Long documentTypeId, - final String documentKey, final String description) { - this.modifiedParameters = modifiedParameters; - this.id = id; - this.clientId = clientId; - this.documentTypeId = documentTypeId; - this.documentKey = documentKey; - this.description = description; - } - - public Long getId() { - return id; - } - - public Long getDocumentTypeId() { - return documentTypeId; - } - - public String getDocumentKey() { - return documentKey; - } - - public String getDescription() { - return description; - } - - public Set getModifiedParameters() { - return modifiedParameters; - } - - public Long getClientId() { - return clientId; - } - - public boolean isDocumentTypeChanged() { - return this.modifiedParameters.contains("documentTypeId"); - } - - public boolean isDocumentKeyChanged() { - return this.modifiedParameters.contains("documentKey"); - } - - public boolean isDescriptionChanged() { - return this.modifiedParameters.contains("description"); - } - -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/NoteCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/NoteCommand.java deleted file mode 100644 index be0a225da..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/NoteCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.mifosng.platform.api.commands; - -/** - * Immutable command used for create or update of notes. - */ -public class NoteCommand { - - private final Long id; - private final Long clientId; - private final Long loanId; - private final Long loanTransactionId; - private final String note; - - public NoteCommand(final Long id, Long clientId, final String note) { - this.id = id; - this.clientId = clientId; - this.loanId = null; - this.loanTransactionId = null; - this.note = note; - } - - public Long getId() { - return id; - } - - public Long getClientId() { - return clientId; - } - - public Long getLoanId() { - return loanId; - } - - public Long getLoanTransactionId() { - return loanTransactionId; - } - - public String getNote() { - return note; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientAccountSummaryData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientAccountSummaryData.java deleted file mode 100644 index b67263097..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientAccountSummaryData.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.mifosng.platform.api.data; - -/** - * Immutable data object for client loan accounts. - */ -public class ClientAccountSummaryData { - - private final Long id; - private final String externalId; - private final Long productId; - private final String productName; - private final Integer accountStatusId; - - public ClientAccountSummaryData( - final Long id, - final String externalId, - final Long productId, - final String loanProductName, - final Integer loanStatusId) { - this.id = id; - this.externalId = externalId; - this.productId = productId; - this.productName = loanProductName; - this.accountStatusId = loanStatusId; - } - - public Long getId() { - return id; - } - - public String getExternalId() { - return externalId; - } - - public Long getProductId() { - return productId; - } - - public String getProductName() { - return productName; - } - - public Integer getAccountStatusId() { - return accountStatusId; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientIdentifierData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientIdentifierData.java deleted file mode 100755 index 83425c21c..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientIdentifierData.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.mifosng.platform.api.data; - -import java.util.Collection; - -import org.mifosplatform.infrastructure.codes.data.CodeValueData; - -/** - * Immutable data object represent client identity data. - */ -public class ClientIdentifierData { - - private final Long id; - private final Long clientId; - private final Long documentTypeId; - private final String documentTypeName; - private final String documentKey; - private final String description; - @SuppressWarnings("unused") - private final Collection allowedDocumentTypes; - - public static ClientIdentifierData singleItem( - final Long id, - final Long clientId, - final Long documentTypeId, - final String documentKey, - final String description, - final String documentTypeName) { - return new ClientIdentifierData(id, clientId, documentTypeId, documentKey, description, documentTypeName, null); - } - - public static ClientIdentifierData template(final Collection codeValues) { - return new ClientIdentifierData(null, null, null, null, null, null, codeValues); - } - - public static ClientIdentifierData template( - final ClientIdentifierData data, - final Collection codeValues) { - return new ClientIdentifierData(data.id, data.clientId, data.documentTypeId, data.documentKey, data.description, data.documentTypeName, codeValues); - } - - public ClientIdentifierData( - final Long id, - final Long clientId, - final Long documentTypeId, - final String documentKey, - final String description, - final String documentTypeName, - final Collection allowedDocumentTypes) { - this.id = id; - this.clientId = clientId; - this.documentTypeId = documentTypeId; - this.documentKey = documentKey; - this.description = description; - this.documentTypeName = documentTypeName; - this.allowedDocumentTypes = allowedDocumentTypes; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java index 75863dc17..b84824500 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java @@ -11,6 +11,7 @@ import org.joda.time.Days; import org.joda.time.LocalDate; import org.joda.time.Months; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; /** * Immutable data object for deposit accounts. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountTransactionData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountTransactionData.java index d845a55ba..a34f0ae09 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountTransactionData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountTransactionData.java @@ -3,6 +3,7 @@ package org.mifosng.platform.api.data; import java.math.BigDecimal; import org.joda.time.LocalDate; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; /** * Immutable data object to represent transactions on a deposit account. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java index d333f68d7..043ccd806 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositProductData.java @@ -6,6 +6,7 @@ import java.util.List; import org.joda.time.DateTime; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; /** * Immutable data object representing details of a deposit product. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java index 3a3125534..1b5c576ee 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java @@ -3,6 +3,7 @@ package org.mifosng.platform.api.data; import java.util.Collection; import org.mifosplatform.infrastructure.office.data.OfficeLookup; +import org.mifosplatform.portfolio.client.data.ClientLookup; /** * Immutable data object representing groups. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanAccountData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanAccountData.java index e5e8d9e88..49bdbccfe 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanAccountData.java @@ -5,6 +5,7 @@ import java.util.Collection; import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.staff.data.StaffData; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.fund.data.FundData; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanBasicDetailsData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanBasicDetailsData.java index 8629b41fd..a8519f14c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanBasicDetailsData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanBasicDetailsData.java @@ -9,6 +9,7 @@ import org.joda.time.Days; import org.joda.time.LocalDate; import org.joda.time.Months; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanChargeData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanChargeData.java index b9399b236..2061ef712 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanChargeData.java @@ -5,6 +5,7 @@ import java.util.Collection; import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.charge.data.ChargeData; /** diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanTransactionData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanTransactionData.java index 0fc92176f..3182cc841 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanTransactionData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/LoanTransactionData.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; /** * Immutable data object representing a loan transaction. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java deleted file mode 100644 index 6cbedab18..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/NoteData.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.mifosng.platform.api.data; - -import org.joda.time.DateTime; - -public class NoteData { - - private Long id; - private Long clientId; - private Long loanId; - private Long loanTransactionId; - private EnumOptionData noteType; - - private String note; - - private Long createdById; - private String createdByUsername; - private DateTime createdOn; - private Long updatedById; - private String updatedByUsername; - private DateTime updatedOn; - - public NoteData() { - // - } - - public NoteData(Long id, Long clientId, Long loanId, - Long transactionId, EnumOptionData noteType, String note, - DateTime createdDate, Long createdById, String createdByUsername, - DateTime lastModifiedDate, Long lastModifiedById, String updatedByUsername) { - this.id = id; - this.clientId = clientId; - this.loanId = loanId; - this.loanTransactionId = transactionId; - this.noteType = noteType; - this.note = note; - this.createdOn = createdDate; - this.createdById = createdById; - this.createdByUsername = createdByUsername; - this.updatedOn = lastModifiedDate; - this.updatedById = lastModifiedById; - this.updatedByUsername = updatedByUsername; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getClientId() { - return clientId; - } - - public void setClientId(Long clientId) { - this.clientId = clientId; - } - - public Long getLoanId() { - return loanId; - } - - public void setLoanId(Long loanId) { - this.loanId = loanId; - } - - public Long getLoanTransactionId() { - return loanTransactionId; - } - - public void setLoanTransactionId(Long loanTransactionId) { - this.loanTransactionId = loanTransactionId; - } - - public String getNote() { - return note; - } - - public void setNote(String note) { - this.note = note; - } - - public Long getCreatedById() { - return createdById; - } - - public void setCreatedById(Long createdById) { - this.createdById = createdById; - } - - public String getCreatedByUsername() { - return createdByUsername; - } - - public void setCreatedByUsername(String createdByUsername) { - this.createdByUsername = createdByUsername; - } - - public DateTime getCreatedOn() { - return createdOn; - } - - public void setCreatedOn(DateTime createdOn) { - this.createdOn = createdOn; - } - - public Long getUpdatedById() { - return updatedById; - } - - public void setUpdatedById(Long updatedById) { - this.updatedById = updatedById; - } - - public String getUpdatedByUsername() { - return updatedByUsername; - } - - public void setUpdatedByUsername(String updatedByUsername) { - this.updatedByUsername = updatedByUsername; - } - - public DateTime getUpdatedOn() { - return updatedOn; - } - - public void setUpdatedOn(DateTime updatedOn) { - this.updatedOn = updatedOn; - } - - public EnumOptionData getNoteType() { - return noteType; - } - - public void setNoteType(EnumOptionData noteType) { - this.noteType = noteType; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingAccountData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingAccountData.java index c1c73f6dd..c7cda59ac 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingAccountData.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; /** * Immutable data object reprsenting a savings account. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingProductData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingProductData.java index 9bc8caca9..341f77600 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingProductData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/SavingProductData.java @@ -7,6 +7,7 @@ import java.util.List; import org.joda.time.DateTime; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; public class SavingProductData implements Serializable { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/StaffAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/StaffAccountSummaryCollectionData.java deleted file mode 100644 index 70ee4a4f3..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/StaffAccountSummaryCollectionData.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.mifosng.platform.api.data; - -import java.util.Collection; -import java.util.List; - -/** - * - */ -public class StaffAccountSummaryCollectionData { - - @SuppressWarnings("unused") - private final List clients; - @SuppressWarnings("unused") - private final List groups; - - public StaffAccountSummaryCollectionData(final List clients, final List groups) { - this.clients = clients; - this.groups = groups; - } - - public static final class ClientSummary { - - private final Long id; - private final String displayName; - - private Collection loans; - - public ClientSummary(Long id, String displayName) { - this.id = id; - this.displayName = displayName; - } - - public Long getId() { - return id; - } - - public String getDisplayName() { - return displayName; - } - - public Collection getLoans() { - return loans; - } - - public void setLoans(Collection loans) { - this.loans = loans; - } - } - - public static final class GroupSummary { - - private final Long id; - private final String name; - - private Collection loans; - - public GroupSummary(Long id, String name) { - this.id = id; - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public Collection getLoans() { - return loans; - } - - public void setLoans(Collection loans) { - this.loans = loans; - } - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientIdentifier.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientIdentifier.java deleted file mode 100755 index a2b7d0a2c..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientIdentifier.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.mifosng.platform.client.domain; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; - -import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.commands.ClientIdentifierCommand; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; -import org.mifosplatform.infrastructure.codes.domain.CodeValue; -import org.mifosplatform.infrastructure.user.domain.AppUser; - -@Entity -@Table(name = "m_client_identifier", uniqueConstraints = { - @UniqueConstraint(columnNames = { "document_type_id", "document_key" }, name = "unique_identifier_key"), - @UniqueConstraint(columnNames = { "client_id", "document_type_id" }, name = "unique_client_identifier") }) -public class ClientIdentifier extends AbstractAuditableCustom { - - @ManyToOne - @JoinColumn(name = "client_id", nullable = false) - private Client client; - - @ManyToOne - @JoinColumn(name = "document_type_id", nullable = false) - private CodeValue documentType; - - @Column(name = "document_key", length = 1000) - private String documentKey; - - @Column(name = "description", length = 1000) - private String description; - - public ClientIdentifier() { - this.client = null; - this.documentType = null; - this.documentKey = null; - this.description = null; - } - - public static ClientIdentifier createNew(final Client client, - final CodeValue documentType, final String documentKey, - final String description) { - return new ClientIdentifier(client, documentType, documentKey, - description); - } - - private ClientIdentifier(final Client client, final CodeValue documentType, - final String documentKey, final String description) { - this.client = client; - this.documentType = documentType; - this.documentKey = StringUtils.defaultIfEmpty(documentKey, null); - this.description = StringUtils.defaultIfEmpty(description, null); - } - - public void update( - final ClientIdentifierCommand command, - final CodeValue documentType) { - - if (command.isDocumentTypeChanged()) { - this.documentType = documentType; - } - - if (command.isDocumentKeyChanged()) { - this.documentKey = StringUtils.defaultIfEmpty( - command.getDocumentKey(), null); - } - - if (command.isDescriptionChanged()) { - this.description = StringUtils.defaultIfEmpty( - command.getDescription(), null); - } - } - - public Client getClient() { - return client; - } - - public CodeValue getDocumentType() { - return documentType; - } - - public String getDocumentKey() { - return documentKey; - } - - public String getDescription() { - return description; - } - -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientIdentifierRepository.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientIdentifierRepository.java deleted file mode 100755 index 23a0ca932..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientIdentifierRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.mifosng.platform.client.domain; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -public interface ClientIdentifierRepository extends - JpaRepository, - JpaSpecificationExecutor { - // no behaviour -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientIdentifierCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientIdentifierCommandValidator.java deleted file mode 100755 index 1ddd9f55d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientIdentifierCommandValidator.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.mifosng.platform.client.service; - -import java.util.ArrayList; -import java.util.List; - -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.commands.ClientIdentifierCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; - -public class ClientIdentifierCommandValidator { - - private final ClientIdentifierCommand command; - - public ClientIdentifierCommandValidator(ClientIdentifierCommand command) { - this.command = command; - } - - public void validateForUpdate() { - List dataValidationErrors = new ArrayList(); - - DataValidatorBuilder baseDataValidator = new DataValidatorBuilder( - dataValidationErrors).resource("clientIdentifier"); - - baseDataValidator.reset().parameter("documentKey") - .value(command.getDocumentKey()).ignoreIfNull().notBlank(); - - if (command.isDocumentTypeChanged()) { - baseDataValidator.reset().parameter("documentTypeId") - .value(command.getDocumentTypeId()).notNull() - .integerGreaterThanZero(); - } - - baseDataValidator.reset().anyOfNotNull(command.getDocumentTypeId(), - command.getDocumentKey()); - - if (!dataValidationErrors.isEmpty()) { - throw new PlatformApiDataValidationException( - "validation.msg.validation.errors.exist", - "Validation errors exist.", dataValidationErrors); - } - } - - public void validateForCreate() { - List dataValidationErrors = new ArrayList(); - - DataValidatorBuilder baseDataValidator = new DataValidatorBuilder( - dataValidationErrors).resource("clientIdentifier"); - - baseDataValidator.reset().parameter("documentTypeId") - .value(command.getDocumentTypeId()).notNull() - .integerGreaterThanZero(); - baseDataValidator.reset().parameter("clientId") - .value(command.getClientId()).notNull() - .integerGreaterThanZero(); - baseDataValidator.reset().parameter("documentKey") - .value(command.getDocumentKey()).notBlank(); - - if (!dataValidationErrors.isEmpty()) { - throw new PlatformApiDataValidationException( - "validation.msg.validation.errors.exist", - "Validation errors exist.", dataValidationErrors); - } - } -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/LoanStatusMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/LoanStatusMapper.java deleted file mode 100644 index 488db6ab4..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/LoanStatusMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.mifosng.platform.client.service; - -public class LoanStatusMapper { - - private final Integer statusId; - - public LoanStatusMapper(Integer statusId) { - this.statusId = statusId; - } - - public boolean isPendingApproval() { - return Integer.valueOf(100).equals(statusId); - } - - public boolean isAwaitingDisbursal() { - return Integer.valueOf(200).equals(statusId); - } - - public boolean isOpen() { - return Integer.valueOf(300).equals(statusId); - } - - public boolean isWithdrawnByClient() { - return Integer.valueOf(400).equals(statusId); - } - - public boolean isRejected() { - return Integer.valueOf(500).equals(statusId); - } - - public boolean isClosed() { - return Integer.valueOf(600).equals(statusId) || isWithdrawnByClient() || isRejected(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/domain/Document.java b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/domain/Document.java index 8a409a6b5..802f8fb15 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/domain/Document.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/domain/Document.java @@ -6,7 +6,7 @@ import javax.persistence.Table; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.DocumentCommand; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentCommandValidator.java index 0d7fd6485..ca0c3b9fb 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.documentmanagement.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DocumentCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class DocumentCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentReadPlatformServiceImpl.java index ba861074d..d17f0d9a7 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentReadPlatformServiceImpl.java @@ -6,8 +6,8 @@ import java.util.Collection; import org.mifosng.platform.api.data.DocumentData; import org.mifosng.platform.exceptions.DocumentNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java index 385853061..034634406 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformService.java @@ -3,7 +3,7 @@ package org.mifosng.platform.documentmanagement.service; import java.io.InputStream; import org.mifosng.platform.api.commands.DocumentCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface DocumentWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformServiceJpaRepositoryImpl.java index b1016c7ed..88a18e3ea 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/documentmanagement/service/DocumentWritePlatformServiceJpaRepositoryImpl.java @@ -5,14 +5,14 @@ import java.io.IOException; import java.io.InputStream; import org.mifosng.platform.api.commands.DocumentCommand; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.documentmanagement.domain.Document; import org.mifosng.platform.documentmanagement.domain.DocumentRepository; import org.mifosng.platform.exceptions.DocumentManagementException; import org.mifosng.platform.exceptions.DocumentNotFoundException; import org.mifosng.platform.exceptions.InvalidEntityTypeForDocumentManagementException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.infrastructure.FileUtils; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; +import org.mifosplatform.infrastructure.core.service.FileUtils; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccounDataValidationtException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccounDataValidationtException.java index d089b3fc9..903b4aa57 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccounDataValidationtException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccounDataValidationtException.java @@ -2,6 +2,8 @@ package org.mifosng.platform.exceptions; import java.math.BigDecimal; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + public class DepositAccounDataValidationtException extends AbstractPlatformDomainRuleException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountNotFoundException.java index 5fa92c897..4dc6bb724 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + public class DepositAccountNotFoundException extends AbstractPlatformResourceNotFoundException { public DepositAccountNotFoundException(final Long id) { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountReopenException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountReopenException.java index b4c64238e..5df550f65 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountReopenException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountReopenException.java @@ -1,6 +1,7 @@ package org.mifosng.platform.exceptions; import org.joda.time.LocalDate; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; public class DepositAccountReopenException extends AbstractPlatformDomainRuleException{ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountTransactionsException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountTransactionsException.java index 586831b05..79753a0ed 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountTransactionsException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositAccountTransactionsException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + public class DepositAccountTransactionsException extends AbstractPlatformDomainRuleException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductNotFoundException.java index 223cb2fa0..9cfd3f4d0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + public class DepositProductNotFoundException extends AbstractPlatformResourceNotFoundException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductValueOutsideRangeException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductValueOutsideRangeException.java new file mode 100644 index 000000000..12a2cbcf8 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DepositProductValueOutsideRangeException.java @@ -0,0 +1,14 @@ +package org.mifosng.platform.exceptions; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + +/** + * Exception thrown when an attempt is made update the parent of a root office. + */ +public class DepositProductValueOutsideRangeException extends AbstractPlatformDomainRuleException { + + public DepositProductValueOutsideRangeException(final String actualValue, final String rangeMin, final String rangeMax, final String fieldCode) { + super("error.msg." + fieldCode + ".outside.of.allowed.range", actualValue + " is outside of allowed range of [" + rangeMin + ", " + + rangeMax + "].", actualValue, rangeMin, rangeMax); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentManagementException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentManagementException.java index ffeb686ce..122989d40 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentManagementException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentManagementException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + public class DocumentManagementException extends AbstractPlatformDomainRuleException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentNotFoundException.java index c337de82d..18bc9c3cc 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DocumentNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + public class DocumentNotFoundException extends AbstractPlatformResourceNotFoundException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DuplicateClientIdentifierException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DuplicateClientIdentifierException.java deleted file mode 100755 index a11444841..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DuplicateClientIdentifierException.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.mifosng.platform.exceptions; - -/** - * A {@link RuntimeException} thrown when a client identifier of the particular type is already present - */ -public class DuplicateClientIdentifierException extends AbstractPlatformDomainRuleException { - - private Long documentTypeId; - private String identifierKey; - private String identifierType; - - public DuplicateClientIdentifierException(final String identifierType) { - super("error.msg.clientIdentifier.type.duplicate", - "Client identifier of type " + identifierType - + " is already present for this client", identifierType); - this.identifierType = identifierType; - } - - public DuplicateClientIdentifierException(final Long documentTypeId, final String identifierType, final String identifierKey) { - super("error.msg.clientIdentifier.identityKey.duplicate", - "Client identifier of type " + identifierType - + " with value of " + identifierKey + " already exists.", identifierType, identifierKey); - this.documentTypeId = documentTypeId; - this.identifierType = identifierType; - this.identifierKey = identifierKey; - } - - public DuplicateClientIdentifierException( - final String clientName, - final String officeName, - final String identifierType, - final String identifierKey) { - super("error.msg.clientIdentifier.identityKey.duplicate", "Client " - + clientName + "under " + officeName + " Branch already has a " - + identifierType + " with unique key " + identifierKey, - clientName, officeName, identifierType, identifierKey); - this.identifierType = identifierType; - this.identifierKey = identifierKey; - } - - public Long getDocumentTypeId() { - return documentTypeId; - } - - public String getIdentifierKey() { - return identifierKey; - } - - public String getIdentifierType() { - return identifierType; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/FundNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/FundNotFoundException.java deleted file mode 100644 index dd8cfa5fd..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/FundNotFoundException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.mifosng.platform.exceptions; - -/** - * A {@link RuntimeException} thrown when fund resources are not found. - */ -public class FundNotFoundException extends AbstractPlatformResourceNotFoundException { - - public FundNotFoundException(final Long id) { - super("error.msg.fund.id.invalid", "Fund with identifier " + id + " does not exist", id); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java index afed44d6f..3a7c57742 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + /** * A {@link RuntimeException} thrown when group resources are not found. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GuarantorNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GuarantorNotFoundException.java index 2ab922b8c..fab49b8c4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GuarantorNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GuarantorNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + /** * A {@link RuntimeException} thrown when guarantor resources are not found. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageDataURLNotValidException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageDataURLNotValidException.java deleted file mode 100755 index 7e8bb7b9f..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageDataURLNotValidException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.mifosng.platform.exceptions; - -public class ImageDataURLNotValidException extends - AbstractPlatformDomainRuleException { - - public ImageDataURLNotValidException() { - super("error.msg.dataURL.save", - "Only GIF, PNG and JPEG Data URL's are allowed"); - } - -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageNotFoundException.java deleted file mode 100644 index 3377c0ce3..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageNotFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.mifosng.platform.exceptions; - -public class ImageNotFoundException extends AbstractPlatformDomainRuleException { - - public ImageNotFoundException(final String resource, final Long resourceId) { - super("error.msg.entity.image.invalid", "Image for resource " - + resource + " with Identifier " + resourceId - + " does not exist", resource, resourceId); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageUploadException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageUploadException.java deleted file mode 100644 index 51dc4212b..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ImageUploadException.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.mifosng.platform.exceptions; - -public class ImageUploadException extends AbstractPlatformDomainRuleException { - - public ImageUploadException() { - super("error.msg.image.type.upload", - "Only image files of type GIF,PNG and JPG are allowed "); - } - -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java index 6c7cda035..bd71a5bc6 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + public class InvalidDepositStateTransitionException extends AbstractPlatformDomainRuleException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidEntityTypeForDocumentManagementException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidEntityTypeForDocumentManagementException.java index 155bc5e41..13dfa699a 100755 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidEntityTypeForDocumentManagementException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidEntityTypeForDocumentManagementException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + /** * A {@link RuntimeException} thrown when document management functionality is * invoked for invalid Entity Types diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidGuarantorException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidGuarantorException.java index 8ef48f959..8c14be0b2 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidGuarantorException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidGuarantorException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + /** * {@link AbstractPlatformDomainRuleException} thrown when a Client is set as a * guarantor for his/her own loans diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanStateTransitionException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanStateTransitionException.java index 465118b1f..541c75822 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanStateTransitionException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanStateTransitionException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + /** * {@link AbstractPlatformDomainRuleException} thrown an action to transition a loan from one state to another violates a domain rule. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanTransactionTypeException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanTransactionTypeException.java index 792f4951d..f7a81fb85 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanTransactionTypeException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidLoanTransactionTypeException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + /** * {@link AbstractPlatformDomainRuleException} thrown an action to transition a loan from one state to another violates a domain rule. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java index f650b34db..2058b8524 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + /** * A {@link RuntimeException} thrown when loan resources are not found. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotInSubmittedAndPendingApprovalStateCannotBeDeleted.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotInSubmittedAndPendingApprovalStateCannotBeDeleted.java index e4ee0cfc4..c65b15e42 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotInSubmittedAndPendingApprovalStateCannotBeDeleted.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotInSubmittedAndPendingApprovalStateCannotBeDeleted.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + /** * {@link AbstractPlatformDomainRuleException} thrown when trying to delete a loan in an invalid state. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanOfficerAssignmentException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanOfficerAssignmentException.java index 71b9aa145..c9c225ca9 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanOfficerAssignmentException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanOfficerAssignmentException.java @@ -1,18 +1,17 @@ package org.mifosng.platform.exceptions; - import org.joda.time.LocalDate; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; -public class LoanOfficerAssignmentException extends - AbstractPlatformDomainRuleException { +public class LoanOfficerAssignmentException extends AbstractPlatformDomainRuleException { public LoanOfficerAssignmentException(final Long loanId, final Long fromLoanOfficerId) { - super("error.msg.loan.not.assigned.to.loan.officer", "Loan with identifier " + loanId + - " is not assigned to Loan Officer with identifier " + fromLoanOfficerId + ".", loanId); + super("error.msg.loan.not.assigned.to.loan.officer", "Loan with identifier " + loanId + + " is not assigned to Loan Officer with identifier " + fromLoanOfficerId + ".", loanId); } - public LoanOfficerAssignmentException(final Long loanId, final LocalDate date){ - super("error.msg.loan.assignment.date.is.before.last.assignment.date", "Loan with identifier " + loanId + - " was already assigned before date " + date.toString()); + public LoanOfficerAssignmentException(final Long loanId, final LocalDate date) { + super("error.msg.loan.assignment.date.is.before.last.assignment.date", "Loan with identifier " + loanId + + " was already assigned before date " + date.toString()); } } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java index 53ae065b4..e6401a85c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + /** * A {@link RuntimeException} thrown when loan resources are not found. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionProcessingStrategyNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionProcessingStrategyNotFoundException.java index 7aedebeaf..2aba3bf5f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionProcessingStrategyNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionProcessingStrategyNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + /** * A {@link RuntimeException} thrown when loan transactions processing strategy resources are not found. */ diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoAuthorizationException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoAuthorizationException.java deleted file mode 100644 index c3585154a..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoAuthorizationException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.mifosng.platform.exceptions; - - -/** - * A {@link RuntimeException} that is thrown in the case where a user does not have sufficient authorization to execute operation on platform. - */ -public class NoAuthorizationException extends RuntimeException { - - public NoAuthorizationException(final String message) { - super(message); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java deleted file mode 100644 index 20fcd87d4..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.mifosng.platform.exceptions; - -/** - * A {@link RuntimeException} thrown when note resources are not found. - */ -public class NoteNotFoundException extends AbstractPlatformResourceNotFoundException { - - public NoteNotFoundException(Long id) { - super("error.msg.note.id.invalid", "Note with identifier " + id + " does not exist", id); - } - - public NoteNotFoundException(Long id, Long clientId, final String resource) { - super("error.msg." + resource + ".note.id.invalid", "Note with identifier " + id + " does not exist for " + resource + " with identifier " + clientId, id, clientId); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformApiDataValidationException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformApiDataValidationException.java deleted file mode 100644 index 9364ecd7d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformApiDataValidationException.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.mifosng.platform.exceptions; - -import java.util.List; - -import org.mifosng.platform.api.data.ApiParameterError; - -public class PlatformApiDataValidationException extends RuntimeException { - - private final String globalisationMessageCode; - private final String defaultUserMessage; - private final List errors; - - public PlatformApiDataValidationException(final String globalisationMessageCode, final String defaultUserMessage, List errors) { - this.globalisationMessageCode = globalisationMessageCode; - this.defaultUserMessage = defaultUserMessage; - this.errors = errors; - } - - public String getGlobalisationMessageCode() { - return globalisationMessageCode; - } - - public String getDefaultUserMessage() { - return defaultUserMessage; - } - - public List getErrors() { - return errors; - } -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformDataIntegrityException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformDataIntegrityException.java deleted file mode 100644 index 17f6fd954..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformDataIntegrityException.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.mifosng.platform.exceptions; - -/** - * A {@link RuntimeException} thrown when data integrity problems happen due to state modifying actions. - */ -public class PlatformDataIntegrityException extends RuntimeException { - - private final String globalisationMessageCode; - private final String defaultUserMessage; - private final String parameterName; - private final Object[] defaultUserMessageArgs; - - public PlatformDataIntegrityException(final String globalisationMessageCode, final String defaultUserMessage, final Object... defaultUserMessageArgs) { - this.globalisationMessageCode = globalisationMessageCode; - this.defaultUserMessage = defaultUserMessage; - this.parameterName = ""; - this.defaultUserMessageArgs = defaultUserMessageArgs; - } - - public PlatformDataIntegrityException(final String globalisationMessageCode, final String defaultUserMessage, final String parameterName, final Object... defaultUserMessageArgs) { - this.globalisationMessageCode = globalisationMessageCode; - this.defaultUserMessage = defaultUserMessage; - this.parameterName = parameterName; - this.defaultUserMessageArgs = defaultUserMessageArgs; - } - - public String getGlobalisationMessageCode() { - return globalisationMessageCode; - } - - public String getDefaultUserMessage() { - return defaultUserMessage; - } - - public Object[] getDefaultUserMessageArgs() { - return defaultUserMessageArgs; - } - - public String getParameterName() { - return parameterName; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformInternalServerException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformInternalServerException.java deleted file mode 100644 index 2421319cb..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformInternalServerException.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.mifosng.platform.exceptions; - -/** - * A {@link RuntimeException} thrown when unexpected server side errors happen. - */ -public class PlatformInternalServerException extends RuntimeException { - - private final String globalisationMessageCode; - private final String defaultUserMessage; - private final Object[] defaultUserMessageArgs; - - public PlatformInternalServerException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) { - this.globalisationMessageCode = globalisationMessageCode; - this.defaultUserMessage = defaultUserMessage; - this.defaultUserMessageArgs = defaultUserMessageArgs; - } - - public String getGlobalisationMessageCode() { - return globalisationMessageCode; - } - - public String getDefaultUserMessage() { - return defaultUserMessage; - } - - public Object[] getDefaultUserMessageArgs() { - return defaultUserMessageArgs; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ProductNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ProductNotFoundException.java deleted file mode 100644 index c985ca485..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ProductNotFoundException.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.mifosng.platform.exceptions; - -public class ProductNotFoundException extends AbstractPlatformResourceNotFoundException{ - - public ProductNotFoundException(Long id) { - super("error.msg.product.id.invalid", "Product with identifier " + id + " does not exist", id); - } - -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java deleted file mode 100644 index bb63538c5..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.mifosng.platform.exceptions; - -/** - * A {@link RuntimeException} thrown when report resources are not found. - */ -public class ReportNotFoundException extends AbstractPlatformResourceNotFoundException { - - public ReportNotFoundException(final String reportSql) { - super("error.msg.report.name.not.found", "Reporting Meta Data Entry Not Found", "Input Sql: " + reportSql); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingAccountNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingAccountNotFoundException.java index 5e77dc8d0..d98c74e09 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingAccountNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingAccountNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + public class SavingAccountNotFoundException extends AbstractPlatformResourceNotFoundException { public SavingAccountNotFoundException(final Long id) { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingProductNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingProductNotFoundException.java index 3e3c4d8da..b384f481f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingProductNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingProductNotFoundException.java @@ -1,5 +1,7 @@ package org.mifosng.platform.exceptions; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + public class SavingProductNotFoundException extends AbstractPlatformResourceNotFoundException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingsProductNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingsProductNotFoundException.java new file mode 100644 index 000000000..dc857d086 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingsProductNotFoundException.java @@ -0,0 +1,11 @@ +package org.mifosng.platform.exceptions; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +public class SavingsProductNotFoundException extends AbstractPlatformResourceNotFoundException { + + public SavingsProductNotFoundException(Long id) { + super("error.msg.product.id.invalid", "Product with identifier " + id + " does not exist", id); + } + +} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UnrecognizedQueryParamException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UnrecognizedQueryParamException.java deleted file mode 100644 index 7a42fde71..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UnrecognizedQueryParamException.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.mifosng.platform.exceptions; - -public class UnrecognizedQueryParamException extends RuntimeException { - - private final String queryParamKey; - private final String queryParamValue; - - public UnrecognizedQueryParamException(String queryParamKey, String queryParamValue) { - this.queryParamKey = queryParamKey; - this.queryParamValue = queryParamValue; - } - - public String getQueryParamKey() { - return queryParamKey; - } - - public String getQueryParamValue() { - return queryParamValue; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ValueOutsideRangeException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ValueOutsideRangeException.java deleted file mode 100644 index e255e117a..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ValueOutsideRangeException.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.mifosng.platform.exceptions; - - -/** - * Exception thrown when an attempt is made update the parent of a root office. - */ -public class ValueOutsideRangeException extends AbstractPlatformDomainRuleException { - - public ValueOutsideRangeException(final String actualValue, final String rangeMin, final String rangeMax, final String fieldCode) { - super("error.msg." + fieldCode + ".outside.of.allowed.range", actualValue + " is outside of allowed range of [" - + rangeMin + ", " + rangeMax + "].", actualValue, rangeMin, rangeMax); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/filters/ResponseCorsFilter.java b/mifosng-provider/src/main/java/org/mifosng/platform/filters/ResponseCorsFilter.java deleted file mode 100644 index 85874805c..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/filters/ResponseCorsFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.mifosng.platform.filters; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; - -import com.sun.jersey.spi.container.ContainerRequest; -import com.sun.jersey.spi.container.ContainerResponse; -import com.sun.jersey.spi.container.ContainerResponseFilter; - -/** - * Filter that returns a response with headers that allows for Cross-Origin Requests (CORs) to be performed against the platform API. - */ -public class ResponseCorsFilter implements ContainerResponseFilter { - - @Override - public ContainerResponse filter(ContainerRequest request, ContainerResponse response) { - - ResponseBuilder resp = Response.fromResponse(response.getResponse()); - - resp.header("Access-Control-Allow-Origin", "*") -// .header("Access-Control-Expose-Headers", "X-Mifos-Platform-TenantId") - .header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); - - String reqHead = request.getHeaderValue("Access-Control-Request-Headers"); - - if (null != reqHead && !reqHead.equals(null)) { - resp.header("Access-Control-Allow-Headers", reqHead); - } - - response.setResponse(resp.build()); - - return response; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java index a6515f1f8..f0dc828e0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java @@ -13,10 +13,10 @@ import javax.persistence.Table; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.domain.Client; @Entity @Table(name = "m_group") diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java index b92c361c2..a6391aa34 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.group.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class GroupCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java index 491d2c062..9c13d660f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java @@ -3,9 +3,9 @@ package org.mifosng.platform.group.service; import java.util.Collection; import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; -import org.mifosng.platform.api.data.ClientLookup; import org.mifosng.platform.api.data.GroupAccountSummaryData; import org.mifosng.platform.api.data.GroupData; +import org.mifosplatform.portfolio.client.data.ClientLookup; public interface GroupReadPlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java index 461731279..406086ecf 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java @@ -7,18 +7,18 @@ import java.util.Collection; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.ClientLookup; import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; import org.mifosng.platform.api.data.GroupAccountSummaryData; import org.mifosng.platform.api.data.GroupData; -import org.mifosng.platform.client.service.ClientReadPlatformService; -import org.mifosng.platform.client.service.LoanStatusMapper; import org.mifosng.platform.exceptions.GroupNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.data.ClientLookup; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.mifosplatform.portfolio.client.service.LoanStatusMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java index 032d1335b..3a9f79029 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java @@ -1,7 +1,7 @@ package org.mifosng.platform.group.service; import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface GroupWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java index bb02b0120..168a23a59 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java @@ -4,19 +4,19 @@ import java.util.HashSet; import java.util.Set; import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.exceptions.ClientNotFoundException; import org.mifosng.platform.exceptions.GroupNotFoundException; -import org.mifosng.platform.exceptions.InvalidOfficeException; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosng.platform.group.domain.Group; import org.mifosng.platform.group.domain.GroupRepository; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.office.domain.OfficeRepository; +import org.mifosplatform.infrastructure.office.exception.InvalidOfficeException; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorCommandValidator.java index 343888a3b..de940b204 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.guarantor; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.GuarantorCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class GuarantorCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorReadPlatformServiceImpl.java index 6e5288e92..9881475f3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorReadPlatformServiceImpl.java @@ -5,13 +5,13 @@ import java.util.List; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; import org.mifosng.platform.api.data.GuarantorData; -import org.mifosng.platform.client.domain.Client; import org.mifosng.platform.exceptions.GuarantorNotFoundException; import org.mifosng.platform.exceptions.LoanNotFoundException; import org.mifosng.platform.loan.domain.Loan; import org.mifosng.platform.loan.domain.LoanRepository; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService; +import org.mifosplatform.portfolio.client.domain.Client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorWritePlatformServiceImpl.java index 9fb35ba0f..9fda5f356 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorWritePlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/guarantor/GuarantorWritePlatformServiceImpl.java @@ -9,16 +9,16 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.GuarantorCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.exceptions.ClientNotFoundException; import org.mifosng.platform.exceptions.InvalidGuarantorException; import org.mifosng.platform.exceptions.LoanNotFoundException; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; import org.mifosng.platform.loan.domain.Loan; import org.mifosng.platform.loan.domain.LoanRepository; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/Base64EncodedImage.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/Base64EncodedImage.java deleted file mode 100644 index f42ffa636..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/Base64EncodedImage.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.mifosng.platform.infrastructure; - -public class Base64EncodedImage { - - private final String base64EncodedString; - private final String fileExtension; - - public Base64EncodedImage(String base64EncodedString, String fileExtension) { - this.base64EncodedString = base64EncodedString; - this.fileExtension = fileExtension; - } - - public String getBase64EncodedString() { - return base64EncodedString; - } - - public String getFileExtension() { - return fileExtension; - } - -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/FileUtils.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/FileUtils.java deleted file mode 100644 index c87431b6b..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/FileUtils.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.mifosng.platform.infrastructure; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.DocumentManagementException; -import org.mifosng.platform.exceptions.ImageDataURLNotValidException; -import org.mifosng.platform.exceptions.ImageUploadException; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.lowagie.text.pdf.codec.Base64; - -public class FileUtils { - - private final static Logger logger = LoggerFactory - .getLogger(FileUtils.class); - - public static final String MIFOSX_BASE_DIR = System - .getProperty("user.home") + File.separator + ".mifosx"; - - public static Random random = new Random(); - - /** - * Generate a random String - * - * @return - */ - public static String generateRandomString() { - String characters = "abcdefghijklmnopqrstuvwxyz123456789"; - int length = generateRandomNumber(); - char[] text = new char[length]; - for (int i = 0; i < length; i++) { - text[i] = characters.charAt(random.nextInt(characters.length())); - } - return new String(text); - } - - /** - * Generate a random number between 5 to 16 - * - * @return - */ - public static int generateRandomNumber() { - Random randomGenerator = new Random(); - return randomGenerator.nextInt(11) + 5; - } - - /** - * Generate the directory path for storing the new document - * - * @param entityType - * @param entityId - * @return - */ - public static String generateFileParentDirectory(String entityType, - Long entityId) { - return FileUtils.MIFOSX_BASE_DIR - + File.separator - + ThreadLocalContextUtil.getTenant().getName() - .replaceAll(" ", "").trim() + File.separator - + "documents" + File.separator + entityType + File.separator - + entityId + File.separator + FileUtils.generateRandomString(); - } - - /** - * Generate directory path for storing new Image - */ - public static String generateClientImageParentDirectory(final Long resourceId) { - return FileUtils.MIFOSX_BASE_DIR - + File.separator - + ThreadLocalContextUtil.getTenant().getName() - .replaceAll(" ", "").trim() + File.separator + "images" - + File.separator + "clients" + File.separator - + resourceId; - } - - /** - * @param uploadedInputStream - * @param uploadedFileLocation - * @return - * @throws IOException - */ - public static String saveToFileSystem(InputStream uploadedInputStream, - String uploadedFileLocation, String fileName) throws IOException { - String fileLocation = uploadedFileLocation + File.separator + fileName; - OutputStream out = new FileOutputStream(new File(fileLocation)); - int read = 0; - byte[] bytes = new byte[1024]; - - while ((read = uploadedInputStream.read(bytes)) != -1) { - out.write(bytes, 0, read); - } - out.flush(); - out.close(); - return fileLocation; - } - - - /** - * @param base64EncodedImage - * @param uploadedFileLocation - * @param fileName - * @return - * @throws IOException - */ - public static String saveToFileSystem(Base64EncodedImage base64EncodedImage, - String uploadedFileLocation, String fileName) throws IOException { - String fileLocation = uploadedFileLocation + File.separator + fileName + base64EncodedImage.getFileExtension(); - OutputStream out = new FileOutputStream(new File(fileLocation)); - byte[] imgBytes = Base64.decode(base64EncodedImage.getBase64EncodedString()); - out.write(imgBytes); - out.flush(); - out.close(); - return fileLocation; - } - - /** - * @param fileSize - * @param name - */ - public static void validateFileSizeWithinPermissibleRange(Long fileSize, - String name, int maxFileSize) { - /** - * Using Content-Length gives me size of the entire request, which is - * good enough for now for a fast fail as the length of the rest of the - * content i.e name and description while compared to the uploaded file - * size is negligible - **/ - if (fileSize != null && ((fileSize / (1024 * 1024)) > maxFileSize)) { - throw new DocumentManagementException(name, fileSize, maxFileSize); - } - } - - /** - * Validates that passed in Mime type maps to known image mime types - * - * @param mimeType - */ - public static void validateImageMimeType(String mimeType) { - if (!(mimeType.equalsIgnoreCase("image/gif") - || mimeType.equalsIgnoreCase("image/jpeg") || mimeType - .equalsIgnoreCase("image/png"))) { - throw new ImageUploadException(); - } - } - - /** - * Extracts Image from a Data URL - * - * @param mimeType - */ - public static Base64EncodedImage extractImageFromDataURL(String dataURL) { - String fileExtension = ""; - String base64EncodedString = null; - String gifDataURLSnippet = "data:image/gif;base64,"; - String pngDataURLSnippet = "data:image/png;base64,"; - String jpegDataURLSnippet = "data:image/jpeg;base64,"; - - if (dataURL.contains(gifDataURLSnippet)) { - base64EncodedString = dataURL.replaceAll(gifDataURLSnippet, ""); - fileExtension = ".gif"; - } else if (dataURL.contains(pngDataURLSnippet)) { - base64EncodedString = dataURL.replaceAll(pngDataURLSnippet, ""); - fileExtension = ".png"; - } else if (dataURL.contains(jpegDataURLSnippet)) { - base64EncodedString = dataURL.replaceAll(jpegDataURLSnippet, ""); - fileExtension = ".jpeg"; - } else { - throw new ImageDataURLNotValidException(); - } - - return new Base64EncodedImage(base64EncodedString, fileExtension); - } - - public static void validateClientImageNotEmpty(String imageFileName) { - List dataValidationErrors = new ArrayList(); - if (imageFileName == null) { - StringBuilder validationErrorCode = new StringBuilder( - "validation.msg.clientImage.cannot.be.blank"); - StringBuilder defaultEnglishMessage = new StringBuilder( - "The parameter image cannot be blank."); - ApiParameterError error = ApiParameterError.parameterError( - validationErrorCode.toString(), - defaultEnglishMessage.toString(), "image"); - dataValidationErrors.add(error); - throw new PlatformApiDataValidationException( - "validation.msg.validation.errors.exist", - "Validation errors exist.", dataValidationErrors); - } - } - - public static void deleteClientImage(final Long resourceId, final String location) { - File fileToBeDeleted = new File(location); - boolean fileDeleted = fileToBeDeleted.delete(); - if (!fileDeleted) { - // no need to throw an Error, simply log a warning - logger.warn("Unable to delete image associated with clients with Id " + resourceId); - } - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/InvalidTenantIdentiferException.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/InvalidTenantIdentiferException.java deleted file mode 100644 index c95487348..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/InvalidTenantIdentiferException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.mifosng.platform.infrastructure; - -/** - * {@link RuntimeException} thrown when an invalid tenant identifier is used in request to platform. - * - * @see CustomRequestHeaderAuthenticationFilter - */ -public class InvalidTenantIdentiferException extends RuntimeException { - - public InvalidTenantIdentiferException(final String message) { - super(message); - } - -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/TomcatJdbcDataSourcePerTenantService.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/TomcatJdbcDataSourcePerTenantService.java deleted file mode 100644 index cd56e71f1..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/TomcatJdbcDataSourcePerTenantService.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.mifosng.platform.infrastructure; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.sql.DataSource; - -import org.apache.tomcat.jdbc.pool.PoolConfiguration; -import org.apache.tomcat.jdbc.pool.PoolProperties; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -/** - * Implementation that returns a new or existing tomcat 7 jdbc connection pool - * datasource based on the tenant details stored in a {@link ThreadLocal} - * variable for this request. - * - * {@link ThreadLocalContextUtil} is used to retrieve the {@link MifosPlatformTenant} for the request. - */ -@Service -public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenantService { - - private final Map tenantToDataSourceMap = new ConcurrentHashMap(1); - private final DataSource tenantDataSource; - - @Autowired - public TomcatJdbcDataSourcePerTenantService(final @Qualifier("tenantDataSourceJndi") DataSource tenantDataSource) { - this.tenantDataSource = tenantDataSource; - } - - @Override - public DataSource retrieveTenantAwareDataSource() { - - // default to tenant database datasource - DataSource tenantDataSource = this.tenantDataSource; - - MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); - if (tenant != null) { - // if tenant information available switch to appropriate datasource for that tenant. - if (this.tenantToDataSourceMap.containsKey(tenant.getId())) { - tenantDataSource = this.tenantToDataSourceMap.get(tenant.getId()); - } else { - tenantDataSource = createNewDataSourceFor(tenant); - this.tenantToDataSourceMap.put(tenant.getId(), tenantDataSource); - } - } - - return tenantDataSource; - } - - private DataSource createNewDataSourceFor(final MifosPlatformTenant tenant) { - // see http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency - - StringBuilder jdbcUrlBuilder = new StringBuilder("jdbc:mysql://") - .append(tenant.getSchemaServer()) - .append(':') - .append(tenant.getSchemaServerPort()) - .append('/') - .append(tenant.getSchemaName()); - - PoolConfiguration poolConfiguration = new PoolProperties(); - poolConfiguration.setDriverClassName("com.mysql.jdbc.Driver"); - poolConfiguration.setName(tenant.getSchemaName() + "_pool"); - poolConfiguration.setUrl(jdbcUrlBuilder.toString()); - poolConfiguration.setUsername(tenant.getSchemaUsername()); - poolConfiguration.setPassword(tenant.getSchemaPassword()); - - poolConfiguration.setInitialSize(5); - poolConfiguration.setMaxActive(5); - poolConfiguration.setMinIdle(1); - poolConfiguration.setMaxIdle(4); - - poolConfiguration.setSuspectTimeout(60); - poolConfiguration.setTimeBetweenEvictionRunsMillis(30000); - poolConfiguration.setMinEvictableIdleTimeMillis(60000); - - poolConfiguration.setTestOnBorrow(true); - poolConfiguration.setValidationQuery("SELECT 1"); - poolConfiguration.setValidationInterval(30000); - - poolConfiguration.setRemoveAbandoned(true); - poolConfiguration.setRemoveAbandonedTimeout(60); - poolConfiguration.setLogAbandoned(true); - poolConfiguration.setAbandonWhenPercentageFull(50); - - poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" - + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport"); - - return new org.apache.tomcat.jdbc.pool.DataSource(poolConfiguration); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/UsernameAlreadyExistsException.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/UsernameAlreadyExistsException.java deleted file mode 100644 index ba48873e8..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/UsernameAlreadyExistsException.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.mifosng.platform.infrastructure; - -public class UsernameAlreadyExistsException extends RuntimeException { - public UsernameAlreadyExistsException(final Throwable e) { - super(e); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/AccessDeniedExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/AccessDeniedExceptionMapper.java deleted file mode 100644 index 27e1a3c3e..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/AccessDeniedExceptionMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.springframework.context.annotation.Scope; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link AccessDeniedException} thrown by platform into a HTTP API friendly format. - * - * The {@link AccessDeniedException} is thrown by spring security on platform when an attempt is made to use functionality - * for which the user does have sufficient privileges. - */ -@Provider -@Component -@Scope("singleton") -public class AccessDeniedExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(@SuppressWarnings("unused") AccessDeniedException exception) { - // Status code 403 really reads as: "Authenticated - but not authorized": - return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized()).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidJsonExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidJsonExceptionMapper.java deleted file mode 100644 index 00862ea8d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidJsonExceptionMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiParameterError; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link InvalidJsonException} thrown by platform into a HTTP API friendly format. - */ -@Provider -@Component -@Scope("singleton") -public class InvalidJsonExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(@SuppressWarnings("unused") final InvalidJsonException exception) { - - String globalisationMessageCode = "error.msg.invalid.request.body"; - String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing."; - - ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); - - return Response.status(Status.BAD_REQUEST).entity(error).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidTenantIdentifierExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidTenantIdentifierExceptionMapper.java deleted file mode 100644 index 59da7ecb4..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidTenantIdentifierExceptionMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.infrastructure.InvalidTenantIdentiferException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link InvalidTenantIdentiferException} thrown by platform during authentication into a HTTP API friendly format. - * - * The {@link InvalidTenantIdentiferException} is thrown by spring security on platform when a request contains an invalid tenant identifier. - */ -@Provider -@Component -@Scope("singleton") -public class InvalidTenantIdentifierExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(@SuppressWarnings("unused") final InvalidTenantIdentiferException e) { - return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.invalidTenantIdentifier()).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/JsonSyntaxExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/JsonSyntaxExceptionMapper.java deleted file mode 100644 index 290ed0acf..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/JsonSyntaxExceptionMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiParameterError; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import com.google.gson.JsonSyntaxException; - -/** - * An {@link ExceptionMapper} to map {@link JsonSyntaxException} thrown by platform into a HTTP API friendly format. - */ -@Provider -@Component -@Scope("singleton") -public class JsonSyntaxExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(final JsonSyntaxException exception) { - - String globalisationMessageCode = "error.msg.invalid.request.body"; - String defaultUserMessage = "The JSON syntax provided in the body of the request is invalid: " + exception.getMessage(); - - ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); - - return Response.status(Status.BAD_REQUEST).entity(error).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/MalformedJsonExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/MalformedJsonExceptionMapper.java deleted file mode 100644 index 7c4d74ae4..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/MalformedJsonExceptionMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiParameterError; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import com.google.gson.stream.MalformedJsonException; - -/** - * An {@link ExceptionMapper} to map {@link MalformedJsonException} thrown by platform into a HTTP API friendly format. - */ -@Provider -@Component -@Scope("singleton") -public class MalformedJsonExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(@SuppressWarnings("unused") final MalformedJsonException exception) { - - String globalisationMessageCode = "error.msg.invalid.request.body"; - String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing."; - - ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); - - return Response.status(Status.BAD_REQUEST).entity(error).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/NoAuthorizationExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/NoAuthorizationExceptionMapper.java deleted file mode 100644 index 51fb0de8d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/NoAuthorizationExceptionMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.NoAuthorizationException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link NoAuthorizationException} thrown by platform into a HTTP API friendly format. - * - * The {@link NoAuthorizationException} is thrown on platform when an attempt is made to use functionality - * for which the user does have sufficient privileges. - */ -@Provider -@Component -@Scope("singleton") -public class NoAuthorizationExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(@SuppressWarnings("unused") NoAuthorizationException exception) { - // Status code 403 really reads as: "Authenticated - but not authorized": - return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized()).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformApiDataValidationExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformApiDataValidationExceptionMapper.java deleted file mode 100644 index 7a1d6fab8..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformApiDataValidationExceptionMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link PlatformApiDataValidationException} thrown by platform into a HTTP API friendly format. - * - * The {@link PlatformApiDataValidationException} is typically thrown in data validation of the parameters passed in with an api request. - */ -@Provider -@Component -@Scope("singleton") -public class PlatformApiDataValidationExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(PlatformApiDataValidationException exception) { - - ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.badClientRequest(exception.getGlobalisationMessageCode(), - exception.getDefaultUserMessage(), exception.getErrors()); - - return Response.status(Status.BAD_REQUEST).entity(dataIntegrityError).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformDataIntegrityExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformDataIntegrityExceptionMapper.java deleted file mode 100644 index 6371d77e4..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformDataIntegrityExceptionMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link PlatformDataIntegrityException} thrown by platform into a HTTP API friendly format. - * - * The {@link PlatformDataIntegrityException} is thrown when modifying api call result in data integrity checks to be fired. - */ -@Provider -@Component -@Scope("singleton") -public class PlatformDataIntegrityExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(PlatformDataIntegrityException exception) { - - ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.dataIntegrityError(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), - exception.getParameterName(), exception.getDefaultUserMessageArgs()); - - return Response.status(Status.FORBIDDEN).entity(dataIntegrityError).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformDomainRuleExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformDomainRuleExceptionMapper.java deleted file mode 100644 index 24dd3c45d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformDomainRuleExceptionMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link AbstractPlatformDomainRuleException} thrown by platform into a HTTP API friendly format. - * - * The {@link AbstractPlatformDomainRuleException} is thrown when an api call results is some internal business/domain logic been violated. - */ -@Provider -@Component -@Scope("singleton") -public class PlatformDomainRuleExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(AbstractPlatformDomainRuleException exception) { - - ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); - // request understood but not carried out due to it violating some domain/business logic - return Response.status(Status.FORBIDDEN).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformInternalServerExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformInternalServerExceptionMapper.java deleted file mode 100644 index ddfe841e9..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformInternalServerExceptionMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.PlatformInternalServerException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link PlatformInternalServerException} thrown by platform into a HTTP API friendly format. - * - * The {@link PlatformInternalServerException} is thrown when an api call results in unexpected server side exceptions. - */ -@Provider -@Component -@Scope("singleton") -public class PlatformInternalServerExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(PlatformInternalServerException exception) { - - ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); - return Response.status(Status.INTERNAL_SERVER_ERROR).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformResourceNotFoundExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformResourceNotFoundExceptionMapper.java deleted file mode 100644 index d2633350e..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/PlatformResourceNotFoundExceptionMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link AbstractPlatformResourceNotFoundException} thrown by platform into a HTTP API friendly format. - * - * The {@link AbstractPlatformResourceNotFoundException} is thrown when an api call for a resource that is expected to exist does not. - */ -@Provider -@Component -@Scope("singleton") -public class PlatformResourceNotFoundExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(AbstractPlatformResourceNotFoundException exception) { - - ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); - return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnAuthenticatedUserExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnAuthenticatedUserExceptionMapper.java deleted file mode 100644 index 821a9220b..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnAuthenticatedUserExceptionMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.UnAuthenticatedUserException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link UnAuthenticatedUserException} thrown by platform into a HTTP API friendly format. - */ -@Provider -@Component -@Scope("singleton") -public class UnAuthenticatedUserExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(@SuppressWarnings("unused") UnAuthenticatedUserException exception) { - // Status code 401 really reads as: "Unauthenticated": - return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnrecognizedQueryParamExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnrecognizedQueryParamExceptionMapper.java deleted file mode 100644 index 4e0bc5e96..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnrecognizedQueryParamExceptionMapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.UnrecognizedQueryParamException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link UnrecognizedQueryParamException} thrown by platform into a HTTP API friendly format. - * - * The {@link UnrecognizedQueryParamException} is typically thrown when a parameter is passed during and post or put that is not expected. - */ -@Provider -@Component -@Scope("singleton") -public class UnrecognizedQueryParamExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(UnrecognizedQueryParamException exception) { - - String parameterName = exception.getQueryParamKey(); - String parameterValue = exception.getQueryParamValue(); - - StringBuilder validationErrorCode = new StringBuilder("error.msg.query.parameter.value.unsupported"); - StringBuilder defaultEnglishMessage = new StringBuilder("The query parameter ").append(parameterName).append(" has an unsupported value of: ").append(parameterValue); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameterName, parameterName, parameterValue); - - List errors = new ArrayList(); - errors.add(error); - - ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest( - "validation.msg.validation.errors.exist", - "Validation errors exist.", errors); - - return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedCommandException.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedCommandException.java deleted file mode 100644 index cee06fe0a..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedCommandException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - - -/** - * A {@link RuntimeException} that is thrown in the case where an invalid or unknown - * command is attempted to be processed by platform. - */ -public class UnsupportedCommandException extends RuntimeException { - - private final String unsupportedCommandName; - - public UnsupportedCommandException(final String unsupportedCommandName) { - this.unsupportedCommandName = unsupportedCommandName; - } - - public String getUnsupportedCommandName() { - return unsupportedCommandName; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedCommandExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedCommandExceptionMapper.java deleted file mode 100644 index 0554d1ca2..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedCommandExceptionMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.api.data.ApiParameterError; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link UnsupportedCommandException} thrown by platform into a HTTP API friendly format. - */ -@Provider -@Component -@Scope("singleton") -public class UnsupportedCommandExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(final UnsupportedCommandException exception) { - - List errors = new ArrayList(); - - StringBuilder validationErrorCode = new StringBuilder("error.msg.command.unsupported"); - StringBuilder defaultEnglishMessage = new StringBuilder("The command ").append(exception.getUnsupportedCommandName()).append(" is not supported."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName()); - - errors.add(error); - - ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest( - "validation.msg.validation.errors.exist", - "Validation errors exist.", errors); - - return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedParameterException.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedParameterException.java deleted file mode 100644 index 742c85696..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedParameterException.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import java.util.List; - -/** - * A {@link RuntimeException} that is thrown in the case where invalid - * parameters are sent in the body of the request to the platform api. - */ -public class UnsupportedParameterException extends RuntimeException { - - private final List unsupportedParameters; - - public UnsupportedParameterException(List unsupportedParameters) { - this.unsupportedParameters = unsupportedParameters; - } - - public List getUnsupportedParameters() { - return unsupportedParameters; - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedParameterExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedParameterExceptionMapper.java deleted file mode 100644 index 8aa675e10..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/UnsupportedParameterExceptionMapper.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.mifosng.platform.infrastructure.errorhandling; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; -import org.mifosng.platform.api.data.ApiParameterError; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -/** - * An {@link ExceptionMapper} to map {@link UnsupportedParameterException} thrown by platform into a HTTP API friendly format. - */ -@Provider -@Component -@Scope("singleton") -public class UnsupportedParameterExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(final UnsupportedParameterException exception) { - - List errors = new ArrayList(); - - for (String parameterName : exception.getUnsupportedParameters()) { - StringBuilder validationErrorCode = new StringBuilder("error.msg.parameter.unsupported"); - StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameterName).append(" is not supported."); - ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameterName, parameterName); - - errors.add(error); - } - - ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest( - "validation.msg.validation.errors.exist", - "Validation errors exist.", errors); - - return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build(); - } -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/Loan.java index 8bff2c8b1..0c0ba043b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/Loan.java @@ -30,17 +30,17 @@ import org.mifosng.platform.api.commands.LoanApplicationCommand; import org.mifosng.platform.api.commands.LoanChargeCommand; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanSchedulePeriodData; -import org.mifosng.platform.client.domain.Client; import org.mifosng.platform.exceptions.InvalidLoanStateTransitionException; import org.mifosng.platform.exceptions.InvalidLoanTransactionTypeException; -import org.mifosng.platform.exceptions.LoanChargeCannotBeAddedException; import org.mifosng.platform.exceptions.LoanOfficerAssignmentException; import org.mifosng.platform.group.domain.Group; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.staff.domain.Staff; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.charge.exception.LoanChargeCannotBeAddedException; +import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.fund.domain.Fund; import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRelatedDetail; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanCharge.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanCharge.java index d70c6519e..562ab1e77 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanCharge.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanCharge.java @@ -17,12 +17,12 @@ import javax.persistence.TemporalType; import org.joda.time.LocalDate; import org.mifosng.platform.api.commands.LoanChargeCommand; -import org.mifosng.platform.exceptions.LoanChargeWithoutMandatoryFieldException; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType; import org.mifosplatform.portfolio.charge.domain.ChargeTimeType; +import org.mifosplatform.portfolio.charge.exception.LoanChargeWithoutMandatoryFieldException; import org.springframework.data.jpa.domain.AbstractPersistable; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanOfficerAssignmentHistory.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanOfficerAssignmentHistory.java index 1b46e18cf..58e27f183 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanOfficerAssignmentHistory.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanOfficerAssignmentHistory.java @@ -1,7 +1,7 @@ package org.mifosng.platform.loan.domain; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.staff.domain.Staff; import org.mifosplatform.infrastructure.user.domain.AppUser; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanRepaymentScheduleInstallment.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanRepaymentScheduleInstallment.java index 7e663b929..876e4f250 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanRepaymentScheduleInstallment.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanRepaymentScheduleInstallment.java @@ -12,9 +12,9 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanTransaction.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanTransaction.java index 91f1fc1fb..0cc7f26a5 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/LoanTransaction.java @@ -16,12 +16,12 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.LoanTransactionData; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations; import org.springframework.format.annotation.DateTimeFormat; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/SavingTypeMethod.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/SavingTypeMethod.java deleted file mode 100644 index 603644a8d..000000000 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/domain/SavingTypeMethod.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.mifosng.platform.loan.domain; - -public enum SavingTypeMethod { - FIXEDTERM_DEPOSITS(0,"savingtype.fixedterm"),OTHER(1,"savingtype.other"),INVALID(2,"savingtype.invalid"); - - private final Integer value; - private final String code; - - private SavingTypeMethod(final Integer value,final String code){ - - this.value=value; - this.code=code; - } - - public Integer getValue() { - return this.value; - } - - public String getCode() { - return code; - } - - public static SavingTypeMethod fromInt(final Integer selectedType){ - SavingTypeMethod savingTypeMethod=null; - switch (selectedType) { - case 0: - savingTypeMethod=SavingTypeMethod.FIXEDTERM_DEPOSITS; - break; - case 1: - savingTypeMethod=SavingTypeMethod.OTHER; - break; - - default: - savingTypeMethod=SavingTypeMethod.INVALID; - break; - } - - return savingTypeMethod; - } - - -} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java index 0ceebad97..ca671af58 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.loan.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class AdjustLoanTransactionCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/CalculateLoanScheduleCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/CalculateLoanScheduleCommandValidator.java index f34929724..3a68f9bd4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/CalculateLoanScheduleCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/CalculateLoanScheduleCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.loan.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class CalculateLoanScheduleCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanApplicationCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanApplicationCommandValidator.java index da1160b4a..6929e8309 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanApplicationCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanApplicationCommandValidator.java @@ -3,12 +3,12 @@ package org.mifosng.platform.loan.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand; import org.mifosng.platform.api.commands.LoanChargeCommand; import org.mifosng.platform.api.commands.LoanApplicationCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class LoanApplicationCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanAssembler.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanAssembler.java index 8d3237608..adc0c9711 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanAssembler.java @@ -8,15 +8,8 @@ import java.util.Set; import org.mifosng.platform.api.commands.LoanApplicationCommand; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanSchedulePeriodData; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.exceptions.ClientNotFoundException; -import org.mifosng.platform.exceptions.FundNotFoundException; import org.mifosng.platform.exceptions.GroupNotFoundException; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; import org.mifosng.platform.exceptions.LoanTransactionProcessingStrategyNotFoundException; -import org.mifosng.platform.exceptions.StaffNotFoundException; -import org.mifosng.platform.exceptions.StaffRoleException; import org.mifosng.platform.group.domain.Group; import org.mifosng.platform.group.domain.GroupRepository; import org.mifosng.platform.loan.domain.DefaultLoanLifecycleStateMachine; @@ -30,8 +23,14 @@ import org.mifosng.platform.loanschedule.domain.AprCalculator; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.staff.domain.Staff; import org.mifosplatform.infrastructure.staff.domain.StaffRepository; +import org.mifosplatform.infrastructure.staff.exception.StaffNotFoundException; +import org.mifosplatform.infrastructure.staff.exception.StaffRoleException; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.fund.domain.Fund; import org.mifosplatform.portfolio.fund.domain.FundRepository; +import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestCalculationPeriodMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestMethod; @@ -40,6 +39,7 @@ import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRelatedDetail; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository; import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeAssembler.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeAssembler.java index 3ff7e4f8f..cd06b5b4e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeAssembler.java @@ -5,13 +5,13 @@ import java.util.HashSet; import java.util.Set; import org.mifosng.platform.api.commands.LoanChargeCommand; -import org.mifosng.platform.exceptions.ChargeIsNotActiveException; -import org.mifosng.platform.exceptions.ChargeNotFoundException; -import org.mifosng.platform.exceptions.LoanChargeNotFoundException; import org.mifosng.platform.loan.domain.LoanCharge; import org.mifosng.platform.loan.domain.LoanChargeRepository; import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.ChargeRepository; +import org.mifosplatform.portfolio.charge.exception.ChargeIsNotActiveException; +import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; +import org.mifosplatform.portfolio.charge.exception.LoanChargeNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeCommandValidator.java index feaf95fb3..d6bf6e71e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanChargeCommandValidator.java @@ -1,9 +1,9 @@ package org.mifosng.platform.loan.service; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.LoanChargeCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import java.util.ArrayList; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanProductRelatedDetailAssembler.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanProductRelatedDetailAssembler.java index 7651b0012..81de116b2 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanProductRelatedDetailAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanProductRelatedDetailAssembler.java @@ -3,7 +3,6 @@ package org.mifosng.platform.loan.service; import java.math.BigDecimal; import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; import org.mifosng.platform.loanschedule.domain.AprCalculator; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; @@ -13,6 +12,7 @@ import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRelatedDetail; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java index a1985aabb..1f46971f7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanReadPlatformServiceImpl.java @@ -7,9 +7,7 @@ import java.util.ArrayList; import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.ClientData; import org.mifosng.platform.api.data.DisbursementData; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.GroupData; import org.mifosng.platform.api.data.LoanBasicDetailsData; import org.mifosng.platform.api.data.LoanChargeData; @@ -17,13 +15,9 @@ import org.mifosng.platform.api.data.LoanPermissionData; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanSchedulePeriodData; import org.mifosng.platform.api.data.LoanTransactionData; -import org.mifosng.platform.client.service.ClientReadPlatformService; -import org.mifosng.platform.exceptions.CurrencyNotFoundException; import org.mifosng.platform.exceptions.LoanNotFoundException; import org.mifosng.platform.exceptions.LoanTransactionNotFoundException; import org.mifosng.platform.group.service.GroupReadPlatformService; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosng.platform.loan.domain.Loan; import org.mifosng.platform.loan.domain.LoanRepository; import org.mifosng.platform.loan.domain.LoanTransaction; @@ -34,7 +28,13 @@ import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrency import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrencyRepository; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.configuration.exception.CurrencyNotFoundException; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations; import org.mifosplatform.portfolio.loanproduct.service.LoanProductReadPlatformService; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanStateTransitionCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanStateTransitionCommandValidator.java index ad479bcd4..514f16408 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanStateTransitionCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanStateTransitionCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.loan.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.LoanStateTransitionCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class LoanStateTransitionCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanTransactionCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanTransactionCommandValidator.java index 4b26988f1..025958ed4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanTransactionCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanTransactionCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.loan.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.LoanTransactionCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class LoanTransactionCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java index b34512f67..750be4902 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformService.java @@ -6,7 +6,7 @@ import org.mifosng.platform.api.commands.LoanStateTransitionCommand; import org.mifosng.platform.api.commands.LoanTransactionCommand; import org.mifosng.platform.api.commands.LoanApplicationCommand; import org.mifosng.platform.api.commands.UndoStateTransitionCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 4eebb515a..456ecbf7e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -15,24 +15,12 @@ import org.mifosng.platform.api.commands.LoanChargeCommand; import org.mifosng.platform.api.commands.LoanStateTransitionCommand; import org.mifosng.platform.api.commands.LoanTransactionCommand; import org.mifosng.platform.api.commands.UndoStateTransitionCommand; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanSchedulePeriodData; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.client.domain.Note; -import org.mifosng.platform.client.domain.NoteRepository; -import org.mifosng.platform.exceptions.ChargeIsNotActiveException; -import org.mifosng.platform.exceptions.ChargeNotFoundException; -import org.mifosng.platform.exceptions.ClientNotFoundException; -import org.mifosng.platform.exceptions.InvalidCurrencyException; -import org.mifosng.platform.exceptions.LoanChargeNotFoundException; import org.mifosng.platform.exceptions.LoanNotFoundException; import org.mifosng.platform.exceptions.LoanNotInSubmittedAndPendingApprovalStateCannotBeDeleted; import org.mifosng.platform.exceptions.LoanOfficerAssignmentException; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; import org.mifosng.platform.exceptions.LoanTransactionNotFoundException; -import org.mifosng.platform.exceptions.NoAuthorizationException; import org.mifosng.platform.loan.domain.DefaultLoanLifecycleStateMachine; import org.mifosng.platform.loan.domain.Loan; import org.mifosng.platform.loan.domain.LoanCharge; @@ -45,6 +33,8 @@ import org.mifosng.platform.loan.domain.LoanTransaction; import org.mifosng.platform.loan.domain.LoanTransactionRepository; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand; import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommandValidator; @@ -52,11 +42,21 @@ import org.mifosplatform.infrastructure.staff.domain.Staff; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.ChargeRepository; +import org.mifosplatform.portfolio.charge.exception.ChargeIsNotActiveException; +import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; +import org.mifosplatform.portfolio.charge.exception.LoanChargeNotFoundException; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.domain.Note; +import org.mifosplatform.portfolio.client.domain.NoteRepository; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.fund.domain.Fund; import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository; import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; +import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java index 437c4c8ef..e6397f82d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java @@ -26,13 +26,13 @@ import org.joda.time.Days; import org.joda.time.LocalDate; import org.joda.time.Months; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; -import org.mifosng.platform.client.domain.Client; import org.mifosng.platform.exceptions.InvalidDepositStateTransitionException; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosng.platform.savingproduct.domain.DepositProduct; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/SavingAccount.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/SavingAccount.java index aae798a53..3f0f84d83 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/SavingAccount.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/SavingAccount.java @@ -14,8 +14,6 @@ import javax.persistence.TemporalType; import javax.persistence.UniqueConstraint; import org.joda.time.LocalDate; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosng.platform.savingproduct.domain.SavingFrequencyType; import org.mifosng.platform.savingproduct.domain.SavingInterestCalculationMethod; import org.mifosng.platform.savingproduct.domain.SavingProduct; @@ -24,7 +22,9 @@ import org.mifosng.platform.savingproduct.domain.SavingsInterestType; import org.mifosng.platform.savingproduct.domain.TenureTypeEnum; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountAssembler.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountAssembler.java index 6d7a044a8..d6a92b1af 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountAssembler.java @@ -6,9 +6,6 @@ import java.util.List; import org.joda.time.LocalDate; import org.mifosng.platform.api.commands.DepositAccountCommand; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.exceptions.ClientNotFoundException; import org.mifosng.platform.exceptions.DepositAccounDataValidationtException; import org.mifosng.platform.exceptions.DepositProductNotFoundException; import org.mifosng.platform.saving.domain.DepositAccount; @@ -19,6 +16,9 @@ import org.mifosng.platform.saving.domain.FixedTermDepositInterestCalculator; import org.mifosng.platform.savingproduct.domain.DepositProduct; import org.mifosng.platform.savingproduct.domain.DepositProductRepository; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java index a1ff5ace5..d9d36be5a 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositAccountCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class DepositAccountCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountEnumerations.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountEnumerations.java index 13eca4f0a..f9a0dac3b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountEnumerations.java @@ -1,7 +1,7 @@ package org.mifosng.platform.saving.service; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.saving.domain.DepositAccountStatus; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; public class DepositAccountEnumerations { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java index 54811aa26..0d25f400d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java @@ -7,21 +7,21 @@ import java.util.Collection; import org.joda.time.LocalDate; import org.joda.time.Months; -import org.mifosng.platform.api.data.ClientData; import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositAccountTransactionData; import org.mifosng.platform.api.data.DepositPermissionData; import org.mifosng.platform.api.data.DepositProductData; import org.mifosng.platform.api.data.DepositProductLookup; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.client.service.ClientReadPlatformService; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosng.platform.savingproduct.service.DepositProductReadPlatformService; import org.mifosng.platform.savingproduct.service.SavingsDepositEnumerations; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountTransactionEnumerations.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountTransactionEnumerations.java index 56df2900a..9f279ad9d 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountTransactionEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountTransactionEnumerations.java @@ -1,7 +1,7 @@ package org.mifosng.platform.saving.service; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.saving.domain.DepositAccountTransactionType; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; public class DepositAccountTransactionEnumerations { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWithdrawalCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWithdrawalCommandValidator.java index 9f97f0a5c..4613917d3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWithdrawalCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWithdrawalCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class DepositAccountWithdrawalCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java index f128257ce..8e1a78225 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java @@ -6,7 +6,7 @@ import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; import org.mifosng.platform.api.commands.DepositStateTransitionCommand; import org.mifosng.platform.api.commands.UndoStateTransitionCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface DepositAccountWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java index 05c0fb720..1f7035034 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java @@ -13,14 +13,10 @@ import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; import org.mifosng.platform.api.commands.DepositStateTransitionCommand; import org.mifosng.platform.api.commands.UndoStateTransitionCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.client.domain.Note; -import org.mifosng.platform.client.domain.NoteRepository; import org.mifosng.platform.exceptions.DepositAccountNotFoundException; import org.mifosng.platform.exceptions.DepositAccountReopenException; import org.mifosng.platform.exceptions.DepositAccountTransactionsException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.exceptions.ProductNotFoundException; +import org.mifosng.platform.exceptions.SavingsProductNotFoundException; import org.mifosng.platform.saving.domain.DepositAccount; import org.mifosng.platform.saving.domain.DepositAccountRepository; import org.mifosng.platform.saving.domain.DepositAccountStatus; @@ -28,7 +24,11 @@ import org.mifosng.platform.saving.domain.DepositLifecycleStateMachine; import org.mifosng.platform.saving.domain.DepositLifecycleStateMachineImpl; import org.mifosng.platform.saving.domain.FixedTermDepositInterestCalculator; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.domain.Note; +import org.mifosplatform.portfolio.client.domain.NoteRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -103,7 +103,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo DepositAccount account = this.depositAccountRepository.findOne(accountId); if (account==null || account.isDeleted()) { - throw new ProductNotFoundException(accountId); + throw new SavingsProductNotFoundException(accountId); } account.delete(); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionApprovalCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionApprovalCommandValidator.java index cc75a7040..287eb9be8 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionApprovalCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionApprovalCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class DepositStateTransitionApprovalCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionCommandValidator.java index d4cf549bf..bee3018d3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositStateTransitionCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositStateTransitionCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class DepositStateTransitionCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/RenewDepositAccountCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/RenewDepositAccountCommandValidator.java index a806c324b..754517375 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/RenewDepositAccountCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/RenewDepositAccountCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositAccountCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class RenewDepositAccountCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountAssembler.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountAssembler.java index 166860ad1..2319d449b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountAssembler.java @@ -6,10 +6,7 @@ import java.util.List; import org.joda.time.LocalDate; import org.mifosng.platform.api.commands.SavingAccountCommand; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.exceptions.ClientNotFoundException; -import org.mifosng.platform.exceptions.ProductNotFoundException; +import org.mifosng.platform.exceptions.SavingsProductNotFoundException; import org.mifosng.platform.saving.domain.DepositAccountStatus; import org.mifosng.platform.saving.domain.DepositLifecycleStateMachine; import org.mifosng.platform.saving.domain.DepositLifecycleStateMachineImpl; @@ -24,6 +21,9 @@ import org.mifosng.platform.savingproduct.domain.SavingsInterestType; import org.mifosng.platform.savingproduct.domain.TenureTypeEnum; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,7 +52,7 @@ public class SavingAccountAssembler { SavingProduct product=this.savingProductRepository.findOne(command.getProductId()); if(product == null || product.isDeleted()){ - throw new ProductNotFoundException(command.getProductId()); + throw new SavingsProductNotFoundException(command.getProductId()); } MonetaryCurrency currency = product.getCurrency(); @@ -127,7 +127,7 @@ public class SavingAccountAssembler { if(product.getId() != command.getProductId()){ product = this.savingProductRepository.findOne(command.getProductId()); if(product == null || product.isDeleted()) - throw new ProductNotFoundException(command.getProductId()); + throw new SavingsProductNotFoundException(command.getProductId()); } } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountCommandValidator.java index 0bb33875d..0add042de 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.SavingAccountCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class SavingAccountCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountReadPlatformServiceImpl.java index e36c15b75..7995ff0e6 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountReadPlatformServiceImpl.java @@ -6,12 +6,12 @@ import java.sql.SQLException; import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.SavingAccountData; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosng.platform.savingproduct.service.SavingProductEnumerations; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java index 75b718676..27caea978 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformService.java @@ -1,7 +1,7 @@ package org.mifosng.platform.saving.service; import org.mifosng.platform.api.commands.SavingAccountCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface SavingAccountWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformServiceJpaRepositoryImpl.java index 959a02c16..07260dfe7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/SavingAccountWritePlatformServiceJpaRepositoryImpl.java @@ -1,13 +1,13 @@ package org.mifosng.platform.saving.service; import org.mifosng.platform.api.commands.SavingAccountCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.client.domain.NoteRepository; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosng.platform.exceptions.SavingAccountNotFoundException; import org.mifosng.platform.saving.domain.SavingAccount; import org.mifosng.platform.saving.domain.SavingAccountRepository; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.domain.NoteRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/WithDrawDepositAccountInterestCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/WithDrawDepositAccountInterestCommandValidator.java index 73438058b..135a88291 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/WithDrawDepositAccountInterestCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/WithDrawDepositAccountInterestCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.saving.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositAccountWithdrawInterestCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class WithDrawDepositAccountInterestCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/DepositProduct.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/DepositProduct.java index 1111343ef..8ae98894e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/DepositProduct.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/DepositProduct.java @@ -10,9 +10,9 @@ import javax.persistence.UniqueConstraint; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.DepositProductCommand; -import org.mifosng.platform.exceptions.ValueOutsideRangeException; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosng.platform.exceptions.DepositProductValueOutsideRangeException; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; @@ -304,7 +304,7 @@ public class DepositProduct extends AbstractAuditableCustom { final String actualValue = interestRate.toPlainString(); final String minValue = (this.maturityMinInterestRate == null) ? "" : this.maturityMinInterestRate.toPlainString(); final String maxValue = (this.maturityMaxInterestRate == null) ? "" : this.maturityMaxInterestRate.toPlainString(); - throw new ValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.maturityInterestRate"); + throw new DepositProductValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.maturityInterestRate"); } } @@ -322,7 +322,7 @@ public class DepositProduct extends AbstractAuditableCustom { final String actualValue = depositAmount.toPlainString(); final String minValue = (this.minimumBalance == null) ? "" : this.minimumBalance.toPlainString(); final String maxValue = (this.minimumBalance == null) ? "" : this.minimumBalance.toPlainString(); - throw new ValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.deposit.amount"); + throw new DepositProductValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.deposit.amount"); } } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/SavingProduct.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/SavingProduct.java index 8f952789c..36f3d11fa 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/SavingProduct.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/domain/SavingProduct.java @@ -9,8 +9,8 @@ import javax.persistence.Table; import org.apache.commons.lang.StringUtils; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductCommandValidator.java index 5da7a82e2..e21d0bec4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.savingproduct.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.DepositProductCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class DepositProductCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductReadPlatformServiceImpl.java index 1aebd0f6d..6398aa26b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductReadPlatformServiceImpl.java @@ -9,10 +9,10 @@ import java.util.List; import org.joda.time.DateTime; import org.mifosng.platform.api.data.DepositProductData; import org.mifosng.platform.api.data.DepositProductLookup; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java index 969f1e2bc..729083fd1 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformService.java @@ -1,7 +1,7 @@ package org.mifosng.platform.savingproduct.service; import org.mifosng.platform.api.commands.DepositProductCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface DepositProductWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java index 1044ad1b4..9f8483c2b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/DepositProductWritePlatformServiceJpaRepositoryImpl.java @@ -1,12 +1,12 @@ package org.mifosng.platform.savingproduct.service; import org.mifosng.platform.api.commands.DepositProductCommand; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.exceptions.DepositProductNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosng.platform.savingproduct.domain.DepositProduct; import org.mifosng.platform.savingproduct.domain.DepositProductRepository; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.slf4j.Logger; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductCommandValidator.java index 49060c1b9..b268a5518 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosng.platform.savingproduct.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class SavingProductCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductEnumerations.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductEnumerations.java index e132e2b50..f7c9d9544 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductEnumerations.java @@ -1,12 +1,12 @@ package org.mifosng.platform.savingproduct.service; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.savingproduct.domain.SavingFrequencyType; import org.mifosng.platform.savingproduct.domain.SavingInterestCalculationMethod; import org.mifosng.platform.savingproduct.domain.SavingProductType; import org.mifosng.platform.savingproduct.domain.SavingsInterestType; import org.mifosng.platform.savingproduct.domain.SavingsLockinPeriodEnum; import org.mifosng.platform.savingproduct.domain.TenureTypeEnum; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; public class SavingProductEnumerations { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductReadPlatformServiceImpl.java index 07674bef3..d0771d8d6 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductReadPlatformServiceImpl.java @@ -7,17 +7,17 @@ import java.util.Collection; import java.util.List; import org.joda.time.DateTime; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.SavingProductData; import org.mifosng.platform.api.data.SavingProductLookup; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosng.platform.savingproduct.domain.SavingProductType; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java index b88af7194..f1abc6056 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformService.java @@ -1,7 +1,7 @@ package org.mifosng.platform.savingproduct.service; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.springframework.security.access.prepost.PreAuthorize; public interface SavingProductWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java index 348434ce2..0f53c27d8 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java @@ -1,8 +1,7 @@ package org.mifosng.platform.savingproduct.service; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.exceptions.ProductNotFoundException; +import org.mifosng.platform.exceptions.SavingsProductNotFoundException; import org.mifosng.platform.exceptions.SavingProductNotFoundException; import org.mifosng.platform.savingproduct.domain.SavingFrequencyType; import org.mifosng.platform.savingproduct.domain.SavingInterestCalculationMethod; @@ -12,6 +11,7 @@ import org.mifosng.platform.savingproduct.domain.SavingProductType; import org.mifosng.platform.savingproduct.domain.SavingsInterestType; import org.mifosng.platform.savingproduct.domain.TenureTypeEnum; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; import org.springframework.beans.factory.annotation.Autowired; @@ -79,7 +79,7 @@ public class SavingProductWritePlatformServiceJpaRepositoryImpl implements Savin this.context.authenticatedUser(); SavingProduct product=this.savingProductRepository.findOne(productId); if (product==null || product.isDeleted()) { - throw new ProductNotFoundException(productId); + throw new SavingsProductNotFoundException(productId); } product.delete(); this.savingProductRepository.save(product); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingsDepositEnumerations.java b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingsDepositEnumerations.java index d6ca7857d..fa4ef4cd7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingsDepositEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/savingproduct/service/SavingsDepositEnumerations.java @@ -1,6 +1,6 @@ package org.mifosng.platform.savingproduct.service; -import org.mifosng.platform.api.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; public class SavingsDepositEnumerations { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLAccountsApiResource.java index 02a33baf6..50073d4fc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLAccountsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLAccountsApiResource.java @@ -17,14 +17,14 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.accounting.api.commands.GLAccountCommand; import org.mifosplatform.accounting.api.data.GLAccountData; import org.mifosplatform.accounting.api.infrastructure.AccountingApiDataConversionService; import org.mifosplatform.accounting.api.infrastructure.AccountingApiJsonSerializerService; import org.mifosplatform.accounting.service.GLAccountReadPlatformService; import org.mifosplatform.accounting.service.GLAccountWritePlatformService; +import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLClosuresApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLClosuresApiResource.java index 24741e4e6..e75df75ea 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLClosuresApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/GLClosuresApiResource.java @@ -17,14 +17,14 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.accounting.api.commands.GLClosureCommand; import org.mifosplatform.accounting.api.data.GLClosureData; import org.mifosplatform.accounting.api.infrastructure.AccountingApiDataConversionService; import org.mifosplatform.accounting.api.infrastructure.AccountingApiJsonSerializerService; import org.mifosplatform.accounting.service.GLClosureReadPlatformService; import org.mifosplatform.accounting.service.GLClosureWritePlatformService; +import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/AccountingApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/AccountingApiJsonSerializerService.java index 4e1dc7dc2..f8f196156 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/AccountingApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/AccountingApiJsonSerializerService.java @@ -3,9 +3,9 @@ package org.mifosplatform.accounting.api.infrastructure; import java.util.Collection; import java.util.Set; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosplatform.accounting.api.data.GLAccountData; import org.mifosplatform.accounting.api.data.GLClosureData; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; public interface AccountingApiJsonSerializerService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/AccountingApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/AccountingApiDataConversionServiceImpl.java index cedee4746..a87d99c88 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/AccountingApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/AccountingApiDataConversionServiceImpl.java @@ -10,12 +10,12 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.api.JsonParserHelper; -import org.mifosng.platform.infrastructure.errorhandling.InvalidJsonException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedParameterException; 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.springframework.stereotype.Service; import com.google.gson.Gson; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/GoogleGsonAccountingApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/GoogleGsonAccountingApiJsonSerializerService.java index c09348576..025dbc077 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/GoogleGsonAccountingApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/api/infrastructure/impl/GoogleGsonAccountingApiJsonSerializerService.java @@ -5,12 +5,12 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.infrastructure.api.GoogleGsonSerializerHelper; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/domain/GLClosure.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/domain/GLClosure.java index f356ac91f..2478430ee 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/domain/GLClosure.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/domain/GLClosure.java @@ -13,8 +13,8 @@ import javax.persistence.UniqueConstraint; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.accounting.api.commands.GLClosureCommand; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.user.domain.AppUser; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountDuplicateException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountDuplicateException.java index 8e71c1771..85a1ad34d 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountDuplicateException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountDuplicateException.java @@ -1,6 +1,6 @@ package org.mifosplatform.accounting.exceptions; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * A {@link RuntimeException} thrown when a GL Account with a given GL Code of diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidClassificationException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidClassificationException.java index 635120788..86f781b40 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidClassificationException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidClassificationException.java @@ -1,6 +1,6 @@ package org.mifosplatform.accounting.exceptions; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * A {@link RuntimeException} thrown when trying to fetch accounts belonging to diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidDeleteException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidDeleteException.java index 5df89f93b..29af52dee 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidDeleteException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidDeleteException.java @@ -1,6 +1,6 @@ package org.mifosplatform.accounting.exceptions; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * A {@link RuntimeException} thrown when a GL Account with a given GL Code of diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidParentException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidParentException.java index dd1c5aeca..cc632d130 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidParentException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountInvalidParentException.java @@ -1,6 +1,6 @@ package org.mifosplatform.accounting.exceptions; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * A {@link RuntimeException} thrown when trying to map invalid parents to a GL diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountNotFoundException.java index 36f0bd01f..64a90b49f 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLAccountNotFoundException.java @@ -1,6 +1,6 @@ package org.mifosplatform.accounting.exceptions; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when GL account resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureDuplicateException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureDuplicateException.java index beb2407ac..39d4fe65e 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureDuplicateException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureDuplicateException.java @@ -1,7 +1,7 @@ package org.mifosplatform.accounting.exceptions; import org.joda.time.LocalDate; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * A {@link RuntimeException} thrown when a GL Closure for a given date and diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureNotFoundException.java index 71ec8cb15..9601f6505 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/exceptions/GLClosureNotFoundException.java @@ -1,6 +1,6 @@ package org.mifosplatform.accounting.exceptions; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when GL account closure resources are not diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLAccountCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLAccountCommandValidator.java index e3a19fb37..069d42dea 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLAccountCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLAccountCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosplatform.accounting.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; import org.mifosplatform.accounting.api.commands.GLAccountCommand; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class GLAccountCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLClosureCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLClosureCommandValidator.java index ee9df9071..d0ad62f6d 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLClosureCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/GLClosureCommandValidator.java @@ -3,10 +3,10 @@ package org.mifosplatform.accounting.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; import org.mifosplatform.accounting.api.commands.GLClosureCommand; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class GLClosureCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountReadPlatformServiceImpl.java index 4e17f924b..bc2bf5033 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountReadPlatformServiceImpl.java @@ -5,12 +5,12 @@ import java.sql.SQLException; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.accounting.AccountingConstants.GL_ACCOUNT_CLASSIFICATION; import org.mifosplatform.accounting.api.data.GLAccountData; import org.mifosplatform.accounting.exceptions.GLAccountInvalidClassificationException; import org.mifosplatform.accounting.exceptions.GLAccountNotFoundException; import org.mifosplatform.accounting.service.GLAccountReadPlatformService; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountWritePlatformServiceJpaRepositoryImpl.java index 070a2e58b..a35beaf7c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLAccountWritePlatformServiceJpaRepositoryImpl.java @@ -1,6 +1,5 @@ package org.mifosplatform.accounting.service.impl; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosplatform.accounting.api.commands.GLAccountCommand; import org.mifosplatform.accounting.domain.GLAccount; import org.mifosplatform.accounting.domain.GLAccountRepository; @@ -11,6 +10,7 @@ import org.mifosplatform.accounting.exceptions.GLAccountNotFoundException; import org.mifosplatform.accounting.exceptions.GLAccountInvalidDeleteException.GL_ACCOUNT_INVALID_DELETE_REASON; import org.mifosplatform.accounting.service.GLAccountCommandValidator; import org.mifosplatform.accounting.service.GLAccountWritePlatformService; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureReadPlatformServiceImpl.java index c6a354c05..4dce802d4 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureReadPlatformServiceImpl.java @@ -5,11 +5,11 @@ import java.sql.SQLException; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.accounting.api.data.GLClosureData; import org.mifosplatform.accounting.exceptions.GLClosureNotFoundException; import org.mifosplatform.accounting.service.GLClosureReadPlatformService; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureWritePlatformServiceJpaRepositoryImpl.java index ba7f75d6d..8be3ec0d0 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/service/impl/GLClosureWritePlatformServiceJpaRepositoryImpl.java @@ -1,7 +1,5 @@ package org.mifosplatform.accounting.service.impl; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosplatform.accounting.api.commands.GLClosureCommand; import org.mifosplatform.accounting.domain.GLClosure; import org.mifosplatform.accounting.domain.GLClosureRepository; @@ -9,8 +7,10 @@ import org.mifosplatform.accounting.exceptions.GLClosureDuplicateException; import org.mifosplatform.accounting.exceptions.GLClosureNotFoundException; import org.mifosplatform.accounting.service.GLClosureCommandValidator; import org.mifosplatform.accounting.service.GLClosureWritePlatformService; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.office.domain.OfficeRepository; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/CommandsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/CommandsApiResource.java index 56af732b1..004742f46 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/api/CommandsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/api/CommandsApiResource.java @@ -16,13 +16,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.exceptions.UnrecognizedQueryParamException; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.api.data.CommandSourceData; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService; +import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandSource.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandSource.java index fcc8b5e22..f7ca20654 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandSource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandSource.java @@ -178,4 +178,8 @@ public class CommandSource extends AbstractPersistable { public boolean isClientResource() { return this.resource.equalsIgnoreCase("CLIENTS"); } + + public boolean isClientIdentifierResource() { + return this.resource.toUpperCase().startsWith("CLIENTS") && this.resource.toUpperCase().endsWith("IDENTIFIERS"); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/exception/UnsupportedCommandException.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/exception/UnsupportedCommandException.java new file mode 100644 index 000000000..b50943fe5 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/exception/UnsupportedCommandException.java @@ -0,0 +1,18 @@ +package org.mifosplatform.commands.exception; + +/** + * A {@link RuntimeException} that is thrown in the case where an invalid or + * unknown command is attempted to be processed by platform. + */ +public class UnsupportedCommandException extends RuntimeException { + + private final String unsupportedCommandName; + + public UnsupportedCommandException(final String unsupportedCommandName) { + this.unsupportedCommandName = unsupportedCommandName; + } + + public String getUnsupportedCommandName() { + return unsupportedCommandName; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ChargeDefinitionCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ChargeDefinitionCommandHandler.java index a9164ff3a..04136c8cf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ChargeDefinitionCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ChargeDefinitionCommandHandler.java @@ -4,14 +4,14 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.commands.domain.CommandSource; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; import org.mifosplatform.portfolio.charge.service.ChargeWritePlatformService; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientCommandHandler.java index 2a6a310c9..c05075d5f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientCommandHandler.java @@ -4,15 +4,15 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.ClientWritePlatformService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.commands.domain.CommandSource; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.service.ClientWritePlatformService; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientIdentifierCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientIdentifierCommandHandler.java new file mode 100644 index 000000000..aedc2dcdf --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/ClientIdentifierCommandHandler.java @@ -0,0 +1,123 @@ +package org.mifosplatform.commands.handler; + +import java.util.Arrays; +import java.util.List; + +import org.joda.time.LocalDate; +import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; +import org.mifosplatform.portfolio.client.service.ClientWritePlatformService; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ClientIdentifierCommandHandler implements CommandSourceHandler { + + private final PlatformSecurityContext context; + private final ChangeDetectionService changeDetectionService; + private final ClientWritePlatformService clientWritePlatformService; + private final PortfolioCommandDeserializerService commandDeserializerService; + + @Autowired + public ClientIdentifierCommandHandler(final PlatformSecurityContext context, final ChangeDetectionService changeDetectionService, + final PortfolioCommandDeserializerService commandDeserializerService, + final ClientWritePlatformService clientWritePlatformService) { + this.context = context; + this.changeDetectionService = changeDetectionService; + this.commandDeserializerService = commandDeserializerService; + this.clientWritePlatformService = clientWritePlatformService; + } + + @Override + public CommandSource handleCommandWithSupportForRollback(final CommandSource commandSource) { + + final AppUser maker = context.authenticatedUser(); + final LocalDate asToday = new LocalDate(); + + final ClientIdentifierCommand command = this.commandDeserializerService.deserializeClientIdentifierCommand( + commandSource.resourceId(), null, commandSource.json(), false); + + CommandSource commandSourceResult = commandSource.copy(); + Long newResourceId = null; + + if (commandSource.isCreate()) { + try { + newResourceId = this.clientWritePlatformService.addClientIdentifier(command); + commandSourceResult.markAsChecked(maker, asToday); + commandSourceResult.updateResourceId(newResourceId); + } catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) { + // swallow this rollback transaction by design + } + } else if (commandSource.isUpdate()) { + try { + final String jsonOfChangesOnly = this.changeDetectionService.detectChangesOnUpdate(commandSource.resourceName(), + commandSource.resourceId(), commandSource.json()); + commandSourceResult.updateJsonTo(jsonOfChangesOnly); + + final ClientIdentifierCommand changesOnly = this.commandDeserializerService.deserializeClientIdentifierCommand( + commandSource.resourceId(), null, jsonOfChangesOnly, false); + + EntityIdentifier result = this.clientWritePlatformService.updateClientIdentifier(changesOnly); + newResourceId = result.getEntityId(); + + commandSourceResult.markAsChecked(maker, asToday); + } catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) { + // swallow this rollback transaction by design + } + } else if (commandSource.isDelete()) { + try { + EntityIdentifier result = this.clientWritePlatformService.deleteClientIdentifier(command); + newResourceId = result.getEntityId(); + commandSourceResult.markAsChecked(maker, asToday); + } catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) { + // swallow this rollback transaction by design + } + } + + return commandSourceResult; + } + + @Override + public CommandSource handleCommandForCheckerApproval(final CommandSource commandSourceResult) { + + final AppUser checker = context.authenticatedUser(); + + Long resourceId = null; + final ClientIdentifierCommand command = this.commandDeserializerService.deserializeClientIdentifierCommand( + commandSourceResult.resourceId(), null, commandSourceResult.json(), true); + + if (commandSourceResult.isCreate()) { + final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", + "CREATE_CLIENTIDENTIFIER_CHECKER"); + context.authenticatedUser().validateHasPermissionTo("CREATE_CLIENTIDENTIFIER_CHECKER", allowedPermissions); + + resourceId = this.clientWritePlatformService.addClientIdentifier(command); + commandSourceResult.updateResourceId(resourceId); + commandSourceResult.markAsChecked(checker, new LocalDate()); + } else if (commandSourceResult.isUpdate()) { + final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", + "UPDATE_CLIENTIDENTIFIER_CHECKER"); + context.authenticatedUser().validateHasPermissionTo("UPDATE_CLIENTIDENTIFIER_CHECKER", allowedPermissions); + + EntityIdentifier result = this.clientWritePlatformService.updateClientIdentifier(command); + resourceId = result.getEntityId(); + commandSourceResult.markAsChecked(checker, new LocalDate()); + } else if (commandSourceResult.isDelete()) { + final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", + "DELETE_CLIENTIDENTIFIER_CHECKER"); + context.authenticatedUser().validateHasPermissionTo("DELETE_CLIENTIDENTIFIER_CHECKER", allowedPermissions); + + EntityIdentifier result = this.clientWritePlatformService.deleteClientIdentifier(command); + resourceId = result.getEntityId(); + commandSourceResult.markAsChecked(checker, new LocalDate()); + } + + return commandSourceResult; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CodeCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CodeCommandHandler.java index 68dc08eb2..a511e84ce 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CodeCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CodeCommandHandler.java @@ -4,14 +4,14 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.commands.domain.CommandSource; import org.mifosplatform.commands.service.ChangeDetectionService; import org.mifosplatform.infrastructure.codes.command.CodeCommand; import org.mifosplatform.infrastructure.codes.service.CodeWritePlatformService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CommandSourceHandlerDelegator.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CommandSourceHandlerDelegator.java index 4c5b9aad1..7baf9fe44 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CommandSourceHandlerDelegator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CommandSourceHandlerDelegator.java @@ -1,7 +1,7 @@ package org.mifosplatform.commands.handler; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,10 +25,12 @@ public class CommandSourceHandlerDelegator { private final CurrencyCommandHandler currencyCommandHandler; private final ChargeDefinitionCommandHandler chargeDefinitionCommandHandler; private final LoanProductCommandHandler loanProductCommandHandler; + private final ClientIdentifierCommandHandler clientIdentifierCommandHandler; @Autowired public CommandSourceHandlerDelegator(final PlatformSecurityContext context, final ClientCommandHandler clientCommandHandler, + final ClientIdentifierCommandHandler clientIdentifierCommandHandler, final RoleCommandHandler roleCommandHandler, final PermissionsCommandHandler permissionCommandHandler, final UserCommandHandler userCommandHandler, @@ -42,6 +44,7 @@ public class CommandSourceHandlerDelegator { final LoanProductCommandHandler loanProductCommandHandler) { this.context = context; this.clientCommandHandler = clientCommandHandler; + this.clientIdentifierCommandHandler = clientIdentifierCommandHandler; this.roleCommandHandler = roleCommandHandler; this.permissionCommandHandler = permissionCommandHandler; this.userCommandHandler = userCommandHandler; @@ -61,6 +64,8 @@ public class CommandSourceHandlerDelegator { CommandSource commandSourceResult = null; if (commandSource.isClientResource()) { commandSourceResult = clientCommandHandler.handleCommandWithSupportForRollback(commandSource); + } else if (commandSource.isClientIdentifierResource()) { + commandSourceResult = clientIdentifierCommandHandler.handleCommandWithSupportForRollback(commandSource); } else if (commandSource.isRoleResource()) { commandSourceResult = roleCommandHandler.handleCommandWithSupportForRollback(commandSource); } else if (commandSource.isPermissionResource()) { @@ -95,6 +100,8 @@ public class CommandSourceHandlerDelegator { CommandSource commandSourceResult = null; if (existingCommandSource.isClientResource()) { commandSourceResult = clientCommandHandler.handleCommandForCheckerApproval(existingCommandSource); + } else if (existingCommandSource.isClientIdentifierResource()) { + commandSourceResult = clientIdentifierCommandHandler.handleCommandWithSupportForRollback(existingCommandSource); } else if (existingCommandSource.isRoleResource()) { commandSourceResult = roleCommandHandler.handleCommandForCheckerApproval(existingCommandSource); } else if (existingCommandSource.isPermissionResource()) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CurrencyCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CurrencyCommandHandler.java index 7d9ec364a..539d75061 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CurrencyCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/CurrencyCommandHandler.java @@ -4,15 +4,15 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; import org.mifosplatform.infrastructure.configuration.service.CurrencyWritePlatformService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/FundCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/FundCommandHandler.java index 889f4ccfd..1a121af50 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/FundCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/FundCommandHandler.java @@ -4,13 +4,13 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.fund.service.FundWritePlatformService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/LoanProductCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/LoanProductCommandHandler.java index 122beea08..0e4aac284 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/LoanProductCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/LoanProductCommandHandler.java @@ -4,14 +4,14 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; import org.mifosplatform.portfolio.loanproduct.service.LoanProductWritePlatformService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeCommandHandler.java index ac421c19c..01c13a2fc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeCommandHandler.java @@ -4,15 +4,15 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.office.command.OfficeCommand; import org.mifosplatform.infrastructure.office.service.OfficeWritePlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeTransactionCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeTransactionCommandHandler.java index 72337cabe..adb4f630b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeTransactionCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/OfficeTransactionCommandHandler.java @@ -4,14 +4,14 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand; import org.mifosplatform.infrastructure.office.service.OfficeWritePlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/PermissionsCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/PermissionsCommandHandler.java index a2c0f887e..863644fe4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/PermissionsCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/PermissionsCommandHandler.java @@ -4,15 +4,15 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.command.PermissionsCommand; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.infrastructure.user.service.PermissionWritePlatformService; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/RoleCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/RoleCommandHandler.java index 39827ea4d..609184af0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/RoleCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/RoleCommandHandler.java @@ -4,16 +4,16 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.command.RoleCommand; import org.mifosplatform.infrastructure.user.command.RolePermissionCommand; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.infrastructure.user.service.RoleWritePlatformService; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/StaffCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/StaffCommandHandler.java index c9be9561f..feda0edf6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/StaffCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/StaffCommandHandler.java @@ -4,15 +4,15 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException; import org.mifosplatform.commands.domain.CommandSource; +import org.mifosplatform.commands.exception.UnsupportedCommandException; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.staff.command.StaffCommand; import org.mifosplatform.infrastructure.staff.service.StaffWritePlatformService; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/UserCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/UserCommandHandler.java index 4bf9d891c..573b14a90 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/UserCommandHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/handler/UserCommandHandler.java @@ -4,14 +4,14 @@ import java.util.Arrays; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.commands.domain.CommandSource; import org.mifosplatform.commands.service.ChangeDetectionService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandDeserializerService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.infrastructure.user.service.AppUserWritePlatformService; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -99,13 +99,12 @@ public class UserCommandHandler implements CommandSourceHandler { commandSourceResult.updateResourceId(resourceId); commandSourceResult.markAsChecked(checker, new LocalDate()); } else if (commandSourceResult.isUpdate()) { - final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "USER_ADMINISTRATION_SUPER_USER", - "UPDATE_USER_MAKER"); - context.authenticatedUser().validateHasPermissionTo("UPDATE_USER_MAKER", allowedPermissions); - if (checker.hasIdOf(command.getId())) { this.writePlatformService.updateUsersOwnAccountDetails(command); } else { + final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "USER_ADMINISTRATION_SUPER_USER","UPDATE_USER_MAKER"); + context.authenticatedUser().validateHasPermissionTo("UPDATE_USER_MAKER", allowedPermissions); + this.writePlatformService.updateUser(command); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/ChangeDetectionServiceJdbc.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/ChangeDetectionServiceJdbc.java index d164ea56a..e9c650b49 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/ChangeDetectionServiceJdbc.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/ChangeDetectionServiceJdbc.java @@ -1,11 +1,11 @@ package org.mifosplatform.commands.service; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.client.service.ClientReadPlatformService; +import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService; +import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; +import org.mifosplatform.infrastructure.core.api.PortfolioCommandSerializerService; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformService.java index 37afc728d..88a5e9ea8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformService.java @@ -1,6 +1,6 @@ package org.mifosplatform.commands.service; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; public interface PortfolioCommandSourceWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java index 13a3cc72a..96c1e37b5 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java @@ -1,10 +1,10 @@ package org.mifosplatform.commands.service; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosplatform.commands.domain.CommandSource; import org.mifosplatform.commands.domain.CommandSourceRepository; import org.mifosplatform.commands.handler.CommandSourceHandlerDelegator; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandsReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandsReadPlatformServiceImpl.java index 9f5b57343..15728c748 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandsReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandsReadPlatformServiceImpl.java @@ -5,9 +5,9 @@ import java.sql.SQLException; import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.commands.api.data.CommandSourceData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java index aa580b3cd..556a85395 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/api/CodesApiResource.java @@ -17,15 +17,15 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; 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.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.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/command/CodeCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/command/CodeCommand.java index 1c58aa71c..95da77808 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/command/CodeCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/command/CodeCommand.java @@ -4,9 +4,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; /** * Immutable command for creating or updating details of a code. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeNotFoundException.java index 49dff1dad..38c9634ad 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeNotFoundException.java @@ -1,6 +1,6 @@ package org.mifosplatform.infrastructure.codes.exception; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when a code is not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeValueNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeValueNotFoundException.java index 34d610da4..7e798ff98 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeValueNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/CodeValueNotFoundException.java @@ -1,6 +1,6 @@ package org.mifosplatform.infrastructure.codes.exception; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when client resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/SystemDefinedCodeCannotBeChangedException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/SystemDefinedCodeCannotBeChangedException.java index b95cd351e..a2126b785 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/SystemDefinedCodeCannotBeChangedException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/exception/SystemDefinedCodeCannotBeChangedException.java @@ -1,6 +1,6 @@ package org.mifosplatform.infrastructure.codes.exception; -import org.mifosng.platform.exceptions.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * A {@link AbstractPlatformDomainRuleException} thrown when someone attempts to update or delete a system defined code. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java index 11aa37fcc..952a14c67 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeReadPlatformServiceImpl.java @@ -4,10 +4,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import org.mifosng.platform.exceptions.FundNotFoundException; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.codes.data.CodeData; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java index 963584eae..399f76233 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java @@ -4,8 +4,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.codes.data.CodeValueData; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformService.java index 11c27282b..02f09715c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformService.java @@ -1,7 +1,7 @@ package org.mifosplatform.infrastructure.codes.service; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosplatform.infrastructure.codes.command.CodeCommand; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; public interface CodeWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java index 4551ef44a..088dd2bae 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeWritePlatformServiceJpaRepositoryImpl.java @@ -1,15 +1,15 @@ package org.mifosplatform.infrastructure.codes.service; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.codes.command.CodeCommand; import org.mifosplatform.infrastructure.codes.domain.Code; import org.mifosplatform.infrastructure.codes.domain.CodeRepository; import org.mifosplatform.infrastructure.codes.exception.CodeNotFoundException; import org.mifosplatform.infrastructure.codes.exception.SystemDefinedCodeCannotBeChangedException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/CurrenciesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/CurrenciesApiResource.java index c97f574d7..ca96dc951 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/CurrenciesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/api/CurrenciesApiResource.java @@ -13,15 +13,15 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; import org.mifosplatform.infrastructure.configuration.data.ConfigurationData; import org.mifosplatform.infrastructure.configuration.service.OrganisationCurrencyReadPlatformService; +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.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/exception/CurrencyNotFoundException.java similarity index 69% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/exception/CurrencyNotFoundException.java index 189440836..82698e08f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/exception/CurrencyNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.configuration.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when loan resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyReadPlatformServiceImpl.java index 8e528a715..85d32e5c7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyReadPlatformServiceImpl.java @@ -4,9 +4,9 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java index 6fc57a296..06cbf8039 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java @@ -5,16 +5,16 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrency; import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrencyRepository; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.infrastructure.office.domain.OrganisationCurrency; import org.mifosplatform.infrastructure.office.domain.OrganisationCurrencyRepository; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ApiConstants.java similarity index 85% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiConstants.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ApiConstants.java index d5085d6d9..805d59fec 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ApiConstants.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; public class ApiConstants { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/ApiParameterHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ApiParameterHelper.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/ApiParameterHelper.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ApiParameterHelper.java index e468094f0..021357893 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/ApiParameterHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ApiParameterHelper.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.api; +package org.mifosplatform.infrastructure.core.api; import java.util.Arrays; import java.util.HashSet; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/GoogleGsonPortfolioApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/GoogleGsonPortfolioApiJsonSerializerService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java index cfc99cfd7..d369e5a0f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/GoogleGsonPortfolioApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java @@ -1,17 +1,13 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.data.ClientIdentifierData; import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositProductData; import org.mifosng.platform.api.data.DocumentData; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; import org.mifosng.platform.api.data.GroupData; import org.mifosng.platform.api.data.GuarantorData; @@ -19,13 +15,12 @@ import org.mifosng.platform.api.data.LoanAccountData; import org.mifosng.platform.api.data.LoanChargeData; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanTransactionData; -import org.mifosng.platform.api.data.NoteData; import org.mifosng.platform.api.data.SavingAccountData; import org.mifosng.platform.api.data.SavingProductData; -import org.mifosng.platform.infrastructure.api.GoogleGsonSerializerHelper; import org.mifosplatform.commands.api.data.CommandSourceData; import org.mifosplatform.infrastructure.codes.data.CodeData; import org.mifosplatform.infrastructure.configuration.data.ConfigurationData; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.dataqueries.data.DatatableData; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.office.data.OfficeData; @@ -38,6 +33,10 @@ import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData; import org.mifosplatform.infrastructure.user.api.data.RoleData; import org.mifosplatform.infrastructure.user.api.data.RolePermissionsData; import org.mifosplatform.portfolio.charge.data.ChargeData; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.data.ClientIdentifierData; +import org.mifosplatform.portfolio.client.data.NoteData; import org.mifosplatform.portfolio.fund.data.FundData; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/GoogleGsonSerializerHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonSerializerHelper.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/GoogleGsonSerializerHelper.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonSerializerHelper.java index 30c05ceb7..8f0094acd 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/GoogleGsonSerializerHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonSerializerHelper.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.api; +package org.mifosplatform.infrastructure.core.api; import java.util.ArrayList; import java.util.HashSet; @@ -6,7 +6,7 @@ import java.util.Set; import org.joda.time.DateTime; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedParameterException; +import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException; import org.springframework.stereotype.Service; import com.google.gson.ExclusionStrategy; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JodaDateTimeAdapter.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JodaDateTimeAdapter.java similarity index 93% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JodaDateTimeAdapter.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JodaDateTimeAdapter.java index 9ece15bfc..23b71e79f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JodaDateTimeAdapter.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JodaDateTimeAdapter.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.api; +package org.mifosplatform.infrastructure.core.api; import java.lang.reflect.Type; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JodaLocalDateAdapter.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JodaLocalDateAdapter.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JodaLocalDateAdapter.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JodaLocalDateAdapter.java index 66b624205..2f5eae15c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JodaLocalDateAdapter.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JodaLocalDateAdapter.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.api; +package org.mifosplatform.infrastructure.core.api; import java.lang.reflect.Type; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JsonParserHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonParserHelper.java similarity index 99% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JsonParserHelper.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonParserHelper.java index 94748e50f..d32fc610c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/JsonParserHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/JsonParserHelper.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.api; +package org.mifosplatform.infrastructure.core.api; import java.math.BigDecimal; import java.text.DecimalFormat; @@ -14,8 +14,8 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.springframework.format.number.NumberFormatter; import com.google.gson.JsonArray; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/ParameterListExclusionStrategy.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ParameterListExclusionStrategy.java similarity index 95% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/ParameterListExclusionStrategy.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ParameterListExclusionStrategy.java index d4c4e1fb3..ecc3d6d0a 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/api/ParameterListExclusionStrategy.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/ParameterListExclusionStrategy.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.api; +package org.mifosplatform.infrastructure.core.api; import java.util.Set; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiDataConversionService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java similarity index 92% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiDataConversionService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java index ef89a8459..6c01775ca 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiDataConversionService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java @@ -1,8 +1,6 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.commands.ClientIdentifierCommand; import org.mifosng.platform.api.commands.DepositAccountCommand; import org.mifosng.platform.api.commands.DepositAccountWithdrawInterestCommand; import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; @@ -15,10 +13,8 @@ import org.mifosng.platform.api.commands.LoanApplicationCommand; import org.mifosng.platform.api.commands.LoanChargeCommand; import org.mifosng.platform.api.commands.LoanStateTransitionCommand; import org.mifosng.platform.api.commands.LoanTransactionCommand; -import org.mifosng.platform.api.commands.NoteCommand; import org.mifosng.platform.api.commands.SavingAccountCommand; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.api.data.ClientData; import org.mifosplatform.infrastructure.codes.command.CodeCommand; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand; @@ -30,6 +26,10 @@ import org.mifosplatform.infrastructure.user.command.RoleCommand; import org.mifosplatform.infrastructure.user.command.RolePermissionCommand; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; +import org.mifosplatform.portfolio.client.command.NoteCommand; +import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; @@ -95,7 +95,7 @@ public interface PortfolioApiDataConversionService { DepositAccountWithdrawInterestCommand convertJsonToDepositAccountWithdrawInterestCommand(Long resourceIdentifier, String json); - ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json); + ClientIdentifierCommand convertApiRequestJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json); CodeCommand convertApiRequestJsonToCodeCommand(Long resourceIdentifier, String json); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiDataConversionServiceImpl.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java index 3c9908ddf..aa7ff7efa 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; import java.lang.reflect.Type; import java.math.BigDecimal; @@ -18,8 +18,6 @@ import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.commands.ClientIdentifierCommand; import org.mifosng.platform.api.commands.DepositAccountCommand; import org.mifosng.platform.api.commands.DepositAccountWithdrawInterestCommand; import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; @@ -32,17 +30,14 @@ import org.mifosng.platform.api.commands.LoanApplicationCommand; import org.mifosng.platform.api.commands.LoanChargeCommand; import org.mifosng.platform.api.commands.LoanStateTransitionCommand; import org.mifosng.platform.api.commands.LoanTransactionCommand; -import org.mifosng.platform.api.commands.NoteCommand; import org.mifosng.platform.api.commands.SavingAccountCommand; import org.mifosng.platform.api.commands.SavingProductCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; -import org.mifosng.platform.infrastructure.api.JsonParserHelper; -import org.mifosng.platform.infrastructure.errorhandling.InvalidJsonException; -import org.mifosng.platform.infrastructure.errorhandling.UnsupportedParameterException; import org.mifosplatform.infrastructure.codes.command.CodeCommand; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; +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.office.command.BranchMoneyTransferCommand; import org.mifosplatform.infrastructure.office.command.OfficeCommand; import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand; @@ -52,6 +47,10 @@ import org.mifosplatform.infrastructure.user.command.RoleCommand; import org.mifosplatform.infrastructure.user.command.RolePermissionCommand; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; +import org.mifosplatform.portfolio.client.command.NoteCommand; +import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; import org.springframework.beans.factory.annotation.Autowired; @@ -1494,7 +1493,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo } @Override - public ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json) { + public ClientIdentifierCommand convertApiRequestJsonToClientIdentifierCommand(final Long resourceIdentifier, final Long clientId, final String json) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } Type typeOfMap = new TypeToken>() {}.getType(); @@ -1504,14 +1503,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo checkForUnsupportedParameters(requestMap, supportedParams); - Set modifiedParameters = new HashSet(); - - Long documentTypeId = extractLongParameter("documentTypeId", requestMap, modifiedParameters); - String documentKey = extractStringParameter("documentKey", requestMap, modifiedParameters); - String documentDescription = extractStringParameter("description", requestMap, modifiedParameters); - - return new ClientIdentifierCommand(modifiedParameters, resourceIdentifier, clientId, documentTypeId, documentKey, - documentDescription); + return this.portfolioCommandDeserializerService.deserializeClientIdentifierCommand(resourceIdentifier, clientId, json, false); } @Override diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java similarity index 95% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiJsonSerializerService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java index 057a0b53d..793e994af 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java @@ -1,15 +1,11 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; import java.util.Collection; import java.util.Set; -import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.data.ClientIdentifierData; import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositProductData; import org.mifosng.platform.api.data.DocumentData; -import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; import org.mifosng.platform.api.data.GroupData; import org.mifosng.platform.api.data.GuarantorData; @@ -17,12 +13,12 @@ import org.mifosng.platform.api.data.LoanAccountData; import org.mifosng.platform.api.data.LoanChargeData; import org.mifosng.platform.api.data.LoanScheduleData; import org.mifosng.platform.api.data.LoanTransactionData; -import org.mifosng.platform.api.data.NoteData; import org.mifosng.platform.api.data.SavingAccountData; import org.mifosng.platform.api.data.SavingProductData; import org.mifosplatform.commands.api.data.CommandSourceData; import org.mifosplatform.infrastructure.codes.data.CodeData; import org.mifosplatform.infrastructure.configuration.data.ConfigurationData; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.dataqueries.data.DatatableData; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.office.data.OfficeData; @@ -35,6 +31,10 @@ import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData; import org.mifosplatform.infrastructure.user.api.data.RoleData; import org.mifosplatform.infrastructure.user.api.data.RolePermissionsData; import org.mifosplatform.portfolio.charge.data.ChargeData; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.data.ClientIdentifierData; +import org.mifosplatform.portfolio.client.data.NoteData; import org.mifosplatform.portfolio.fund.data.FundData; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandDeerializerServiceGoogleGson.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandDeerializerServiceGoogleGson.java similarity index 82% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandDeerializerServiceGoogleGson.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandDeerializerServiceGoogleGson.java index a5adf5b82..12edd06c4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandDeerializerServiceGoogleGson.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandDeerializerServiceGoogleGson.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; import java.math.BigDecimal; import java.util.HashSet; @@ -7,11 +7,9 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.infrastructure.api.JsonParserHelper; -import org.mifosng.platform.infrastructure.errorhandling.InvalidJsonException; import org.mifosplatform.infrastructure.codes.command.CodeCommand; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; +import org.mifosplatform.infrastructure.core.exception.InvalidJsonException; import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand; import org.mifosplatform.infrastructure.office.command.OfficeCommand; import org.mifosplatform.infrastructure.staff.command.StaffCommand; @@ -20,6 +18,8 @@ import org.mifosplatform.infrastructure.user.command.RoleCommand; import org.mifosplatform.infrastructure.user.command.RolePermissionCommand; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; import org.springframework.stereotype.Service; @@ -31,8 +31,9 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; /** - * Implementation of {@link PortfolioCommandDeserializerService} that de-serializes - * JSON of commands into Java object representation using google-gson. + * Implementation of {@link PortfolioCommandDeserializerService} that + * de-serializes JSON of commands into Java object representation using + * google-gson. */ @Service public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCommandDeserializerService { @@ -61,7 +62,8 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo } @Override - public RolePermissionCommand deserializeRolePermissionCommand(final Long roleId, final String commandAsJson, final boolean makerCheckerApproval) { + public RolePermissionCommand deserializeRolePermissionCommand(final Long roleId, final String commandAsJson, + final boolean makerCheckerApproval) { if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); } final RolePermissionCommand command = gsonConverter.fromJson(commandAsJson, RolePermissionCommand.class); @@ -120,8 +122,8 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo } } - return new UserCommand(parametersPassedInRequest, makerCheckerApproval, userId, username, firstname, lastname, - password, repeatPassword, email, officeId, notSelectedRoles, roles); + return new UserCommand(parametersPassedInRequest, makerCheckerApproval, userId, username, firstname, lastname, password, + repeatPassword, email, officeId, notSelectedRoles, roles); } @Override @@ -204,11 +206,12 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo final Long toOfficeId = helper.extractLongNamed("toOfficeId", element, parametersPassedInRequest); final LocalDate transactionLocalDate = helper.extractLocalDateAsArrayNamed("transactionDate", element, parametersPassedInRequest); final String currencyCode = helper.extractStringNamed("currencyCode", element, parametersPassedInRequest); - final BigDecimal transactionAmount = helper.extractBigDecimalNamed("transactionAmount", element.getAsJsonObject(), Locale.US, parametersPassedInRequest); + final BigDecimal transactionAmount = helper.extractBigDecimalNamed("transactionAmount", element.getAsJsonObject(), Locale.US, + parametersPassedInRequest); final String description = helper.extractStringNamed("description", element, parametersPassedInRequest); - return new BranchMoneyTransferCommand(parametersPassedInRequest, makerCheckerApproval, fromOfficeId, toOfficeId, transactionLocalDate, currencyCode, - transactionAmount, description); + return new BranchMoneyTransferCommand(parametersPassedInRequest, makerCheckerApproval, fromOfficeId, toOfficeId, + transactionLocalDate, currencyCode, transactionAmount, description); } @Override @@ -226,8 +229,9 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo } @Override - public ChargeDefinitionCommand deserializeChargeDefinitionCommand(final Long chargeDefinitionId, final String commandAsJson, final boolean makerCheckerApproval) { - + public ChargeDefinitionCommand deserializeChargeDefinitionCommand(final Long chargeDefinitionId, final String commandAsJson, + final boolean makerCheckerApproval) { + if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); } final JsonParserHelper helper = new JsonParserHelper(); @@ -238,21 +242,22 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo final String name = helper.extractStringNamed("name", element, parametersPassedInRequest); final String currencyCode = helper.extractStringNamed("currencyCode", element, parametersPassedInRequest); final BigDecimal amount = helper.extractBigDecimalNamed("amount", element.getAsJsonObject(), Locale.US, parametersPassedInRequest); - + final Integer chargeTimeType = helper.extractIntegerNamed("chargeTimeType", element, Locale.US, parametersPassedInRequest); final Integer chargeAppliesTo = helper.extractIntegerNamed("chargeAppliesTo", element, Locale.US, parametersPassedInRequest); - final Integer chargeCalculationType = helper.extractIntegerNamed("chargeCalculationType", element, Locale.US, parametersPassedInRequest); - + final Integer chargeCalculationType = helper.extractIntegerNamed("chargeCalculationType", element, Locale.US, + parametersPassedInRequest); + final Boolean penalty = helper.extractBooleanNamed("penalty", element, parametersPassedInRequest); final Boolean active = helper.extractBooleanNamed("active", element, parametersPassedInRequest); - - return new ChargeDefinitionCommand(parametersPassedInRequest, makerCheckerApproval, chargeDefinitionId, name, amount, currencyCode, chargeTimeType, chargeAppliesTo, - chargeCalculationType, penalty, active); + + return new ChargeDefinitionCommand(parametersPassedInRequest, makerCheckerApproval, chargeDefinitionId, name, amount, currencyCode, + chargeTimeType, chargeAppliesTo, chargeCalculationType, penalty, active); } @Override public ClientCommand deserializeClientCommand(final Long clientId, final String commandAsJson, final boolean makerCheckerApproval) { - + if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); } final JsonParserHelper helper = new JsonParserHelper(); @@ -267,37 +272,43 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo final String clientOrBusinessName = helper.extractStringNamed("clientOrBusinessName", element, parametersPassedInRequest); final LocalDate joiningDate = helper.extractLocalDateAsArrayNamed("joiningDate", element, parametersPassedInRequest); - return new ClientCommand(parametersPassedInRequest, clientId, externalId, firstname, lastname, clientOrBusinessName, - officeId, joiningDate, makerCheckerApproval); + return new ClientCommand(parametersPassedInRequest, clientId, externalId, firstname, lastname, clientOrBusinessName, officeId, + joiningDate, makerCheckerApproval); } @Override - public LoanProductCommand deserializeLoanProductCommand(final Long loanProductId, final String commandAsJson, final boolean makerCheckerApproval) { - + public LoanProductCommand deserializeLoanProductCommand(final Long loanProductId, 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 parametersPassedInRequest = new HashSet(); - + final String name = helper.extractStringNamed("name", element, parametersPassedInRequest); final String description = helper.extractStringNamed("description", element, parametersPassedInRequest); final Long fundId = helper.extractLongNamed("fundId", element, parametersPassedInRequest); - final Long transactionProcessingStrategyId = helper - .extractLongNamed("transactionProcessingStrategyId", element, parametersPassedInRequest); + final Long transactionProcessingStrategyId = helper.extractLongNamed("transactionProcessingStrategyId", element, + parametersPassedInRequest); final String currencyCode = helper.extractStringNamed("currencyCode", element, parametersPassedInRequest); final Integer digitsAfterDecimal = helper.extractIntegerNamed("digitsAfterDecimal", element, Locale.US, parametersPassedInRequest); - final BigDecimal principal = helper.extractBigDecimalNamed("principal", element.getAsJsonObject(), Locale.US, parametersPassedInRequest); - final BigDecimal inArrearsTolerance = helper.extractBigDecimalNamed("inArrearsTolerance", element.getAsJsonObject(), Locale.US, parametersPassedInRequest); - final BigDecimal interestRatePerPeriod = helper.extractBigDecimalNamed("interestRatePerPeriod", element.getAsJsonObject(), Locale.US, parametersPassedInRequest); + final BigDecimal principal = helper.extractBigDecimalNamed("principal", element.getAsJsonObject(), Locale.US, + parametersPassedInRequest); + final BigDecimal inArrearsTolerance = helper.extractBigDecimalNamed("inArrearsTolerance", element.getAsJsonObject(), Locale.US, + parametersPassedInRequest); + final BigDecimal interestRatePerPeriod = helper.extractBigDecimalNamed("interestRatePerPeriod", element.getAsJsonObject(), + Locale.US, parametersPassedInRequest); final Integer repaymentEvery = helper.extractIntegerNamed("repaymentEvery", element, Locale.US, parametersPassedInRequest); final Integer numberOfRepayments = helper.extractIntegerNamed("numberOfRepayments", element, Locale.US, parametersPassedInRequest); - final Integer repaymentFrequencyType = helper.extractIntegerNamed("repaymentFrequencyType", element, Locale.US, parametersPassedInRequest); - final Integer interestRateFrequencyType = helper.extractIntegerNamed("interestRateFrequencyType", element, Locale.US, parametersPassedInRequest); + final Integer repaymentFrequencyType = helper.extractIntegerNamed("repaymentFrequencyType", element, Locale.US, + parametersPassedInRequest); + final Integer interestRateFrequencyType = helper.extractIntegerNamed("interestRateFrequencyType", element, Locale.US, + parametersPassedInRequest); final Integer amortizationType = helper.extractIntegerNamed("amortizationType", element, Locale.US, parametersPassedInRequest); final Integer interestType = helper.extractIntegerNamed("interestType", element, Locale.US, parametersPassedInRequest); final Integer interestCalculationPeriodType = helper.extractIntegerNamed("interestCalculationPeriodType", element, Locale.US, @@ -316,8 +327,33 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo } } - return new LoanProductCommand(parametersPassedInRequest, makerCheckerApproval, loanProductId, name, description, fundId, transactionProcessingStrategyId, - currencyCode, digitsAfterDecimal, principal, inArrearsTolerance, numberOfRepayments, repaymentEvery, interestRatePerPeriod, - repaymentFrequencyType, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, charges); + return new LoanProductCommand(parametersPassedInRequest, makerCheckerApproval, loanProductId, name, description, fundId, + transactionProcessingStrategyId, currencyCode, digitsAfterDecimal, principal, inArrearsTolerance, numberOfRepayments, + repaymentEvery, interestRatePerPeriod, repaymentFrequencyType, interestRateFrequencyType, amortizationType, interestType, + interestCalculationPeriodType, charges); + } + + @Override + public ClientIdentifierCommand deserializeClientIdentifierCommand(final Long clientIdentifierId, final Long clientId, + 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 parametersPassedInRequest = new HashSet(); + + Long actualClientId = clientId; + final Long clientIdInternal = helper.extractLongNamed("clientId", element, parametersPassedInRequest); + if (clientId != null) { + actualClientId = clientIdInternal; + } + final Long documentTypeId = helper.extractLongNamed("documentTypeId", element, parametersPassedInRequest); + final String documentKey = helper.extractStringNamed("documentKey", element, parametersPassedInRequest); + final String documentDescription = helper.extractStringNamed("documentDescription", element, parametersPassedInRequest); + + return new ClientIdentifierCommand(parametersPassedInRequest, makerCheckerApproval, clientIdentifierId, actualClientId, + documentTypeId, documentKey, documentDescription); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandDeserializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandDeserializerService.java similarity index 84% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandDeserializerService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandDeserializerService.java index 7f4abea87..07f7604f1 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandDeserializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandDeserializerService.java @@ -1,6 +1,5 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; -import org.mifosng.platform.api.commands.ClientCommand; import org.mifosplatform.infrastructure.codes.command.CodeCommand; import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand; import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand; @@ -11,6 +10,8 @@ import org.mifosplatform.infrastructure.user.command.RoleCommand; import org.mifosplatform.infrastructure.user.command.RolePermissionCommand; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; @@ -50,5 +51,7 @@ public interface PortfolioCommandDeserializerService { ClientCommand deserializeClientCommand(Long clientId, String commandAsJson, boolean makerCheckerApproval); - LoanProductCommand deserializeLoanProductCommand(Long resourceId, String json, boolean b); + LoanProductCommand deserializeLoanProductCommand(Long loanProductId, String commandAsJson, boolean makerCheckerApproval); + + ClientIdentifierCommand deserializeClientIdentifierCommand(Long clientIdentifierId, Long clientId, String commandAsJson, boolean makerCheckerApproval); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandSerializerService.java similarity index 83% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandSerializerService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandSerializerService.java index c1314b396..2cd3f4c24 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandSerializerService.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; /** * Service for serializing commands into another format. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandSerializerServiceJson.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandSerializerServiceJson.java similarity index 88% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandSerializerServiceJson.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandSerializerServiceJson.java index 3a6ed6ce2..55792a2e3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/PortfolioCommandSerializerServiceJson.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioCommandSerializerServiceJson.java @@ -1,8 +1,7 @@ -package org.mifosng.platform.api.infrastructure; +package org.mifosplatform.infrastructure.core.api; import java.util.HashSet; -import org.mifosng.platform.infrastructure.api.GoogleGsonSerializerHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiErrorMessageArg.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiErrorMessageArg.java similarity index 89% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiErrorMessageArg.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiErrorMessageArg.java index dda4de0ae..673c70899 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiErrorMessageArg.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiErrorMessageArg.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.infrastructure.core.data; public class ApiErrorMessageArg { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiGlobalErrorResponse.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiGlobalErrorResponse.java similarity index 99% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiGlobalErrorResponse.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiGlobalErrorResponse.java index 5c139f19b..825f66a02 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiGlobalErrorResponse.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiGlobalErrorResponse.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.infrastructure.core.data; import java.util.ArrayList; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiParameterError.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiParameterError.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiParameterError.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiParameterError.java index e00358ce7..e59e70973 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ApiParameterError.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/ApiParameterError.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.infrastructure.core.data; import java.util.ArrayList; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java new file mode 100644 index 000000000..fd8baedf5 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/DataValidatorBuilder.java @@ -0,0 +1,326 @@ +package org.mifosplatform.infrastructure.core.data; + +import java.math.BigDecimal; +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.springframework.util.ObjectUtils; + +public class DataValidatorBuilder { + + private final List dataValidationErrors; + private String resource; + private String parameter; + private Object value; + private boolean ignoreNullValue = false; + + public DataValidatorBuilder(List dataValidationErrors) { + this.dataValidationErrors = dataValidationErrors; + } + + public DataValidatorBuilder reset() { + return new DataValidatorBuilder(dataValidationErrors).resource(resource); + } + + public DataValidatorBuilder resource(final String resource) { + this.resource = resource; + return this; + } + + public DataValidatorBuilder parameter(final String parameter) { + this.parameter = parameter; + return this; + } + + public DataValidatorBuilder value(Object value) { + this.value = value; + return this; + } + + public DataValidatorBuilder ignoreIfNull() { + this.ignoreNullValue = true; + return this; + } + + public DataValidatorBuilder andNotBlank(String linkedParameterName, String linkedValue) { + if (value == null && linkedValue == null && ignoreNullValue) { return this; } + + if (StringUtils.isBlank(linkedValue)) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".") + .append(linkedParameterName).append(".cannot.be.empty.when.").append(parameter).append(".is.populated"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName) + .append(" cannot be empty when ").append(parameter).append(" is populated."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + linkedParameterName, linkedValue, value); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder equalToParameter(String linkedParameterName, Object linkedValue) { + if (value == null && linkedValue == null && ignoreNullValue) { return this; } + + if (value != null && !value.equals(linkedValue)) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".") + .append(linkedParameterName).append(".not.equal.to.").append(parameter); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName) + .append(" is not equal to ").append(parameter).append("."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + linkedParameterName, linkedValue, value); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder notSameAsParameter(String linkedParameterName, Object linkedValue) { + if (value == null && linkedValue == null && ignoreNullValue) { return this; } + + if (value != null && value.equals(linkedValue)) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".") + .append(linkedParameterName).append(".same.as.").append(parameter); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is same as ") + .append(parameter).append("."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + linkedParameterName, linkedValue, value); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder trueOrFalseRequired(boolean trueOfFalseFieldProvided) { + if (!trueOfFalseFieldProvided && !ignoreNullValue) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".must.be.true.or.false"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append( + " must be set as true or false."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder notNull() { + if (value == null && !ignoreNullValue) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".cannot.be.blank"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be blank."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder notBlank() { + if (value == null && ignoreNullValue) { return this; } + + if (value == null || StringUtils.isBlank(value.toString())) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".cannot.be.blank"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be blank."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder notExceedingLengthOf(Integer maxLength) { + if (value == null && ignoreNullValue) { return this; } + + if (value != null && value.toString().trim().length() > maxLength) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".exceeds.max.length"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" exceeds max length of ") + .append(maxLength).append("."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter, maxLength, value.toString()); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder inMinMaxRange(Integer min, Integer max) { + if (value == null && ignoreNullValue) { return this; } + + if (value != null) { + Integer number = Integer.valueOf(value.toString()); + if (number < min || number > max) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".is.not.within.expected.range"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be between ") + .append(min).append(" and ").append(max).append("."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, number, min, max); + dataValidationErrors.add(error); + } + } + return this; + } + + public DataValidatorBuilder positiveAmount() { + if (value == null && ignoreNullValue) { return this; } + + if (value != null) { + BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString())); + if (number.compareTo(BigDecimal.ZERO) <= 0) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".not.greater.than.zero"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append( + " must be greater than 0."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, number, 0); + dataValidationErrors.add(error); + } + } + return this; + } + + public DataValidatorBuilder zeroOrPositiveAmount() { + if (value == null && ignoreNullValue) { return this; } + + if (value != null) { + BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString())); + if (number.compareTo(BigDecimal.ZERO) < 0) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".not.zero.or.greater"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append( + " must be greater than or equal to 0."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, number, 0); + dataValidationErrors.add(error); + } + } + return this; + } + + public DataValidatorBuilder integerGreaterThanZero() { + if (value == null && ignoreNullValue) { return this; } + + if (value != null) { + Integer number = Integer.valueOf(value.toString()); + if (number < 1) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".not.greater.than.zero"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append( + " must be greater than 0."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, number, 0); + dataValidationErrors.add(error); + } + } + return this; + } + + public DataValidatorBuilder longGreaterThanZero() { + if (value == null && ignoreNullValue) { return this; } + + if (value != null) { + Long number = Long.valueOf(value.toString()); + if (number < 1) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".not.greater.than.zero"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append( + " must be greater than 0."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, number, 0); + dataValidationErrors.add(error); + } + } + return this; + } + + public DataValidatorBuilder arrayNotEmpty() { + if (value == null && ignoreNullValue) { return this; } + + Object[] array = (Object[]) value; + if (ObjectUtils.isEmpty(array)) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".cannot.be.empty"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append( + " cannot be empty. You must select at least one."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder anyOfNotNull(Object... object) { + boolean hasData = false; + for (Object obj : object) { + if (obj != null) { + hasData = true; + break; + } + } + + if (!hasData) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".no.parameters.for.update"); + StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + "id"); + dataValidationErrors.add(error); + } + return this; + } + + public DataValidatorBuilder inValidValue(String parameterValueCode, Object invalidValue) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".invalid.").append(parameterValueCode); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" has an invalid value."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter, invalidValue); + dataValidationErrors.add(error); + return this; + } + + public DataValidatorBuilder mustBeBlankWhenParameterProvided(String parameterName, Object parameterValue) { + if (value == null && ignoreNullValue) { return this; } + + if (value == null && parameterValue != null) { return this; } + + if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null + && StringUtils.isNotBlank(parameterValue.toString())) { return this; } + + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter) + .append(" cannot also be provided when ").append(parameterName).append(" is populated."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameter, value, parameterName, parameterValue); + dataValidationErrors.add(error); + return this; + } + + public DataValidatorBuilder comapareMinimumAndMaximumAmounts(BigDecimal minimumBalance, BigDecimal maximumBalance) { + if (minimumBalance != null && maximumBalance != null) + if (maximumBalance.compareTo(minimumBalance) == -1) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".is.not.within.expected.range"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ").append(minimumBalance) + .append(" should less than maximum amount ").append(maximumBalance).append("."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, minimumBalance, maximumBalance); + dataValidationErrors.add(error); + return this; + } + return this; + } + + public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(BigDecimal min, BigDecimal max) { + if (min != null && max != null) + if (max.compareTo(min) == -1) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter) + .append(".is.not.within.expected.range"); + StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min) + .append(" should less than max number ").append(max).append("."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), + defaultEnglishMessage.toString(), parameter, min, max); + dataValidationErrors.add(error); + return this; + } + return this; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/EntityIdentifier.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/EntityIdentifier.java similarity index 95% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/EntityIdentifier.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/EntityIdentifier.java index 643674248..8b514f12f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/EntityIdentifier.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/EntityIdentifier.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.infrastructure.core.data; /** * Represents the successful result of an REST API call. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/EnumOptionData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/EnumOptionData.java similarity index 89% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/EnumOptionData.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/EnumOptionData.java index f9b1406cf..a30d9b185 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/EnumOptionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/data/EnumOptionData.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.infrastructure.core.data; public class EnumOptionData { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/AbstractAuditableCustom.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/AbstractAuditableCustom.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/AbstractAuditableCustom.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/AbstractAuditableCustom.java index 1bc0b6d14..93166241c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/AbstractAuditableCustom.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/AbstractAuditableCustom.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.domain; import java.io.Serializable; import java.util.Date; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/AuditorAwareImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/AuditorAwareImpl.java similarity index 95% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/AuditorAwareImpl.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/AuditorAwareImpl.java index 2928be5d8..eb4cb984b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/AuditorAwareImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/AuditorAwareImpl.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.domain; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.infrastructure.user.domain.AppUserRepository; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/Base64EncodedImage.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/Base64EncodedImage.java new file mode 100644 index 000000000..5868767ba --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/Base64EncodedImage.java @@ -0,0 +1,20 @@ +package org.mifosplatform.infrastructure.core.domain; + +public class Base64EncodedImage { + + private final String base64EncodedString; + private final String fileExtension; + + public Base64EncodedImage(String base64EncodedString, String fileExtension) { + this.base64EncodedString = base64EncodedString; + this.fileExtension = fileExtension; + } + + public String getBase64EncodedString() { + return base64EncodedString; + } + + public String getFileExtension() { + return fileExtension; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/DefaultPlatformPasswordEncoder.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/DefaultPlatformPasswordEncoder.java similarity index 88% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/DefaultPlatformPasswordEncoder.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/DefaultPlatformPasswordEncoder.java index 5d1107e91..4b9f94059 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/DefaultPlatformPasswordEncoder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/DefaultPlatformPasswordEncoder.java @@ -1,6 +1,7 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.domain; import org.mifosplatform.infrastructure.security.domain.PlatformUser; +import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.security.authentication.dao.SaltSource; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/EmailDetail.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/EmailDetail.java similarity index 92% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/EmailDetail.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/EmailDetail.java index 6646c1eb8..49b658109 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/EmailDetail.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/EmailDetail.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.domain; public class EmailDetail { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/JdbcSupport.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/JdbcSupport.java similarity index 97% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/JdbcSupport.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/JdbcSupport.java index f055eda61..1eecbb491 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/JdbcSupport.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/JdbcSupport.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.domain; import java.math.BigDecimal; import java.sql.ResultSet; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/MifosPlatformTenant.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/MifosPlatformTenant.java similarity index 95% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/MifosPlatformTenant.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/MifosPlatformTenant.java index e44cfaf52..72f9148b0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/MifosPlatformTenant.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/domain/MifosPlatformTenant.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.domain; public class MifosPlatformTenant { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformDomainRuleException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/AbstractPlatformDomainRuleException.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformDomainRuleException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/AbstractPlatformDomainRuleException.java index 4aee53abb..f29836a01 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformDomainRuleException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/AbstractPlatformDomainRuleException.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.core.exception; /** * A {@link RuntimeException} thrown when valid api request end up violating diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformResourceNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/AbstractPlatformResourceNotFoundException.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformResourceNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/AbstractPlatformResourceNotFoundException.java index d05d2c722..952f30356 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformResourceNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/AbstractPlatformResourceNotFoundException.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.core.exception; /** * A {@link RuntimeException} thrown when resources that are queried for are not diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/ImageDataURLNotValidException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/ImageDataURLNotValidException.java new file mode 100644 index 000000000..56e238afb --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/ImageDataURLNotValidException.java @@ -0,0 +1,8 @@ +package org.mifosplatform.infrastructure.core.exception; + +public class ImageDataURLNotValidException extends AbstractPlatformDomainRuleException { + + public ImageDataURLNotValidException() { + super("error.msg.dataURL.save", "Only GIF, PNG and JPEG Data URL's are allowed"); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/ImageUploadException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/ImageUploadException.java new file mode 100644 index 000000000..ddfd25fad --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/ImageUploadException.java @@ -0,0 +1,8 @@ +package org.mifosplatform.infrastructure.core.exception; + +public class ImageUploadException extends AbstractPlatformDomainRuleException { + + public ImageUploadException() { + super("error.msg.image.type.upload", "Only image files of type GIF,PNG and JPG are allowed "); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidJsonException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/InvalidJsonException.java similarity index 50% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidJsonException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/InvalidJsonException.java index 597ee9292..b2e79a61c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/InvalidJsonException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/InvalidJsonException.java @@ -1,9 +1,9 @@ -package org.mifosng.platform.infrastructure.errorhandling; - +package org.mifosplatform.infrastructure.core.exception; /** - * A {@link RuntimeException} that is thrown in the case where invalid JSON is sent in the body of the request to the platform api. + * A {@link RuntimeException} that is thrown in the case where invalid JSON is + * sent in the body of the request to the platform api. */ public class InvalidJsonException extends RuntimeException { - // + // } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformApiDataValidationException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformApiDataValidationException.java new file mode 100644 index 000000000..9afcbfa76 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformApiDataValidationException.java @@ -0,0 +1,31 @@ +package org.mifosplatform.infrastructure.core.exception; + +import java.util.List; + +import org.mifosplatform.infrastructure.core.data.ApiParameterError; + +public class PlatformApiDataValidationException extends RuntimeException { + + private final String globalisationMessageCode; + private final String defaultUserMessage; + private final List errors; + + public PlatformApiDataValidationException(final String globalisationMessageCode, final String defaultUserMessage, + List errors) { + this.globalisationMessageCode = globalisationMessageCode; + this.defaultUserMessage = defaultUserMessage; + this.errors = errors; + } + + public String getGlobalisationMessageCode() { + return globalisationMessageCode; + } + + public String getDefaultUserMessage() { + return defaultUserMessage; + } + + public List getErrors() { + return errors; + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformDataIntegrityException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformDataIntegrityException.java new file mode 100644 index 000000000..443134362 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformDataIntegrityException.java @@ -0,0 +1,45 @@ +package org.mifosplatform.infrastructure.core.exception; + +/** + * A {@link RuntimeException} thrown when data integrity problems happen due to + * state modifying actions. + */ +public class PlatformDataIntegrityException extends RuntimeException { + + private final String globalisationMessageCode; + private final String defaultUserMessage; + private final String parameterName; + private final Object[] defaultUserMessageArgs; + + public PlatformDataIntegrityException(final String globalisationMessageCode, final String defaultUserMessage, + final Object... defaultUserMessageArgs) { + this.globalisationMessageCode = globalisationMessageCode; + this.defaultUserMessage = defaultUserMessage; + this.parameterName = ""; + this.defaultUserMessageArgs = defaultUserMessageArgs; + } + + public PlatformDataIntegrityException(final String globalisationMessageCode, final String defaultUserMessage, + final String parameterName, final Object... defaultUserMessageArgs) { + this.globalisationMessageCode = globalisationMessageCode; + this.defaultUserMessage = defaultUserMessage; + this.parameterName = parameterName; + this.defaultUserMessageArgs = defaultUserMessageArgs; + } + + public String getGlobalisationMessageCode() { + return globalisationMessageCode; + } + + public String getDefaultUserMessage() { + return defaultUserMessage; + } + + public Object[] getDefaultUserMessageArgs() { + return defaultUserMessageArgs; + } + + public String getParameterName() { + return parameterName; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformInternalServerException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformInternalServerException.java new file mode 100644 index 000000000..e6532cfe5 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/PlatformInternalServerException.java @@ -0,0 +1,29 @@ +package org.mifosplatform.infrastructure.core.exception; + +/** + * A {@link RuntimeException} thrown when unexpected server side errors happen. + */ +public class PlatformInternalServerException extends RuntimeException { + + private final String globalisationMessageCode; + private final String defaultUserMessage; + private final Object[] defaultUserMessageArgs; + + public PlatformInternalServerException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) { + this.globalisationMessageCode = globalisationMessageCode; + this.defaultUserMessage = defaultUserMessage; + this.defaultUserMessageArgs = defaultUserMessageArgs; + } + + public String getGlobalisationMessageCode() { + return globalisationMessageCode; + } + + public String getDefaultUserMessage() { + return defaultUserMessage; + } + + public Object[] getDefaultUserMessageArgs() { + return defaultUserMessageArgs; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/UnrecognizedQueryParamException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/UnrecognizedQueryParamException.java new file mode 100644 index 000000000..81efcb36e --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/UnrecognizedQueryParamException.java @@ -0,0 +1,20 @@ +package org.mifosplatform.infrastructure.core.exception; + +public class UnrecognizedQueryParamException extends RuntimeException { + + private final String queryParamKey; + private final String queryParamValue; + + public UnrecognizedQueryParamException(String queryParamKey, String queryParamValue) { + this.queryParamKey = queryParamKey; + this.queryParamValue = queryParamValue; + } + + public String getQueryParamKey() { + return queryParamKey; + } + + public String getQueryParamValue() { + return queryParamValue; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/UnsupportedParameterException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/UnsupportedParameterException.java new file mode 100644 index 000000000..64a233463 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exception/UnsupportedParameterException.java @@ -0,0 +1,20 @@ +package org.mifosplatform.infrastructure.core.exception; + +import java.util.List; + +/** + * A {@link RuntimeException} that is thrown in the case where invalid + * parameters are sent in the body of the request to the platform api. + */ +public class UnsupportedParameterException extends RuntimeException { + + private final List unsupportedParameters; + + public UnsupportedParameterException(List unsupportedParameters) { + this.unsupportedParameters = unsupportedParameters; + } + + public List getUnsupportedParameters() { + return unsupportedParameters; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/AccessDeniedExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/AccessDeniedExceptionMapper.java new file mode 100644 index 000000000..de2d61a8a --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/AccessDeniedExceptionMapper.java @@ -0,0 +1,33 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.springframework.context.annotation.Scope; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link AccessDeniedException} thrown by + * platform into a HTTP API friendly format. + * + * The {@link AccessDeniedException} is thrown by spring security on platform + * when an attempt is made to use functionality for which the user does have + * sufficient privileges. + */ +@Provider +@Component +@Scope("singleton") +public class AccessDeniedExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(@SuppressWarnings("unused") AccessDeniedException exception) { + // Status code 403 really reads as: + // "Authenticated - but not authorized": + return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized()).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/BadCredentialsExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/BadCredentialsExceptionMapper.java similarity index 51% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/BadCredentialsExceptionMapper.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/BadCredentialsExceptionMapper.java index 4604df0b5..8fa8615ae 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/errorhandling/BadCredentialsExceptionMapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/BadCredentialsExceptionMapper.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure.errorhandling; +package org.mifosplatform.infrastructure.core.exceptionmapper; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -6,23 +6,27 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; -import org.mifosng.platform.api.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; import org.springframework.context.annotation.Scope; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.stereotype.Component; /** - * An {@link ExceptionMapper} to map {@link BadCredentialsException} thrown by platform during authentication into a HTTP API friendly format. + * An {@link ExceptionMapper} to map {@link BadCredentialsException} thrown by + * platform during authentication into a HTTP API friendly format. * - * The {@link BadCredentialsException} is thrown by spring security on platform when an attempt is made to authenticate using invalid username/password credentials. + * The {@link BadCredentialsException} is thrown by spring security on platform + * when an attempt is made to authenticate using invalid username/password + * credentials. */ @Provider @Component @Scope("singleton") public class BadCredentialsExceptionMapper implements ExceptionMapper { - @Override - public Response toResponse(@SuppressWarnings("unused") BadCredentialsException exception) { - return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON).build(); - } + @Override + public Response toResponse(@SuppressWarnings("unused") BadCredentialsException exception) { + return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON) + .build(); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/InvalidJsonExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/InvalidJsonExceptionMapper.java new file mode 100644 index 000000000..b09947377 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/InvalidJsonExceptionMapper.java @@ -0,0 +1,33 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.exception.InvalidJsonException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link InvalidJsonException} thrown by + * platform into a HTTP API friendly format. + */ +@Provider +@Component +@Scope("singleton") +public class InvalidJsonExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(@SuppressWarnings("unused") final InvalidJsonException exception) { + + String globalisationMessageCode = "error.msg.invalid.request.body"; + String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing."; + + ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); + + return Response.status(Status.BAD_REQUEST).entity(error).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/InvalidTenantIdentifierExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/InvalidTenantIdentifierExceptionMapper.java new file mode 100644 index 000000000..d3c954610 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/InvalidTenantIdentifierExceptionMapper.java @@ -0,0 +1,31 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link InvalidTenantIdentiferException} + * thrown by platform during authentication into a HTTP API friendly format. + * + * The {@link InvalidTenantIdentiferException} is thrown by spring security on + * platform when a request contains an invalid tenant identifier. + */ +@Provider +@Component +@Scope("singleton") +public class InvalidTenantIdentifierExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(@SuppressWarnings("unused") final InvalidTenantIdentiferException e) { + return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.invalidTenantIdentifier()) + .type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/JsonSyntaxExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/JsonSyntaxExceptionMapper.java new file mode 100644 index 000000000..03e6b52b7 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/JsonSyntaxExceptionMapper.java @@ -0,0 +1,34 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import com.google.gson.JsonSyntaxException; + +/** + * An {@link ExceptionMapper} to map {@link JsonSyntaxException} thrown by + * platform into a HTTP API friendly format. + */ +@Provider +@Component +@Scope("singleton") +public class JsonSyntaxExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(final JsonSyntaxException exception) { + + String globalisationMessageCode = "error.msg.invalid.request.body"; + String defaultUserMessage = "The JSON syntax provided in the body of the request is invalid: " + exception.getMessage(); + + ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); + + return Response.status(Status.BAD_REQUEST).entity(error).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/MalformedJsonExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/MalformedJsonExceptionMapper.java new file mode 100644 index 000000000..d66c504d0 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/MalformedJsonExceptionMapper.java @@ -0,0 +1,34 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import com.google.gson.stream.MalformedJsonException; + +/** + * An {@link ExceptionMapper} to map {@link MalformedJsonException} thrown by + * platform into a HTTP API friendly format. + */ +@Provider +@Component +@Scope("singleton") +public class MalformedJsonExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(@SuppressWarnings("unused") final MalformedJsonException exception) { + + String globalisationMessageCode = "error.msg.invalid.request.body"; + String defaultUserMessage = "The JSON provided in the body of the request is invalid or missing."; + + ApiParameterError error = ApiParameterError.generalError(globalisationMessageCode, defaultUserMessage); + + return Response.status(Status.BAD_REQUEST).entity(error).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/NoAuthorizationExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/NoAuthorizationExceptionMapper.java new file mode 100644 index 000000000..843721bea --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/NoAuthorizationExceptionMapper.java @@ -0,0 +1,32 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link NoAuthorizationException} thrown by + * platform into a HTTP API friendly format. + * + * The {@link NoAuthorizationException} is thrown on platform when an attempt is + * made to use functionality for which the user does have sufficient privileges. + */ +@Provider +@Component +@Scope("singleton") +public class NoAuthorizationExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(@SuppressWarnings("unused") NoAuthorizationException exception) { + // Status code 403 really reads as: + // "Authenticated - but not authorized": + return Response.status(Status.FORBIDDEN).entity(ApiGlobalErrorResponse.unAuthorized()).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformApiDataValidationExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformApiDataValidationExceptionMapper.java new file mode 100644 index 000000000..af3b3d443 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformApiDataValidationExceptionMapper.java @@ -0,0 +1,34 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link PlatformApiDataValidationException} + * thrown by platform into a HTTP API friendly format. + * + * The {@link PlatformApiDataValidationException} is typically thrown in data + * validation of the parameters passed in with an api request. + */ +@Provider +@Component +@Scope("singleton") +public class PlatformApiDataValidationExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(PlatformApiDataValidationException exception) { + + ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.badClientRequest(exception.getGlobalisationMessageCode(), + exception.getDefaultUserMessage(), exception.getErrors()); + + return Response.status(Status.BAD_REQUEST).entity(dataIntegrityError).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformDataIntegrityExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformDataIntegrityExceptionMapper.java new file mode 100644 index 000000000..7a8d64999 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformDataIntegrityExceptionMapper.java @@ -0,0 +1,34 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link PlatformDataIntegrityException} + * thrown by platform into a HTTP API friendly format. + * + * The {@link PlatformDataIntegrityException} is thrown when modifying api call + * result in data integrity checks to be fired. + */ +@Provider +@Component +@Scope("singleton") +public class PlatformDataIntegrityExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(PlatformDataIntegrityException exception) { + + ApiGlobalErrorResponse dataIntegrityError = ApiGlobalErrorResponse.dataIntegrityError(exception.getGlobalisationMessageCode(), + exception.getDefaultUserMessage(), exception.getParameterName(), exception.getDefaultUserMessageArgs()); + + return Response.status(Status.FORBIDDEN).entity(dataIntegrityError).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformDomainRuleExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformDomainRuleExceptionMapper.java new file mode 100644 index 000000000..a97bce0d0 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformDomainRuleExceptionMapper.java @@ -0,0 +1,35 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link AbstractPlatformDomainRuleException} + * thrown by platform into a HTTP API friendly format. + * + * The {@link AbstractPlatformDomainRuleException} is thrown when an api call + * results is some internal business/domain logic been violated. + */ +@Provider +@Component +@Scope("singleton") +public class PlatformDomainRuleExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(AbstractPlatformDomainRuleException exception) { + + ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.domainRuleViolation(exception.getGlobalisationMessageCode(), + exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); + // request understood but not carried out due to it violating some + // domain/business logic + return Response.status(Status.FORBIDDEN).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformInternalServerExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformInternalServerExceptionMapper.java new file mode 100644 index 000000000..ede0df59d --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformInternalServerExceptionMapper.java @@ -0,0 +1,33 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.exception.PlatformInternalServerException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link PlatformInternalServerException} + * thrown by platform into a HTTP API friendly format. + * + * The {@link PlatformInternalServerException} is thrown when an api call + * results in unexpected server side exceptions. + */ +@Provider +@Component +@Scope("singleton") +public class PlatformInternalServerExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(PlatformInternalServerException exception) { + + ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(), + exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); + return Response.status(Status.INTERNAL_SERVER_ERROR).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformResourceNotFoundExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformResourceNotFoundExceptionMapper.java new file mode 100644 index 000000000..978722ab2 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/PlatformResourceNotFoundExceptionMapper.java @@ -0,0 +1,34 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map + * {@link AbstractPlatformResourceNotFoundException} thrown by platform into a + * HTTP API friendly format. + * + * The {@link AbstractPlatformResourceNotFoundException} is thrown when an api + * call for a resource that is expected to exist does not. + */ +@Provider +@Component +@Scope("singleton") +public class PlatformResourceNotFoundExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(AbstractPlatformResourceNotFoundException exception) { + + ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(), + exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); + return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnAuthenticatedUserExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnAuthenticatedUserExceptionMapper.java new file mode 100644 index 000000000..3ee25bf90 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnAuthenticatedUserExceptionMapper.java @@ -0,0 +1,29 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.user.exception.UnAuthenticatedUserException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link UnAuthenticatedUserException} thrown + * by platform into a HTTP API friendly format. + */ +@Provider +@Component +@Scope("singleton") +public class UnAuthenticatedUserExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(@SuppressWarnings("unused") UnAuthenticatedUserException exception) { + // Status code 401 really reads as: "Unauthenticated": + return Response.status(Status.UNAUTHORIZED).entity(ApiGlobalErrorResponse.unAuthenticated()).type(MediaType.APPLICATION_JSON) + .build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnrecognizedQueryParamExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnrecognizedQueryParamExceptionMapper.java new file mode 100644 index 000000000..15ab0691a --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnrecognizedQueryParamExceptionMapper.java @@ -0,0 +1,50 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link UnrecognizedQueryParamException} + * thrown by platform into a HTTP API friendly format. + * + * The {@link UnrecognizedQueryParamException} is typically thrown when a + * parameter is passed during and post or put that is not expected. + */ +@Provider +@Component +@Scope("singleton") +public class UnrecognizedQueryParamExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(UnrecognizedQueryParamException exception) { + + String parameterName = exception.getQueryParamKey(); + String parameterValue = exception.getQueryParamValue(); + + StringBuilder validationErrorCode = new StringBuilder("error.msg.query.parameter.value.unsupported"); + StringBuilder defaultEnglishMessage = new StringBuilder("The query parameter ").append(parameterName) + .append(" has an unsupported value of: ").append(parameterValue); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameterName, parameterName, parameterValue); + + List errors = new ArrayList(); + errors.add(error); + + ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest("validation.msg.validation.errors.exist", + "Validation errors exist.", errors); + + return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnsupportedCommandExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnsupportedCommandExceptionMapper.java new file mode 100644 index 000000000..ecc89fb41 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnsupportedCommandExceptionMapper.java @@ -0,0 +1,45 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.commands.exception.UnsupportedCommandException; +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link UnsupportedCommandException} thrown + * by platform into a HTTP API friendly format. + */ +@Provider +@Component +@Scope("singleton") +public class UnsupportedCommandExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(final UnsupportedCommandException exception) { + + List errors = new ArrayList(); + + StringBuilder validationErrorCode = new StringBuilder("error.msg.command.unsupported"); + StringBuilder defaultEnglishMessage = new StringBuilder("The command ").append(exception.getUnsupportedCommandName()).append( + " is not supported."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName()); + + errors.add(error); + + ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest("validation.msg.validation.errors.exist", + "Validation errors exist.", errors); + + return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnsupportedParameterExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnsupportedParameterExceptionMapper.java new file mode 100644 index 000000000..e5ef80120 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/exceptionmapper/UnsupportedParameterExceptionMapper.java @@ -0,0 +1,46 @@ +package org.mifosplatform.infrastructure.core.exceptionmapper; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.mifosplatform.infrastructure.core.data.ApiGlobalErrorResponse; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.exception.UnsupportedParameterException; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * An {@link ExceptionMapper} to map {@link UnsupportedParameterException} + * thrown by platform into a HTTP API friendly format. + */ +@Provider +@Component +@Scope("singleton") +public class UnsupportedParameterExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(final UnsupportedParameterException exception) { + + List errors = new ArrayList(); + + for (String parameterName : exception.getUnsupportedParameters()) { + StringBuilder validationErrorCode = new StringBuilder("error.msg.parameter.unsupported"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameterName).append(" is not supported."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + parameterName, parameterName); + + errors.add(error); + } + + ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest("validation.msg.validation.errors.exist", + "Validation errors exist.", errors); + + return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/filters/ResponseCorsFilter.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/filters/ResponseCorsFilter.java new file mode 100644 index 000000000..b98807fa4 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/filters/ResponseCorsFilter.java @@ -0,0 +1,35 @@ +package org.mifosplatform.infrastructure.core.filters; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.ResponseBuilder; + +import com.sun.jersey.spi.container.ContainerRequest; +import com.sun.jersey.spi.container.ContainerResponse; +import com.sun.jersey.spi.container.ContainerResponseFilter; + +/** + * Filter that returns a response with headers that allows for Cross-Origin + * Requests (CORs) to be performed against the platform API. + */ +public class ResponseCorsFilter implements ContainerResponseFilter { + + @Override + public ContainerResponse filter(ContainerRequest request, ContainerResponse response) { + + ResponseBuilder resp = Response.fromResponse(response.getResponse()); + + resp.header("Access-Control-Allow-Origin", "*") + // .header("Access-Control-Expose-Headers", "X-Mifos-Platform-TenantId") + .header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); + + String reqHead = request.getHeaderValue("Access-Control-Request-Headers"); + + if (null != reqHead && !reqHead.equals(null)) { + resp.header("Access-Control-Allow-Headers", reqHead); + } + + response.setResponse(resp.build()); + + return response; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/DataSourcePerTenantService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DataSourcePerTenantService.java similarity index 50% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/DataSourcePerTenantService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DataSourcePerTenantService.java index 381c36ea9..a647a09dc 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/DataSourcePerTenantService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/DataSourcePerTenantService.java @@ -1,11 +1,12 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.service; import javax.sql.DataSource; /** - * A service for getting hold of the appropriate {@link DataSource} connection pool for the given tenant. + * A service for getting hold of the appropriate {@link DataSource} connection + * pool for the given tenant. */ public interface DataSourcePerTenantService { - DataSource retrieveTenantAwareDataSource(); + DataSource retrieveTenantAwareDataSource(); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/FileUtils.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/FileUtils.java new file mode 100644 index 000000000..70a10a51f --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/FileUtils.java @@ -0,0 +1,188 @@ +package org.mifosplatform.infrastructure.core.service; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import org.mifosng.platform.exceptions.DocumentManagementException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage; +import org.mifosplatform.infrastructure.core.exception.ImageDataURLNotValidException; +import org.mifosplatform.infrastructure.core.exception.ImageUploadException; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.lowagie.text.pdf.codec.Base64; + +public class FileUtils { + + private final static Logger logger = LoggerFactory.getLogger(FileUtils.class); + + public static final String MIFOSX_BASE_DIR = System.getProperty("user.home") + File.separator + ".mifosx"; + + public static Random random = new Random(); + + /** + * Generate a random String + * + * @return + */ + public static String generateRandomString() { + String characters = "abcdefghijklmnopqrstuvwxyz123456789"; + int length = generateRandomNumber(); + char[] text = new char[length]; + for (int i = 0; i < length; i++) { + text[i] = characters.charAt(random.nextInt(characters.length())); + } + return new String(text); + } + + /** + * Generate a random number between 5 to 16 + * + * @return + */ + public static int generateRandomNumber() { + Random randomGenerator = new Random(); + return randomGenerator.nextInt(11) + 5; + } + + /** + * Generate the directory path for storing the new document + * + * @param entityType + * @param entityId + * @return + */ + public static String generateFileParentDirectory(String entityType, Long entityId) { + return FileUtils.MIFOSX_BASE_DIR + File.separator + ThreadLocalContextUtil.getTenant().getName().replaceAll(" ", "").trim() + + File.separator + "documents" + File.separator + entityType + File.separator + entityId + File.separator + + FileUtils.generateRandomString(); + } + + /** + * Generate directory path for storing new Image + */ + public static String generateClientImageParentDirectory(final Long resourceId) { + return FileUtils.MIFOSX_BASE_DIR + File.separator + ThreadLocalContextUtil.getTenant().getName().replaceAll(" ", "").trim() + + File.separator + "images" + File.separator + "clients" + File.separator + resourceId; + } + + /** + * @param uploadedInputStream + * @param uploadedFileLocation + * @return + * @throws IOException + */ + public static String saveToFileSystem(InputStream uploadedInputStream, String uploadedFileLocation, String fileName) throws IOException { + String fileLocation = uploadedFileLocation + File.separator + fileName; + OutputStream out = new FileOutputStream(new File(fileLocation)); + int read = 0; + byte[] bytes = new byte[1024]; + + while ((read = uploadedInputStream.read(bytes)) != -1) { + out.write(bytes, 0, read); + } + out.flush(); + out.close(); + return fileLocation; + } + + /** + * @param base64EncodedImage + * @param uploadedFileLocation + * @param fileName + * @return + * @throws IOException + */ + public static String saveToFileSystem(Base64EncodedImage base64EncodedImage, String uploadedFileLocation, String fileName) + throws IOException { + String fileLocation = uploadedFileLocation + File.separator + fileName + base64EncodedImage.getFileExtension(); + OutputStream out = new FileOutputStream(new File(fileLocation)); + byte[] imgBytes = Base64.decode(base64EncodedImage.getBase64EncodedString()); + out.write(imgBytes); + out.flush(); + out.close(); + return fileLocation; + } + + /** + * @param fileSize + * @param name + */ + public static void validateFileSizeWithinPermissibleRange(Long fileSize, String name, int maxFileSize) { + /** + * Using Content-Length gives me size of the entire request, which is + * good enough for now for a fast fail as the length of the rest of the + * content i.e name and description while compared to the uploaded file + * size is negligible + **/ + if (fileSize != null && ((fileSize / (1024 * 1024)) > maxFileSize)) { throw new DocumentManagementException(name, fileSize, + maxFileSize); } + } + + /** + * Validates that passed in Mime type maps to known image mime types + * + * @param mimeType + */ + public static void validateImageMimeType(String mimeType) { + if (!(mimeType.equalsIgnoreCase("image/gif") || mimeType.equalsIgnoreCase("image/jpeg") || mimeType.equalsIgnoreCase("image/png"))) { throw new ImageUploadException(); } + } + + /** + * Extracts Image from a Data URL + * + * @param mimeType + */ + public static Base64EncodedImage extractImageFromDataURL(String dataURL) { + String fileExtension = ""; + String base64EncodedString = null; + String gifDataURLSnippet = "data:image/gif;base64,"; + String pngDataURLSnippet = "data:image/png;base64,"; + String jpegDataURLSnippet = "data:image/jpeg;base64,"; + + if (dataURL.contains(gifDataURLSnippet)) { + base64EncodedString = dataURL.replaceAll(gifDataURLSnippet, ""); + fileExtension = ".gif"; + } else if (dataURL.contains(pngDataURLSnippet)) { + base64EncodedString = dataURL.replaceAll(pngDataURLSnippet, ""); + fileExtension = ".png"; + } else if (dataURL.contains(jpegDataURLSnippet)) { + base64EncodedString = dataURL.replaceAll(jpegDataURLSnippet, ""); + fileExtension = ".jpeg"; + } else { + throw new ImageDataURLNotValidException(); + } + + return new Base64EncodedImage(base64EncodedString, fileExtension); + } + + public static void validateClientImageNotEmpty(String imageFileName) { + List dataValidationErrors = new ArrayList(); + if (imageFileName == null) { + StringBuilder validationErrorCode = new StringBuilder("validation.msg.clientImage.cannot.be.blank"); + StringBuilder defaultEnglishMessage = new StringBuilder("The parameter image cannot be blank."); + ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), + "image"); + dataValidationErrors.add(error); + throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", + dataValidationErrors); + } + } + + public static void deleteClientImage(final Long resourceId, final String location) { + File fileToBeDeleted = new File(location); + boolean fileDeleted = fileToBeDeleted.delete(); + if (!fileDeleted) { + // no need to throw an Error, simply log a warning + logger.warn("Unable to delete image associated with clients with Id " + resourceId); + } + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/GmailBackedPlatformEmailService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/GmailBackedPlatformEmailService.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/GmailBackedPlatformEmailService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/GmailBackedPlatformEmailService.java index aeec92975..0141a6955 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/GmailBackedPlatformEmailService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/GmailBackedPlatformEmailService.java @@ -1,9 +1,10 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.service; import org.apache.commons.mail.DefaultAuthenticator; import org.apache.commons.mail.Email; import org.apache.commons.mail.EmailException; import org.apache.commons.mail.SimpleEmail; +import org.mifosplatform.infrastructure.core.domain.EmailDetail; import org.springframework.stereotype.Service; @Service diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformEmailSendException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/PlatformEmailSendException.java similarity index 73% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformEmailSendException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/PlatformEmailSendException.java index 1ccbb7ede..afbda09ed 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformEmailSendException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/PlatformEmailSendException.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.service; public class PlatformEmailSendException extends RuntimeException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformEmailService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/PlatformEmailService.java similarity index 50% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformEmailService.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/PlatformEmailService.java index c2130f3ac..dd33759a0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformEmailService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/PlatformEmailService.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.service; + +import org.mifosplatform.infrastructure.core.domain.EmailDetail; public interface PlatformEmailService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/TenantAwareRoutingDataSource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/TenantAwareRoutingDataSource.java similarity index 56% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/TenantAwareRoutingDataSource.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/TenantAwareRoutingDataSource.java index b5135555a..f6c1c0a28 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/TenantAwareRoutingDataSource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/TenantAwareRoutingDataSource.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.service; import java.sql.Connection; import java.sql.SQLException; @@ -20,23 +20,23 @@ import org.springframework.stereotype.Service; * The {@link DataSourcePerTenantService} is responsible for returning the * appropriate {@link DataSource} for the tenant of this request. */ -@Service(value="tenantAwareDataSource") +@Service(value = "tenantAwareDataSource") public class TenantAwareRoutingDataSource extends AbstractDataSource { - @Autowired - private DataSourcePerTenantService dataSourcePerTenantService; - - @Override - public Connection getConnection() throws SQLException { - return determineTargetDataSource().getConnection(); - } + @Autowired + private DataSourcePerTenantService dataSourcePerTenantService; - private DataSource determineTargetDataSource() { - return dataSourcePerTenantService.retrieveTenantAwareDataSource(); - } + @Override + public Connection getConnection() throws SQLException { + return determineTargetDataSource().getConnection(); + } - @Override - public Connection getConnection(final String username, final String password) throws SQLException { - return determineTargetDataSource().getConnection(username, password); - } + private DataSource determineTargetDataSource() { + return dataSourcePerTenantService.retrieveTenantAwareDataSource(); + } + + @Override + public Connection getConnection(final String username, final String password) throws SQLException { + return determineTargetDataSource().getConnection(username, password); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/ThreadLocalContextUtil.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/ThreadLocalContextUtil.java similarity index 81% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/ThreadLocalContextUtil.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/ThreadLocalContextUtil.java index b2266399d..ecc431c49 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/ThreadLocalContextUtil.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/ThreadLocalContextUtil.java @@ -1,5 +1,6 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.core.service; +import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant; import org.springframework.util.Assert; /** diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java new file mode 100644 index 000000000..078ed3b31 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java @@ -0,0 +1,92 @@ +package org.mifosplatform.infrastructure.core.service; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import javax.sql.DataSource; + +import org.apache.tomcat.jdbc.pool.PoolConfiguration; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +/** + * Implementation that returns a new or existing tomcat 7 jdbc connection pool + * datasource based on the tenant details stored in a {@link ThreadLocal} + * variable for this request. + * + * {@link ThreadLocalContextUtil} is used to retrieve the + * {@link MifosPlatformTenant} for the request. + */ +@Service +public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenantService { + + private final Map tenantToDataSourceMap = new ConcurrentHashMap(1); + private final DataSource tenantDataSource; + + @Autowired + public TomcatJdbcDataSourcePerTenantService(final @Qualifier("tenantDataSourceJndi") DataSource tenantDataSource) { + this.tenantDataSource = tenantDataSource; + } + + @Override + public DataSource retrieveTenantAwareDataSource() { + + // default to tenant database datasource + DataSource tenantDataSource = this.tenantDataSource; + + MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); + if (tenant != null) { + // if tenant information available switch to appropriate datasource + // for that tenant. + if (this.tenantToDataSourceMap.containsKey(tenant.getId())) { + tenantDataSource = this.tenantToDataSourceMap.get(tenant.getId()); + } else { + tenantDataSource = createNewDataSourceFor(tenant); + this.tenantToDataSourceMap.put(tenant.getId(), tenantDataSource); + } + } + + return tenantDataSource; + } + + private DataSource createNewDataSourceFor(final MifosPlatformTenant tenant) { + // see + // http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency + + StringBuilder jdbcUrlBuilder = new StringBuilder("jdbc:mysql://").append(tenant.getSchemaServer()).append(':') + .append(tenant.getSchemaServerPort()).append('/').append(tenant.getSchemaName()); + + PoolConfiguration poolConfiguration = new PoolProperties(); + poolConfiguration.setDriverClassName("com.mysql.jdbc.Driver"); + poolConfiguration.setName(tenant.getSchemaName() + "_pool"); + poolConfiguration.setUrl(jdbcUrlBuilder.toString()); + poolConfiguration.setUsername(tenant.getSchemaUsername()); + poolConfiguration.setPassword(tenant.getSchemaPassword()); + + poolConfiguration.setInitialSize(5); + poolConfiguration.setMaxActive(5); + poolConfiguration.setMinIdle(1); + poolConfiguration.setMaxIdle(4); + + poolConfiguration.setSuspectTimeout(60); + poolConfiguration.setTimeBetweenEvictionRunsMillis(30000); + poolConfiguration.setMinEvictableIdleTimeMillis(60000); + + poolConfiguration.setTestOnBorrow(true); + poolConfiguration.setValidationQuery("SELECT 1"); + poolConfiguration.setValidationInterval(30000); + + poolConfiguration.setRemoveAbandoned(true); + poolConfiguration.setRemoveAbandonedTimeout(60); + poolConfiguration.setLogAbandoned(true); + poolConfiguration.setAbandonWhenPercentageFull(50); + + poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;" + + "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport"); + + return new org.apache.tomcat.jdbc.pool.DataSource(poolConfiguration); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java index ad0053c9e..4e32df69d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/DataTableApiResource.java @@ -23,14 +23,14 @@ import javax.ws.rs.core.UriInfo; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.exceptions.NoAuthorizationException; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.dataqueries.data.DatatableData; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.dataqueries.service.GenericDataService; import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService; +import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.slf4j.Logger; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/ReportsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/ReportsApiResource.java index db5c2c639..73304c4c4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/ReportsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/api/ReportsApiResource.java @@ -18,11 +18,11 @@ import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.StreamingOutput; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.exceptions.NoAuthorizationException; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; +import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.dataqueries.service.ReadReportingService; +import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeader.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeader.java index bb5dd3ea6..65c7d322e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeader.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/data/ResultsetColumnHeader.java @@ -3,7 +3,7 @@ package org.mifosplatform.infrastructure.dataqueries.data; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; public class ResultsetColumnHeader { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DataTableNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DataTableNotFoundException.java similarity index 75% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DataTableNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DataTableNotFoundException.java index 6bc7feedd..48dea9836 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/DataTableNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/DataTableNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.dataqueries.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when client resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java new file mode 100644 index 000000000..e9f521fa8 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/exception/ReportNotFoundException.java @@ -0,0 +1,13 @@ +package org.mifosplatform.infrastructure.dataqueries.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +/** + * A {@link RuntimeException} thrown when report resources are not found. + */ +public class ReportNotFoundException extends AbstractPlatformResourceNotFoundException { + + public ReportNotFoundException(final String reportSql) { + super("error.msg.report.name.not.found", "Reporting Meta Data Entry Not Found", "Input Sql: " + reportSql); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/GenericDataServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/GenericDataServiceImpl.java index acfbe9c1c..aacebabce 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/GenericDataServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/GenericDataServiceImpl.java @@ -12,8 +12,8 @@ import javax.sql.DataSource; import javax.sql.rowset.CachedRowSet; import org.joda.time.LocalDate; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnHeader; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetDataRow; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java index 6cd004092..7f83f1fd4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadReportingServiceImpl.java @@ -18,12 +18,12 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.exceptions.ReportNotFoundException; -import org.mifosng.platform.infrastructure.FileUtils; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; +import org.mifosplatform.infrastructure.core.service.FileUtils; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnHeader; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetDataRow; +import org.mifosplatform.infrastructure.dataqueries.exception.ReportNotFoundException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java index 28dcf3b62..7e819b2d8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java @@ -12,16 +12,16 @@ import java.util.Set; import javax.sql.rowset.CachedRowSet; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.DataTableNotFoundException; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.infrastructure.api.JsonParserHelper; +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.dataqueries.data.DatatableData; import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnHeader; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnValue; import org.mifosplatform.infrastructure.dataqueries.data.ResultsetDataRow; +import org.mifosplatform.infrastructure.dataqueries.exception.DataTableNotFoundException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.slf4j.Logger; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficeTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficeTransactionsApiResource.java index 798d5946f..b5d063227 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficeTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficeTransactionsApiResource.java @@ -14,12 +14,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.office.command.BranchMoneyTransferCommand; import org.mifosplatform.infrastructure.office.data.OfficeTransactionData; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficesApiResource.java index 540831ba3..e7972de37 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/api/OfficesApiResource.java @@ -17,12 +17,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.office.command.OfficeCommand; import org.mifosplatform.infrastructure.office.data.OfficeData; import org.mifosplatform.infrastructure.office.data.OfficeLookup; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/BranchMoneyTransferCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/BranchMoneyTransferCommand.java index 635dae8ff..f5b64f855 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/BranchMoneyTransferCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/BranchMoneyTransferCommand.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.Set; import org.joda.time.LocalDate; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; /** * Immutable command for transferring money between two branches. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/OfficeCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/OfficeCommand.java index d4532f6e8..b61c36783 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/OfficeCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/command/OfficeCommand.java @@ -5,9 +5,9 @@ import java.util.List; import java.util.Set; import org.joda.time.LocalDate; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; /** * Immutable command for creating or updating details of a office. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/Office.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/Office.java index 26aa7371e..0463ab0ff 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/Office.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/Office.java @@ -17,10 +17,10 @@ import javax.persistence.UniqueConstraint; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; -import org.mifosng.platform.exceptions.CannotUpdateOfficeWithParentOfficeSameAsSelf; -import org.mifosng.platform.exceptions.RootOfficeParentCannotBeUpdated; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.command.OfficeCommand; +import org.mifosplatform.infrastructure.office.exception.CannotUpdateOfficeWithParentOfficeSameAsSelf; +import org.mifosplatform.infrastructure.office.exception.RootOfficeParentCannotBeUpdated; import org.mifosplatform.infrastructure.user.domain.AppUser; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OfficeTransaction.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OfficeTransaction.java index aa556a541..a95b2bdbb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OfficeTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OfficeTransaction.java @@ -14,9 +14,9 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import org.joda.time.LocalDate; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OrganisationCurrency.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OrganisationCurrency.java index 1e12fbfb6..a3ff7b873 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OrganisationCurrency.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/domain/OrganisationCurrency.java @@ -4,7 +4,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CannotUpdateOfficeWithParentOfficeSameAsSelf.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/CannotUpdateOfficeWithParentOfficeSameAsSelf.java similarity index 73% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CannotUpdateOfficeWithParentOfficeSameAsSelf.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/CannotUpdateOfficeWithParentOfficeSameAsSelf.java index b22ae32ae..d1f216974 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CannotUpdateOfficeWithParentOfficeSameAsSelf.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/CannotUpdateOfficeWithParentOfficeSameAsSelf.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.office.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * Exception thrown when an attempt is made update the parent of a root office. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidOfficeException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/InvalidOfficeException.java similarity index 73% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidOfficeException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/InvalidOfficeException.java index 4f1be7796..e69c177de 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidOfficeException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/InvalidOfficeException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.office.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * {@link AbstractPlatformDomainRuleException} thrown when office mismatch occurs diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/OfficeNotFoundException.java similarity index 67% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/OfficeNotFoundException.java index d627c2e4a..d7d8ed098 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/OfficeNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.office.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when office resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RootOfficeParentCannotBeUpdated.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/RootOfficeParentCannotBeUpdated.java similarity index 70% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RootOfficeParentCannotBeUpdated.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/RootOfficeParentCannotBeUpdated.java index 276d53439..bbc4826c5 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RootOfficeParentCannotBeUpdated.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/exception/RootOfficeParentCannotBeUpdated.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.office.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * Exception thrown when an attempt is made update the parent of a root office. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeReadPlatformServiceImpl.java index ffe532d43..0c5e90f0e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeReadPlatformServiceImpl.java @@ -8,14 +8,14 @@ import java.util.Collection; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.office.data.OfficeData; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.data.OfficeTransactionData; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java index cb58456fc..d9a52a823 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/office/service/OfficeWritePlatformServiceJpaRepositoryImpl.java @@ -1,23 +1,23 @@ package org.mifosplatform.infrastructure.office.service; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.CurrencyNotFoundException; -import org.mifosng.platform.exceptions.NoAuthorizationException; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrency; import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrencyRepository; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; +import org.mifosplatform.infrastructure.configuration.exception.CurrencyNotFoundException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand; import org.mifosplatform.infrastructure.office.command.OfficeCommand; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.office.domain.OfficeRepository; import org.mifosplatform.infrastructure.office.domain.OfficeTransaction; import org.mifosplatform.infrastructure.office.domain.OfficeTransactionRepository; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; +import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/exception/InvalidTenantIdentiferException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/exception/InvalidTenantIdentiferException.java new file mode 100644 index 000000000..0fb316cd3 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/exception/InvalidTenantIdentiferException.java @@ -0,0 +1,14 @@ +package org.mifosplatform.infrastructure.security.exception; + +/** + * {@link RuntimeException} thrown when an invalid tenant identifier is used in + * request to platform. + * + * @see CustomRequestHeaderAuthenticationFilter + */ +public class InvalidTenantIdentiferException extends RuntimeException { + + public InvalidTenantIdentiferException(final String message) { + super(message); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/exception/NoAuthorizationException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/exception/NoAuthorizationException.java new file mode 100644 index 000000000..209a51a12 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/exception/NoAuthorizationException.java @@ -0,0 +1,12 @@ +package org.mifosplatform.infrastructure.security.exception; + +/** + * A {@link RuntimeException} that is thrown in the case where a user does not + * have sufficient authorization to execute operation on platform. + */ +public class NoAuthorizationException extends RuntimeException { + + public NoAuthorizationException(final String message) { + super(message); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/filter/TenantAwareBasicAuthenticationFilter.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/filter/TenantAwareBasicAuthenticationFilter.java index 5c6997346..986a19ef6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/filter/TenantAwareBasicAuthenticationFilter.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/filter/TenantAwareBasicAuthenticationFilter.java @@ -9,9 +9,9 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.mifosng.platform.infrastructure.InvalidTenantIdentiferException; -import org.mifosng.platform.infrastructure.MifosPlatformTenant; -import org.mifosng.platform.infrastructure.ThreadLocalContextUtil; +import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant; +import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil; +import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException; import org.mifosplatform.infrastructure.security.service.TenantDetailsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/CustomAuthenticationFailureHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/CustomAuthenticationFailureHandler.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/CustomAuthenticationFailureHandler.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/CustomAuthenticationFailureHandler.java index 75bff314a..296f8fe73 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/CustomAuthenticationFailureHandler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/CustomAuthenticationFailureHandler.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.security.service; import java.io.IOException; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/JdbcTenantDetailsService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/JdbcTenantDetailsService.java index d518136d5..ca6cfb94e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/JdbcTenantDetailsService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/JdbcTenantDetailsService.java @@ -5,8 +5,8 @@ import java.sql.SQLException; import javax.sql.DataSource; -import org.mifosng.platform.infrastructure.InvalidTenantIdentiferException; -import org.mifosng.platform.infrastructure.MifosPlatformTenant; +import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant; +import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.dao.EmptyResultDataAccessException; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformPasswordEncoder.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformPasswordEncoder.java similarity index 73% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformPasswordEncoder.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformPasswordEncoder.java index 488f08b08..f2871be39 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/PlatformPasswordEncoder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformPasswordEncoder.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.security.service; import org.mifosplatform.infrastructure.security.domain.PlatformUser; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/RandomPasswordGenerator.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/RandomPasswordGenerator.java similarity index 90% rename from mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/RandomPasswordGenerator.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/RandomPasswordGenerator.java index 3cff8bae5..8a088e927 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/infrastructure/RandomPasswordGenerator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/RandomPasswordGenerator.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.infrastructure; +package org.mifosplatform.infrastructure.security.service; public class RandomPasswordGenerator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java index 0b57a496f..37c6d0ea2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java @@ -1,7 +1,7 @@ package org.mifosplatform.infrastructure.security.service; -import org.mifosng.platform.exceptions.UnAuthenticatedUserException; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.infrastructure.user.exception.UnAuthenticatedUserException; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantDetailsService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantDetailsService.java index bd856d74c..d35feb7a0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantDetailsService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/TenantDetailsService.java @@ -1,6 +1,6 @@ package org.mifosplatform.infrastructure.security.service; -import org.mifosng.platform.infrastructure.MifosPlatformTenant; +import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant; public interface TenantDetailsService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/api/StaffApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/api/StaffApiResource.java index 9984737f8..e4c31f168 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/api/StaffApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/api/StaffApiResource.java @@ -18,12 +18,12 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/BulkTransferLoanOfficerCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/BulkTransferLoanOfficerCommandValidator.java index 811ca2a46..3ce7f6db4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/BulkTransferLoanOfficerCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/BulkTransferLoanOfficerCommandValidator.java @@ -1,8 +1,8 @@ package org.mifosplatform.infrastructure.staff.command; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import java.util.ArrayList; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/StaffCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/StaffCommand.java index f16976ad9..6087e1500 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/StaffCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/command/StaffCommand.java @@ -4,9 +4,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; /** * Immutable command for creating or updating details of a staff member. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/BulkTransferLoanOfficerData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/BulkTransferLoanOfficerData.java index 2520879ba..2298df483 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/BulkTransferLoanOfficerData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/BulkTransferLoanOfficerData.java @@ -1,7 +1,6 @@ package org.mifosplatform.infrastructure.staff.data; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.StaffAccountSummaryCollectionData; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import java.util.Collection; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java new file mode 100644 index 000000000..b38d446f8 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java @@ -0,0 +1,81 @@ +package org.mifosplatform.infrastructure.staff.data; + +import java.util.Collection; +import java.util.List; + +import org.mifosng.platform.api.data.GroupAccountSummaryData; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData; + +/** + * + */ +public class StaffAccountSummaryCollectionData { + + @SuppressWarnings("unused") + private final List clients; + @SuppressWarnings("unused") + private final List groups; + + public StaffAccountSummaryCollectionData(final List clients, final List groups) { + this.clients = clients; + this.groups = groups; + } + + public static final class ClientSummary { + + private final Long id; + private final String displayName; + + private Collection loans; + + public ClientSummary(Long id, String displayName) { + this.id = id; + this.displayName = displayName; + } + + public Long getId() { + return id; + } + + public String getDisplayName() { + return displayName; + } + + public Collection getLoans() { + return loans; + } + + public void setLoans(Collection loans) { + this.loans = loans; + } + } + + public static final class GroupSummary { + + private final Long id; + private final String name; + + private Collection loans; + + public GroupSummary(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public Collection getLoans() { + return loans; + } + + public void setLoans(Collection loans) { + this.loans = loans; + } + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/domain/Staff.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/domain/Staff.java index 5ca02e6fb..f74afa933 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/domain/Staff.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/domain/Staff.java @@ -8,7 +8,7 @@ import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.staff.command.StaffCommand; import org.mifosplatform.infrastructure.user.domain.AppUser; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/StaffNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/exception/StaffNotFoundException.java similarity index 67% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/StaffNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/exception/StaffNotFoundException.java index 5ca68234c..69fad2c36 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/StaffNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/exception/StaffNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.staff.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when staff resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/StaffRoleException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/exception/StaffRoleException.java old mode 100755 new mode 100644 similarity index 77% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/StaffRoleException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/exception/StaffRoleException.java index 0521f1f79..0fbb602b2 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/StaffRoleException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/exception/StaffRoleException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.staff.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when staff resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformService.java index 388c1361d..983c57f15 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformService.java @@ -2,7 +2,7 @@ package org.mifosplatform.infrastructure.staff.service; import java.util.Collection; -import org.mifosng.platform.api.data.StaffAccountSummaryCollectionData; +import org.mifosplatform.infrastructure.staff.data.StaffAccountSummaryCollectionData; import org.mifosplatform.infrastructure.staff.data.StaffData; public interface StaffReadPlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java index 1d916d7be..612820264 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java @@ -6,16 +6,16 @@ import java.util.Collection; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.ClientAccountSummaryData; import org.mifosng.platform.api.data.GroupAccountSummaryData; -import org.mifosng.platform.api.data.StaffAccountSummaryCollectionData; -import org.mifosng.platform.client.service.ClientReadPlatformService; -import org.mifosng.platform.exceptions.StaffNotFoundException; import org.mifosng.platform.group.service.GroupReadPlatformService; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.infrastructure.staff.data.StaffAccountSummaryCollectionData; import org.mifosplatform.infrastructure.staff.data.StaffData; +import org.mifosplatform.infrastructure.staff.exception.StaffNotFoundException; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java index 72d3c0885..4e76e2286 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java @@ -1,17 +1,17 @@ package org.mifosplatform.infrastructure.staff.service; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.exceptions.StaffNotFoundException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.office.domain.OfficeRepository; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.staff.command.StaffCommand; import org.mifosplatform.infrastructure.staff.domain.Staff; import org.mifosplatform.infrastructure.staff.domain.StaffRepository; +import org.mifosplatform.infrastructure.staff.exception.StaffNotFoundException; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/AuthenticationApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/AuthenticationApiResource.java index 979c920a0..d4a8549d2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/AuthenticationApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/AuthenticationApiResource.java @@ -10,7 +10,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; +import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; import org.mifosplatform.infrastructure.user.api.data.AuthenticatedUserData; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/PermissionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/PermissionsApiResource.java index 19a151e9f..2eec2fb89 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/PermissionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/PermissionsApiResource.java @@ -14,12 +14,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData; import org.mifosplatform.infrastructure.user.command.PermissionsCommand; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/RolesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/RolesApiResource.java index 23cf05e66..514e4e54f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/RolesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/RolesApiResource.java @@ -17,15 +17,15 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.api.data.CommandSourceData; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService; +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.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData; import org.mifosplatform.infrastructure.user.api.data.RoleData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/UsersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/UsersApiResource.java index c361f6ab3..bbb4bda07 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/UsersApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/api/UsersApiResource.java @@ -18,12 +18,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/RoleCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/RoleCommandValidator.java index d743fbf62..bb54b1408 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/RoleCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/RoleCommandValidator.java @@ -3,9 +3,9 @@ package org.mifosplatform.infrastructure.user.command; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class RoleCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/UserCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/UserCommandValidator.java index de32fafd8..0b5844e21 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/UserCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/command/UserCommandValidator.java @@ -3,9 +3,9 @@ package org.mifosplatform.infrastructure.user.command; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class UserCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/AppUser.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/AppUser.java index 9cf74ccc8..44305399a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/AppUser.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/AppUser.java @@ -16,10 +16,10 @@ import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.UniqueConstraint; -import org.mifosng.platform.exceptions.NoAuthorizationException; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.security.domain.PlatformUser; +import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/JpaUserDomainService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/JpaUserDomainService.java index 6dbe0a108..3fa984341 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/JpaUserDomainService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/JpaUserDomainService.java @@ -1,11 +1,11 @@ package org.mifosplatform.infrastructure.user.domain; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.infrastructure.EmailDetail; -import org.mifosng.platform.infrastructure.PlatformEmailService; -import org.mifosng.platform.infrastructure.PlatformPasswordEncoder; -import org.mifosng.platform.infrastructure.RandomPasswordGenerator; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.domain.EmailDetail; +import org.mifosplatform.infrastructure.core.service.PlatformEmailService; +import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder; +import org.mifosplatform.infrastructure.security.service.RandomPasswordGenerator; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/Role.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/Role.java index 17f090404..74dd9e993 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/Role.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/domain/Role.java @@ -12,7 +12,7 @@ import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.api.data.RoleData; import org.mifosplatform.infrastructure.user.command.RoleCommand; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionCantBeMakerCheckerableException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionCantBeMakerCheckerableException.java index 3b14f4289..7c9ee005d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionCantBeMakerCheckerableException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionCantBeMakerCheckerableException.java @@ -1,6 +1,6 @@ package org.mifosplatform.infrastructure.user.exception; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when permission is attempted to be set as maker-checker enabled. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionNotFoundException.java index 096cb31ce..29ea5ef47 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/PermissionNotFoundException.java @@ -1,6 +1,6 @@ package org.mifosplatform.infrastructure.user.exception; -import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when permission resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/RoleNotFoundException.java similarity index 66% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/RoleNotFoundException.java index 4600d7d06..8757b93ac 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/RoleNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.user.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when role resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UnAuthenticatedUserException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UnAuthenticatedUserException.java similarity index 57% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UnAuthenticatedUserException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UnAuthenticatedUserException.java index 84cc541bf..cc76413f9 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UnAuthenticatedUserException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UnAuthenticatedUserException.java @@ -1,10 +1,11 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.user.exception; import org.springframework.security.core.context.SecurityContext; /** - * A {@link RuntimeException} that is thrown in the case where no authenticated user exists within the platform {@link SecurityContext}. + * A {@link RuntimeException} that is thrown in the case where no authenticated + * user exists within the platform {@link SecurityContext}. */ public class UnAuthenticatedUserException extends RuntimeException { - // no added behaviour + // no added behaviour } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UserNotFoundException.java similarity index 66% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UserNotFoundException.java index d809da215..2c28f78c8 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UserNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.infrastructure.user.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when user resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UsernameAlreadyExistsException.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UsernameAlreadyExistsException.java new file mode 100644 index 000000000..0e7a0e0b7 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/exception/UsernameAlreadyExistsException.java @@ -0,0 +1,8 @@ +package org.mifosplatform.infrastructure.user.exception; + +public class UsernameAlreadyExistsException extends RuntimeException { + + public UsernameAlreadyExistsException(final Throwable e) { + super(e); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserReadPlatformServiceImpl.java index 24ded8913..eb63572ca 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserReadPlatformServiceImpl.java @@ -7,9 +7,8 @@ import java.util.Collection; import java.util.List; import java.util.Set; -import org.mifosng.platform.exceptions.UserNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.office.data.OfficeData; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; @@ -19,6 +18,7 @@ import org.mifosplatform.infrastructure.user.api.data.RoleData; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.infrastructure.user.domain.AppUserRepository; import org.mifosplatform.infrastructure.user.domain.Role; +import org.mifosplatform.infrastructure.user.exception.UserNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserWritePlatformServiceJpaRepositoryImpl.java index 1bf2a2541..1e2c9d938 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/AppUserWritePlatformServiceJpaRepositoryImpl.java @@ -6,20 +6,17 @@ import java.util.List; import java.util.Set; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.exceptions.RoleNotFoundException; -import org.mifosng.platform.exceptions.UserNotFoundException; -import org.mifosng.platform.infrastructure.PlatformEmailSendException; -import org.mifosng.platform.infrastructure.PlatformPasswordEncoder; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +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.service.PlatformEmailSendException; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.office.domain.OfficeRepository; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; import org.mifosplatform.infrastructure.security.domain.BasicPasswordEncodablePlatformUser; import org.mifosplatform.infrastructure.security.domain.PlatformUser; +import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.command.UserCommand; import org.mifosplatform.infrastructure.user.command.UserCommandValidator; @@ -28,6 +25,9 @@ import org.mifosplatform.infrastructure.user.domain.AppUserRepository; import org.mifosplatform.infrastructure.user.domain.Role; import org.mifosplatform.infrastructure.user.domain.RoleRepository; import org.mifosplatform.infrastructure.user.domain.UserDomainService; +import org.mifosplatform.infrastructure.user.exception.RoleNotFoundException; +import org.mifosplatform.infrastructure.user.exception.UserNotFoundException; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/PermissionReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/PermissionReadPlatformServiceImpl.java index 3d0f2feee..13823a062 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/PermissionReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/PermissionReadPlatformServiceImpl.java @@ -4,7 +4,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData; import org.slf4j.Logger; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleReadPlatformServiceImpl.java index 476bfb208..fd84c0e93 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleReadPlatformServiceImpl.java @@ -4,13 +4,13 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import org.mifosng.platform.exceptions.RoleNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.api.data.RoleData; import org.mifosplatform.infrastructure.user.domain.Role; import org.mifosplatform.infrastructure.user.domain.RoleRepository; +import org.mifosplatform.infrastructure.user.exception.RoleNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleWritePlatformServiceJpaRepositoryImpl.java index 19ec4629f..178a58ea2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/user/service/RoleWritePlatformServiceJpaRepositoryImpl.java @@ -3,8 +3,6 @@ package org.mifosplatform.infrastructure.user.service; import java.util.Collection; import java.util.Map; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.RoleNotFoundException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.command.RoleCommand; @@ -15,6 +13,8 @@ import org.mifosplatform.infrastructure.user.domain.PermissionRepository; import org.mifosplatform.infrastructure.user.domain.Role; import org.mifosplatform.infrastructure.user.domain.RoleRepository; import org.mifosplatform.infrastructure.user.exception.PermissionNotFoundException; +import org.mifosplatform.infrastructure.user.exception.RoleNotFoundException; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java index 501e20b2c..054f4af44 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/api/ChargesApiResource.java @@ -17,12 +17,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; import org.mifosplatform.portfolio.charge.data.ChargeData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/command/ChargeDefinitionCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/command/ChargeDefinitionCommand.java index aa1c8d312..bf99152f4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/command/ChargeDefinitionCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/command/ChargeDefinitionCommand.java @@ -5,9 +5,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; /** * Immutable data object for creating and modifying defined charges. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java index 18017ff18..2027f3686 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/data/ChargeData.java @@ -3,8 +3,8 @@ package org.mifosplatform.portfolio.charge.data; import java.math.BigDecimal; import java.util.List; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; /** * Immutable data object for charge data. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java index 29f93b23d..9db269ca8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/domain/Charge.java @@ -1,6 +1,6 @@ package org.mifosplatform.portfolio.charge.domain; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ChargeIsNotActiveException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/ChargeIsNotActiveException.java similarity index 71% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ChargeIsNotActiveException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/ChargeIsNotActiveException.java index eb450c7bc..7b3bce9eb 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ChargeIsNotActiveException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/ChargeIsNotActiveException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.charge.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * {@link AbstractPlatformDomainRuleException} thrown when charge is not active. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ChargeNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/ChargeNotFoundException.java similarity index 62% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ChargeNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/ChargeNotFoundException.java index 8b821991a..39374766e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ChargeNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/ChargeNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.charge.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; public class ChargeNotFoundException extends AbstractPlatformResourceNotFoundException { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeCannotBeAddedException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeAddedException.java similarity index 77% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeCannotBeAddedException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeAddedException.java index eaed6ca3b..eae377495 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeCannotBeAddedException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeCannotBeAddedException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.charge.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * {@link AbstractPlatformDomainRuleException} thrown when loan charge is not allowed to be added to the loan. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeNotFoundException.java similarity index 70% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeNotFoundException.java index 486ded5df..27dd6ec35 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeNotFoundException.java @@ -1,4 +1,7 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.charge.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * {@link AbstractPlatformDomainRuleException} thrown when loan charge does not exist. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeWithoutMandatoryFieldException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeWithoutMandatoryFieldException.java similarity index 76% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeWithoutMandatoryFieldException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeWithoutMandatoryFieldException.java index 618a21507..8c20efeec 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanChargeWithoutMandatoryFieldException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/exception/LoanChargeWithoutMandatoryFieldException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.charge.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** * {@link AbstractPlatformDomainRuleException} thrown when currency mismatch occurs diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java index 68c28032c..23eb83ec4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformService.java @@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.charge.service; import java.util.List; -import org.mifosng.platform.api.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; public interface ChargeDropdownReadPlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java index 7dfd119a0..7a15ba35c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeDropdownReadPlatformServiceImpl.java @@ -7,7 +7,7 @@ import static org.mifosplatform.portfolio.charge.service.ChargeEnumerations.char import java.util.Arrays; import java.util.List; -import org.mifosng.platform.api.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo; import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType; import org.mifosplatform.portfolio.charge.domain.ChargeTimeType; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java index 571825f5f..0e979ac4d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeEnumerations.java @@ -1,6 +1,6 @@ package org.mifosplatform.portfolio.charge.service; -import org.mifosng.platform.api.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo; import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType; import org.mifosplatform.portfolio.charge.domain.ChargeTimeType; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java index d28d28017..f3305a824 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java @@ -7,16 +7,16 @@ import java.util.Collection; import java.util.List; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.api.data.LoanChargeData; -import org.mifosng.platform.exceptions.ChargeNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo; +import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java index fd3f26342..77965fbf7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeWritePlatformServiceJpaRepositoryImpl.java @@ -1,9 +1,7 @@ package org.mifosplatform.portfolio.charge.service; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.ChargeNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand; import org.mifosplatform.portfolio.charge.domain.Charge; @@ -11,6 +9,8 @@ import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo; import org.mifosplatform.portfolio.charge.domain.ChargeCalculationType; import org.mifosplatform.portfolio.charge.domain.ChargeRepository; import org.mifosplatform.portfolio.charge.domain.ChargeTimeType; +import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java new file mode 100644 index 000000000..6dd7f06a3 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientIdentifiersApiResource.java @@ -0,0 +1,205 @@ +package org.mifosplatform.portfolio.client.api; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +import org.mifosplatform.infrastructure.codes.data.CodeValueData; +import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; +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.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.data.ClientIdentifierData; +import org.mifosplatform.portfolio.client.exception.DuplicateClientIdentifierException; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Path("/clients/{clientId}/identifiers") +@Component +@Scope("singleton") +public class ClientIdentifiersApiResource { + + private final String entityType = "CLIENTIDENTIFIER"; + + private final PlatformSecurityContext context; + private final ClientReadPlatformService clientReadPlatformService; + private final CodeValueReadPlatformService codeValueReadPlatformService; + private final PortfolioApiDataConversionService apiDataConversionService; + private final PortfolioCommandSerializerService commandSerializerService; + private final PortfolioApiJsonSerializerService apiJsonSerializerService; + private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; + + @Autowired + public ClientIdentifiersApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService, + final CodeValueReadPlatformService codeValueReadPlatformService, + final PortfolioApiDataConversionService apiDataConversionService, + final PortfolioCommandSerializerService commandSerializerService, + final PortfolioApiJsonSerializerService apiJsonSerializerService, + final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) { + this.context = context; + this.clientReadPlatformService = readPlatformService; + this.codeValueReadPlatformService = codeValueReadPlatformService; + this.apiDataConversionService = apiDataConversionService; + this.commandSerializerService = commandSerializerService; + this.apiJsonSerializerService = apiJsonSerializerService; + this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; + } + + @GET + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String retrieveAllClientIdentifiers(@Context final UriInfo uriInfo, @PathParam("clientId") final Long clientId) { + + context.authenticatedUser().validateHasReadPermission(entityType); + + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); + final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); + + final Collection clientIdentifiers = this.clientReadPlatformService.retrieveClientIdentifiers(clientId); + + return this.apiJsonSerializerService.serializeClientIdentifierDataToJson(prettyPrint, responseParameters, clientIdentifiers); + } + + @GET + @Path("template") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String newClientDetails(@Context final UriInfo uriInfo) { + + context.authenticatedUser().validateHasReadPermission(entityType); + + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); + final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); + + Collection codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues(); + ClientIdentifierData clientIdentifierData = ClientIdentifierData.template(codeValues); + + return this.apiJsonSerializerService.serializeClientIdentifierDataToJson(prettyPrint, responseParameters, clientIdentifierData); + } + + @POST + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String createClientIdentifier(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) { + + try { + final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", + "CREATE_CLIENTIDENTIFIER"); + context.authenticatedUser().validateHasPermissionTo("CREATE_CLIENTIDENTIFIER", allowedPermissions); + + final ClientIdentifierCommand command = this.apiDataConversionService.convertApiRequestJsonToClientIdentifierCommand(null, + clientId, apiRequestBodyAsJson); + final String commandSerializedAsJson = this.commandSerializerService.serializeCommandToJson(command); + + final String resourceUrl = "clients/" + clientId + "/identifiers"; + final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", resourceUrl, null, + commandSerializedAsJson); + + return this.apiJsonSerializerService.serializeEntityIdentifier(result); + } catch (DuplicateClientIdentifierException e) { + DuplicateClientIdentifierException rethrowas = e; + if (e.getDocumentTypeId() != null) { + // need to fetch client info + ClientData clientInfo = this.clientReadPlatformService.retrieveClientByIdentifier(e.getDocumentTypeId(), + e.getIdentifierKey()); + rethrowas = new DuplicateClientIdentifierException(clientInfo.displayName(), clientInfo.officeName(), + e.getIdentifierType(), e.getIdentifierKey()); + } + throw rethrowas; + } + } + + @GET + @Path("{identifierId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String getClientIdentifier(@PathParam("clientId") final Long clientId, @PathParam("identifierId") final Long clientIdentifierId, + @Context final UriInfo uriInfo) { + + context.authenticatedUser().validateHasReadPermission(entityType); + + final Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); + final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); + final boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); + + ClientIdentifierData clientIdentifierData = this.clientReadPlatformService.retrieveClientIdentifier(clientId, clientIdentifierId); + if (template) { + final Collection codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues(); + clientIdentifierData = ClientIdentifierData.template(clientIdentifierData, codeValues); + } + + return this.apiJsonSerializerService.serializeClientIdentifierDataToJson(prettyPrint, responseParameters, clientIdentifierData); + } + + @PUT + @Path("{identifierId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String updateClientIdentifer(@PathParam("clientId") final Long clientId, + @PathParam("identifierId") final Long clientIdentifierId, final String apiRequestBodyAsJson) { + + try { + final List allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", + "UPDATE_CLIENTIDENTIFIER"); + context.authenticatedUser().validateHasPermissionTo("UPDATE_CLIENTIDENTIFIER", allowedPermissions); + + final ClientIdentifierCommand command = this.apiDataConversionService.convertApiRequestJsonToClientIdentifierCommand( + clientIdentifierId, clientId, apiRequestBodyAsJson); + final String commandSerializedAsJson = this.commandSerializerService.serializeCommandToJson(command); + + final String resourceUrl = "clients/" + clientId + "/identifiers"; + final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", resourceUrl, + clientIdentifierId, commandSerializedAsJson); + + return this.apiJsonSerializerService.serializeEntityIdentifier(result); + } catch (DuplicateClientIdentifierException e) { + DuplicateClientIdentifierException reThrowAs = e; + if (e.getDocumentTypeId() != null) { + ClientData clientInfo = this.clientReadPlatformService.retrieveClientByIdentifier(e.getDocumentTypeId(), + e.getIdentifierKey()); + reThrowAs = new DuplicateClientIdentifierException(clientInfo.displayName(), clientInfo.officeName(), + e.getIdentifierType(), e.getIdentifierKey()); + } + throw reThrowAs; + } + } + + @DELETE + @Path("{identifierId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String deleteClientIdentifier(@PathParam("clientId") final Long clientId, + @PathParam("identifierId") final Long clientIdentifierId) { + + final List allowedPermissions = Arrays + .asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", "DELETE_CLIENTIDENTIFIER"); + context.authenticatedUser().validateHasPermissionTo("DELETE_CLIENTIDENTIFIER", allowedPermissions); + + final String resourceUrl = "clients/" + clientId + "/identifiers"; + final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", resourceUrl, clientIdentifierId, + "{}"); + + return this.apiJsonSerializerService.serializeEntityIdentifier(result); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java index 8da641fc2..f138268db 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api; +package org.mifosplatform.portfolio.client.api; import java.io.InputStream; import java.util.ArrayList; @@ -23,28 +23,28 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.commands.NoteCommand; -import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.data.NoteData; -import org.mifosng.platform.api.infrastructure.ApiConstants; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.client.service.ClientReadPlatformService; -import org.mifosng.platform.client.service.ClientWritePlatformService; -import org.mifosng.platform.exceptions.ImageNotFoundException; -import org.mifosng.platform.infrastructure.Base64EncodedImage; -import org.mifosng.platform.infrastructure.FileUtils; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.api.data.CommandSourceData; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService; +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.service.FileUtils; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.NoteCommand; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.data.NoteData; +import org.mifosplatform.portfolio.client.exception.ImageNotFoundException; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.mifosplatform.portfolio.client.service.ClientWritePlatformService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ClientCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommand.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ClientCommand.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommand.java index ede9caf5b..bb00cd3f7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ClientCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommand.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.commands; +package org.mifosplatform.portfolio.client.command; import java.util.Set; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommandValidator.java similarity index 92% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientCommandValidator.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommandValidator.java index 611c34150..686e5d32e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommandValidator.java @@ -1,13 +1,12 @@ -package org.mifosng.platform.client.service; +package org.mifosplatform.portfolio.client.command; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; public class ClientCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientIdentifierCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientIdentifierCommand.java new file mode 100644 index 000000000..93485c7fb --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientIdentifierCommand.java @@ -0,0 +1,71 @@ +package org.mifosplatform.portfolio.client.command; + +import java.util.Set; + +/** + * Immutable command for creating or updating details of a client identifier. + */ +public class ClientIdentifierCommand { + + + private final Long clientId; + private final Long documentTypeId; + + private final String documentKey; + private final String description; + + private final transient Set modifiedParameters; + private final transient boolean makerCheckerApproval; + private final transient Long id; + + public ClientIdentifierCommand(final Set modifiedParameters, final boolean makerCheckerApproval, final Long id, final Long clientId, final Long documentTypeId, + final String documentKey, final String description) { + this.modifiedParameters = modifiedParameters; + this.makerCheckerApproval = makerCheckerApproval; + this.id = id; + this.clientId = clientId; + this.documentTypeId = documentTypeId; + this.documentKey = documentKey; + this.description = description; + } + + public Long getId() { + return id; + } + + public Long getDocumentTypeId() { + return documentTypeId; + } + + public String getDocumentKey() { + return documentKey; + } + + public String getDescription() { + return description; + } + + public Set getModifiedParameters() { + return modifiedParameters; + } + + public Long getClientId() { + return clientId; + } + + public boolean isDocumentTypeChanged() { + return this.modifiedParameters.contains("documentTypeId"); + } + + public boolean isDocumentKeyChanged() { + return this.modifiedParameters.contains("documentKey"); + } + + public boolean isDescriptionChanged() { + return this.modifiedParameters.contains("description"); + } + + public boolean isApprovedByChecker() { + return this.makerCheckerApproval; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientIdentifierCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientIdentifierCommandValidator.java new file mode 100644 index 000000000..77acefbd3 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientIdentifierCommandValidator.java @@ -0,0 +1,47 @@ +package org.mifosplatform.portfolio.client.command; + +import java.util.ArrayList; +import java.util.List; + +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; + +public class ClientIdentifierCommandValidator { + + private final ClientIdentifierCommand command; + + public ClientIdentifierCommandValidator(ClientIdentifierCommand command) { + this.command = command; + } + + public void validateForUpdate() { + List dataValidationErrors = new ArrayList(); + + DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("clientIdentifier"); + + baseDataValidator.reset().parameter("documentKey").value(command.getDocumentKey()).ignoreIfNull().notBlank(); + + if (command.isDocumentTypeChanged()) { + baseDataValidator.reset().parameter("documentTypeId").value(command.getDocumentTypeId()).notNull().integerGreaterThanZero(); + } + + baseDataValidator.reset().anyOfNotNull(command.getDocumentTypeId(), command.getDocumentKey()); + + if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); } + } + + public void validateForCreate() { + List dataValidationErrors = new ArrayList(); + + DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("clientIdentifier"); + + baseDataValidator.reset().parameter("documentTypeId").value(command.getDocumentTypeId()).notNull().integerGreaterThanZero(); + baseDataValidator.reset().parameter("clientId").value(command.getClientId()).notNull().integerGreaterThanZero(); + baseDataValidator.reset().parameter("documentKey").value(command.getDocumentKey()).notBlank(); + + if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); } + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/NoteCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/NoteCommand.java new file mode 100644 index 000000000..f0e4beeb1 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/NoteCommand.java @@ -0,0 +1,41 @@ +package org.mifosplatform.portfolio.client.command; + +/** + * Immutable command used for create or update of notes. + */ +public class NoteCommand { + + private final Long id; + private final Long clientId; + private final Long loanId; + private final Long loanTransactionId; + private final String note; + + public NoteCommand(final Long id, Long clientId, final String note) { + this.id = id; + this.clientId = clientId; + this.loanId = null; + this.loanTransactionId = null; + this.note = note; + } + + public Long getId() { + return id; + } + + public Long getClientId() { + return clientId; + } + + public Long getLoanId() { + return loanId; + } + + public Long getLoanTransactionId() { + return loanTransactionId; + } + + public String getNote() { + return note; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java similarity index 99% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientAccountSummaryCollectionData.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java index 3f10d668c..88726dbd1 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientAccountSummaryCollectionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.portfolio.client.data; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java new file mode 100644 index 000000000..a8dfa06e8 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java @@ -0,0 +1,30 @@ +package org.mifosplatform.portfolio.client.data; + +/** + * Immutable data object for client loan accounts. + */ +public class ClientAccountSummaryData { + + @SuppressWarnings("unused") + private final Long id; + @SuppressWarnings("unused") + private final String externalId; + @SuppressWarnings("unused") + private final Long productId; + @SuppressWarnings("unused") + private final String productName; + private final Integer accountStatusId; + + public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName, + final Integer loanStatusId) { + this.id = id; + this.externalId = externalId; + this.productId = productId; + this.productName = loanProductName; + this.accountStatusId = loanStatusId; + } + + public Integer accountStatusId() { + return accountStatusId; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientData.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java index d262c47e0..d0533d54a 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.portfolio.client.data; import java.util.Collection; import java.util.List; @@ -55,7 +55,8 @@ final public class ClientData { } final String displayName = buildDisplayNameFrom(firstnameValue, lastnameValue); - return new ClientData(officeId, null, id, firstnameValue, lastnameValue, displayName, externalId, joiningDate, null, null, null, null); + return new ClientData(officeId, null, id, firstnameValue, lastnameValue, displayName, externalId, joiningDate, null, null, null, + null); } public static ClientData integrateChanges(final ClientData clientData, ClientData currentChange, final Collection allChanges) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientIdentifierData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientIdentifierData.java new file mode 100644 index 000000000..1052dc04b --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientIdentifierData.java @@ -0,0 +1,45 @@ +package org.mifosplatform.portfolio.client.data; + +import java.util.Collection; + +import org.mifosplatform.infrastructure.codes.data.CodeValueData; + +/** + * Immutable data object represent client identity data. + */ +public class ClientIdentifierData { + + private final Long id; + private final Long clientId; + private final Long documentTypeId; + private final String documentTypeName; + private final String documentKey; + private final String description; + @SuppressWarnings("unused") + private final Collection allowedDocumentTypes; + + public static ClientIdentifierData singleItem(final Long id, final Long clientId, final Long documentTypeId, final String documentKey, + final String description, final String documentTypeName) { + return new ClientIdentifierData(id, clientId, documentTypeId, documentKey, description, documentTypeName, null); + } + + public static ClientIdentifierData template(final Collection codeValues) { + return new ClientIdentifierData(null, null, null, null, null, null, codeValues); + } + + public static ClientIdentifierData template(final ClientIdentifierData data, final Collection codeValues) { + return new ClientIdentifierData(data.id, data.clientId, data.documentTypeId, data.documentKey, data.description, + data.documentTypeName, codeValues); + } + + public ClientIdentifierData(final Long id, final Long clientId, final Long documentTypeId, final String documentKey, + final String description, final String documentTypeName, final Collection allowedDocumentTypes) { + this.id = id; + this.clientId = clientId; + this.documentTypeId = documentTypeId; + this.documentKey = documentKey; + this.description = description; + this.documentTypeName = documentTypeName; + this.allowedDocumentTypes = allowedDocumentTypes; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientLookup.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientLookup.java similarity index 97% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientLookup.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientLookup.java index b967a6fed..d93636f96 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/ClientLookup.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientLookup.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.portfolio.client.data; import org.apache.commons.lang.StringUtils; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/NoteData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/NoteData.java new file mode 100644 index 000000000..c73e0f33a --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/NoteData.java @@ -0,0 +1,52 @@ +package org.mifosplatform.portfolio.client.data; + +import org.joda.time.DateTime; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; + +/** + * Immutable data object represent note or case information about a client, loan or loan transaction. + */ +public class NoteData { + + @SuppressWarnings("unused") + private final Long id; + @SuppressWarnings("unused") + private final Long clientId; + @SuppressWarnings("unused") + private final Long loanId; + @SuppressWarnings("unused") + private final Long loanTransactionId; + @SuppressWarnings("unused") + private final EnumOptionData noteType; + @SuppressWarnings("unused") + private final String note; + @SuppressWarnings("unused") + private final Long createdById; + @SuppressWarnings("unused") + private final String createdByUsername; + @SuppressWarnings("unused") + private final DateTime createdOn; + @SuppressWarnings("unused") + private final Long updatedById; + @SuppressWarnings("unused") + private final String updatedByUsername; + @SuppressWarnings("unused") + private final DateTime updatedOn; + + public NoteData(final Long id, final Long clientId, final Long loanId, final Long transactionId, final EnumOptionData noteType, + final String note, final DateTime createdDate, final Long createdById, final String createdByUsername, + final DateTime lastModifiedDate, final Long lastModifiedById, final String updatedByUsername) { + this.id = id; + this.clientId = clientId; + this.loanId = loanId; + this.loanTransactionId = transactionId; + this.noteType = noteType; + this.note = note; + this.createdOn = createdDate; + this.createdById = createdById; + this.createdByUsername = createdByUsername; + this.updatedOn = lastModifiedDate; + this.updatedById = lastModifiedById; + this.updatedByUsername = updatedByUsername; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Client.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Client.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java index d4be97246..338ad18bf 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Client.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.client.domain; +package org.mifosplatform.portfolio.client.domain; import java.util.Date; @@ -12,10 +12,10 @@ import javax.persistence.TemporalType; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.command.ClientCommand; @Entity @Table(name = "m_client") diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientIdentifier.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientIdentifier.java new file mode 100644 index 000000000..45f86700d --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientIdentifier.java @@ -0,0 +1,85 @@ +package org.mifosplatform.portfolio.client.domain; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; + +import org.apache.commons.lang.StringUtils; +import org.mifosplatform.infrastructure.codes.domain.CodeValue; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.user.domain.AppUser; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; + +@Entity +@Table(name = "m_client_identifier", uniqueConstraints = { + @UniqueConstraint(columnNames = { "document_type_id", "document_key" }, name = "unique_identifier_key"), + @UniqueConstraint(columnNames = { "client_id", "document_type_id" }, name = "unique_client_identifier") }) +public class ClientIdentifier extends AbstractAuditableCustom { + + @ManyToOne + @JoinColumn(name = "client_id", nullable = false) + private Client client; + + @ManyToOne + @JoinColumn(name = "document_type_id", nullable = false) + private CodeValue documentType; + + @Column(name = "document_key", length = 1000) + private String documentKey; + + @Column(name = "description", length = 1000) + private String description; + + public ClientIdentifier() { + this.client = null; + this.documentType = null; + this.documentKey = null; + this.description = null; + } + + public static ClientIdentifier createNew(final Client client, final CodeValue documentType, final String documentKey, + final String description) { + return new ClientIdentifier(client, documentType, documentKey, description); + } + + private ClientIdentifier(final Client client, final CodeValue documentType, final String documentKey, final String description) { + this.client = client; + this.documentType = documentType; + this.documentKey = StringUtils.defaultIfEmpty(documentKey, null); + this.description = StringUtils.defaultIfEmpty(description, null); + } + + public void update(final ClientIdentifierCommand command, final CodeValue documentType) { + + if (command.isDocumentTypeChanged()) { + this.documentType = documentType; + } + + if (command.isDocumentKeyChanged()) { + this.documentKey = StringUtils.defaultIfEmpty(command.getDocumentKey(), null); + } + + if (command.isDescriptionChanged()) { + this.description = StringUtils.defaultIfEmpty(command.getDescription(), null); + } + } + + public Client getClient() { + return client; + } + + public CodeValue getDocumentType() { + return documentType; + } + + public String getDocumentKey() { + return documentKey; + } + + public String getDescription() { + return description; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientIdentifierRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientIdentifierRepository.java new file mode 100644 index 000000000..075bbf441 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientIdentifierRepository.java @@ -0,0 +1,8 @@ +package org.mifosplatform.portfolio.client.domain; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface ClientIdentifierRepository extends JpaRepository, JpaSpecificationExecutor { + // no behaviour +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientRepository.java similarity index 83% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientRepository.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientRepository.java index 32d6f1fb2..1bd8487c1 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/ClientRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/ClientRepository.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.client.domain; +package org.mifosplatform.portfolio.client.domain; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Note.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Note.java index 8558f9b69..693e15d29 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/Note.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Note.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.client.domain; +package org.mifosplatform.portfolio.client.domain; import javax.persistence.Column; import javax.persistence.Entity; @@ -6,10 +6,10 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosng.platform.loan.domain.Loan; import org.mifosng.platform.loan.domain.LoanTransaction; import org.mifosng.platform.saving.domain.DepositAccount; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; @Entity diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/NoteEnumerations.java similarity index 81% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/NoteEnumerations.java index 804ee579f..8fff84b5e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/NoteEnumerations.java @@ -1,7 +1,7 @@ -package org.mifosng.platform.client.domain; +package org.mifosplatform.portfolio.client.domain; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.client.domain.Note.NoteType; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.portfolio.client.domain.Note.NoteType; public class NoteEnumerations { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/NoteRepository.java similarity index 86% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteRepository.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/NoteRepository.java index 37675a17d..1537a7126 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/domain/NoteRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/NoteRepository.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.client.domain; +package org.mifosplatform.portfolio.client.domain; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientIdentifierNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientIdentifierNotFoundException.java old mode 100755 new mode 100644 similarity index 71% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientIdentifierNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientIdentifierNotFoundException.java index ab18e2296..f80a31275 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientIdentifierNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientIdentifierNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.client.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when client Identifier resources are not diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientNotFoundException.java similarity index 67% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientNotFoundException.java index 5b42f24ec..35f250fd0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ClientNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.client.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when client resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/DuplicateClientIdentifierException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/DuplicateClientIdentifierException.java new file mode 100644 index 000000000..55d0e6e32 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/DuplicateClientIdentifierException.java @@ -0,0 +1,48 @@ +package org.mifosplatform.portfolio.client.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + +/** + * A {@link RuntimeException} thrown when a client identifier of the particular + * type is already present + */ +public class DuplicateClientIdentifierException extends AbstractPlatformDomainRuleException { + + private Long documentTypeId; + private String identifierKey; + private String identifierType; + + public DuplicateClientIdentifierException(final String identifierType) { + super("error.msg.clientIdentifier.type.duplicate", "Client identifier of type " + identifierType + + " is already present for this client", identifierType); + this.identifierType = identifierType; + } + + public DuplicateClientIdentifierException(final Long documentTypeId, final String identifierType, final String identifierKey) { + super("error.msg.clientIdentifier.identityKey.duplicate", "Client identifier of type " + identifierType + " with value of " + + identifierKey + " already exists.", identifierType, identifierKey); + this.documentTypeId = documentTypeId; + this.identifierType = identifierType; + this.identifierKey = identifierKey; + } + + public DuplicateClientIdentifierException(final String clientName, final String officeName, final String identifierType, + final String identifierKey) { + super("error.msg.clientIdentifier.identityKey.duplicate", "Client " + clientName + "under " + officeName + " Branch already has a " + + identifierType + " with unique key " + identifierKey, clientName, officeName, identifierType, identifierKey); + this.identifierType = identifierType; + this.identifierKey = identifierKey; + } + + public Long getDocumentTypeId() { + return documentTypeId; + } + + public String getIdentifierKey() { + return identifierKey; + } + + public String getIdentifierType() { + return identifierType; + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ImageNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ImageNotFoundException.java new file mode 100644 index 000000000..4d34ee5e0 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/ImageNotFoundException.java @@ -0,0 +1,11 @@ +package org.mifosplatform.portfolio.client.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; + +public class ImageNotFoundException extends AbstractPlatformDomainRuleException { + + public ImageNotFoundException(final String resource, final Long resourceId) { + super("error.msg.entity.image.invalid", "Image for resource " + resource + " with Identifier " + resourceId + " does not exist", + resource, resourceId); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/NoteNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/NoteNotFoundException.java new file mode 100644 index 000000000..a7e1f745b --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/exception/NoteNotFoundException.java @@ -0,0 +1,18 @@ +package org.mifosplatform.portfolio.client.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +/** + * A {@link RuntimeException} thrown when note resources are not found. + */ +public class NoteNotFoundException extends AbstractPlatformResourceNotFoundException { + + public NoteNotFoundException(Long id) { + super("error.msg.note.id.invalid", "Note with identifier " + id + " does not exist", id); + } + + public NoteNotFoundException(Long id, Long clientId, final String resource) { + super("error.msg." + resource + ".note.id.invalid", "Note with identifier " + id + " does not exist for " + resource + + " with identifier " + clientId, id, clientId); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformService.java similarity index 69% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformService.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformService.java index f1fb0ea1e..a89eead91 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformService.java @@ -1,13 +1,13 @@ -package org.mifosng.platform.client.service; +package org.mifosplatform.portfolio.client.service; import java.util.Collection; -import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData; -import org.mifosng.platform.api.data.ClientAccountSummaryData; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.data.ClientIdentifierData; -import org.mifosng.platform.api.data.ClientLookup; -import org.mifosng.platform.api.data.NoteData; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.data.ClientIdentifierData; +import org.mifosplatform.portfolio.client.data.ClientLookup; +import org.mifosplatform.portfolio.client.data.NoteData; public interface ClientReadPlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java similarity index 93% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java index 8fa34edc8..014561cda 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.client.service; +package org.mifosplatform.portfolio.client.service; import java.sql.ResultSet; import java.sql.SQLException; @@ -9,25 +9,25 @@ import java.util.List; import org.apache.commons.lang.StringUtils; import org.joda.time.DateTime; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData; -import org.mifosng.platform.api.data.ClientAccountSummaryData; -import org.mifosng.platform.api.data.ClientData; -import org.mifosng.platform.api.data.ClientIdentifierData; -import org.mifosng.platform.api.data.ClientLookup; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.api.data.NoteData; -import org.mifosng.platform.client.domain.NoteEnumerations; -import org.mifosng.platform.exceptions.ClientIdentifierNotFoundException; -import org.mifosng.platform.exceptions.ClientNotFoundException; -import org.mifosng.platform.exceptions.NoteNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.office.data.OfficeLookup; import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.user.api.data.AppUserData; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.infrastructure.user.service.AppUserReadPlatformService; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryCollectionData; +import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.data.ClientIdentifierData; +import org.mifosplatform.portfolio.client.data.ClientLookup; +import org.mifosplatform.portfolio.client.data.NoteData; +import org.mifosplatform.portfolio.client.domain.NoteEnumerations; +import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; +import org.mifosplatform.portfolio.client.exception.NoteNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; @@ -201,7 +201,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService if (results != null) { for (ClientAccountSummaryData row : results) { - LoanStatusMapper statusMapper = new LoanStatusMapper(row.getAccountStatusId()); + LoanStatusMapper statusMapper = new LoanStatusMapper(row.accountStatusId()); if (statusMapper.isOpen()) { openLoans.add(row); @@ -231,19 +231,19 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService if (depositAccountResults != null) { for (ClientAccountSummaryData row : depositAccountResults) { - if (row.getAccountStatusId() == 100) { + if (row.accountStatusId() == 100) { pendingApprovalDepositAccounts.add(row); - } else if (row.getAccountStatusId() == 300) { + } else if (row.accountStatusId() == 300) { approvedDepositAccounts.add(row); - } else if (row.getAccountStatusId() == 400) { + } else if (row.accountStatusId() == 400) { withdrawnByClientDespositAccounts.add(row); - } else if (row.getAccountStatusId() == 500) { + } else if (row.accountStatusId() == 500) { rejectedDepositAccounts.add(row); - } else if (row.getAccountStatusId() == 600) { + } else if (row.accountStatusId() == 600) { closedDepositAccounts.add(row); - } else if (row.getAccountStatusId() == 700) { + } else if (row.accountStatusId() == 700) { maturedDepositAccounts.add(row); - } else if (row.getAccountStatusId() == 800) { + } else if (row.accountStatusId() == 800) { preclosedDepositAccounts.add(row); } } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformService.java similarity index 60% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformService.java index 2f0cb44e7..4346b67c0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformService.java @@ -1,12 +1,12 @@ -package org.mifosng.platform.client.service; +package org.mifosplatform.portfolio.client.service; import java.io.InputStream; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.commands.ClientIdentifierCommand; -import org.mifosng.platform.api.commands.NoteCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.infrastructure.Base64EncodedImage; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; +import org.mifosplatform.portfolio.client.command.NoteCommand; import org.springframework.security.access.prepost.PreAuthorize; public interface ClientWritePlatformService { @@ -32,12 +32,9 @@ public interface ClientWritePlatformService { @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTNOTE')") EntityIdentifier updateNote(NoteCommand command); - @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIDENTIFIER')") - Long addClientIdentifier(ClientIdentifierCommand clientIdentifierCommand); + Long addClientIdentifier(ClientIdentifierCommand command); - @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTIDENTIFIER')") - EntityIdentifier updateClientIdentifier(ClientIdentifierCommand clientIdentifierCommand); + EntityIdentifier updateClientIdentifier(ClientIdentifierCommand command); - @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIDENTIFIER')") - EntityIdentifier deleteClientIdentifier(Long clientIdentifierId); + EntityIdentifier deleteClientIdentifier(ClientIdentifierCommand command); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java similarity index 90% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java index 20cab9c25..c1e7a8951 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java @@ -1,36 +1,38 @@ -package org.mifosng.platform.client.service; +package org.mifosplatform.portfolio.client.service; import java.io.File; import java.io.IOException; import java.io.InputStream; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.commands.ClientCommand; -import org.mifosng.platform.api.commands.ClientIdentifierCommand; -import org.mifosng.platform.api.commands.NoteCommand; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.client.domain.Client; -import org.mifosng.platform.client.domain.ClientIdentifier; -import org.mifosng.platform.client.domain.ClientIdentifierRepository; -import org.mifosng.platform.client.domain.ClientRepository; -import org.mifosng.platform.client.domain.Note; -import org.mifosng.platform.client.domain.NoteRepository; -import org.mifosng.platform.exceptions.ClientIdentifierNotFoundException; -import org.mifosng.platform.exceptions.ClientNotFoundException; import org.mifosng.platform.exceptions.DocumentManagementException; -import org.mifosng.platform.exceptions.DuplicateClientIdentifierException; -import org.mifosng.platform.exceptions.NoteNotFoundException; -import org.mifosng.platform.exceptions.OfficeNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.infrastructure.Base64EncodedImage; -import org.mifosng.platform.infrastructure.FileUtils; import org.mifosplatform.infrastructure.codes.domain.CodeValue; import org.mifosplatform.infrastructure.codes.domain.CodeValueRepository; import org.mifosplatform.infrastructure.codes.exception.CodeValueNotFoundException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; +import org.mifosplatform.infrastructure.core.service.FileUtils; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.office.domain.OfficeRepository; +import org.mifosplatform.infrastructure.office.exception.OfficeNotFoundException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.command.ClientCommand; +import org.mifosplatform.portfolio.client.command.ClientCommandValidator; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; +import org.mifosplatform.portfolio.client.command.ClientIdentifierCommandValidator; +import org.mifosplatform.portfolio.client.command.NoteCommand; +import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.client.domain.ClientIdentifier; +import org.mifosplatform.portfolio.client.domain.ClientIdentifierRepository; +import org.mifosplatform.portfolio.client.domain.ClientRepository; +import org.mifosplatform.portfolio.client.domain.Note; +import org.mifosplatform.portfolio.client.domain.NoteRepository; +import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; +import org.mifosplatform.portfolio.client.exception.DuplicateClientIdentifierException; +import org.mifosplatform.portfolio.client.exception.NoteNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -296,12 +298,12 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP @Transactional @Override - public EntityIdentifier deleteClientIdentifier(final Long clientIdentifierId) { - final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(clientIdentifierId); - if (clientIdentifier == null) { throw new ClientIdentifierNotFoundException(clientIdentifierId); } + public EntityIdentifier deleteClientIdentifier(final ClientIdentifierCommand command) { + final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(command.getId()); + if (clientIdentifier == null) { throw new ClientIdentifierNotFoundException(command.getId()); } this.clientIdentifierRepository.delete(clientIdentifier); - return new EntityIdentifier(clientIdentifierId); + return new EntityIdentifier(command.getId()); } @Transactional diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/LoanStatusMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/LoanStatusMapper.java new file mode 100644 index 000000000..c45d09d5b --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/LoanStatusMapper.java @@ -0,0 +1,34 @@ +package org.mifosplatform.portfolio.client.service; + +public class LoanStatusMapper { + + private final Integer statusId; + + public LoanStatusMapper(Integer statusId) { + this.statusId = statusId; + } + + public boolean isPendingApproval() { + return Integer.valueOf(100).equals(statusId); + } + + public boolean isAwaitingDisbursal() { + return Integer.valueOf(200).equals(statusId); + } + + public boolean isOpen() { + return Integer.valueOf(300).equals(statusId); + } + + public boolean isWithdrawnByClient() { + return Integer.valueOf(400).equals(statusId); + } + + public boolean isRejected() { + return Integer.valueOf(500).equals(statusId); + } + + public boolean isClosed() { + return Integer.valueOf(600).equals(statusId) || isWithdrawnByClient() || isRejected(); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/RollbackTransactionAsCommandIsNotApprovedByCheckerException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/RollbackTransactionAsCommandIsNotApprovedByCheckerException.java similarity index 66% rename from mifosng-provider/src/main/java/org/mifosng/platform/client/service/RollbackTransactionAsCommandIsNotApprovedByCheckerException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/RollbackTransactionAsCommandIsNotApprovedByCheckerException.java index 17a9f206b..a23f95c0e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/RollbackTransactionAsCommandIsNotApprovedByCheckerException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/RollbackTransactionAsCommandIsNotApprovedByCheckerException.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.client.service; +package org.mifosplatform.portfolio.client.service; public class RollbackTransactionAsCommandIsNotApprovedByCheckerException extends RuntimeException { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java index 03940c5ec..533e683cc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/api/FundsApiResource.java @@ -16,12 +16,12 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +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.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.fund.data.FundData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/command/FundCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/command/FundCommand.java index b9921c26d..cb476d16e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/command/FundCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/command/FundCommand.java @@ -4,9 +4,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; /** * Immutable command for creating or updating details of a fund. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/domain/Fund.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/domain/Fund.java index 63f33e700..ab2c188b4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/domain/Fund.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/domain/Fund.java @@ -6,7 +6,7 @@ import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.fund.command.FundCommand; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/exception/FundNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/exception/FundNotFoundException.java new file mode 100644 index 000000000..c8a1bad19 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/exception/FundNotFoundException.java @@ -0,0 +1,13 @@ +package org.mifosplatform.portfolio.fund.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +/** + * A {@link RuntimeException} thrown when fund resources are not found. + */ +public class FundNotFoundException extends AbstractPlatformResourceNotFoundException { + + public FundNotFoundException(final Long id) { + super("error.msg.fund.id.invalid", "Fund with identifier " + id + " does not exist", id); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java index f4c0c08ab..811e9d282 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundReadPlatformServiceImpl.java @@ -4,10 +4,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import org.mifosng.platform.exceptions.FundNotFoundException; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.fund.data.FundData; +import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java index 5233e333c..000268c47 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/fund/service/FundWritePlatformServiceJpaRepositoryImpl.java @@ -1,13 +1,13 @@ package org.mifosplatform.portfolio.fund.service; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.FundNotFoundException; -import org.mifosng.platform.exceptions.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.portfolio.fund.command.FundCommand; import org.mifosplatform.portfolio.fund.domain.Fund; import org.mifosplatform.portfolio.fund.domain.FundRepository; +import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java index bc55233d5..952c9eba4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -16,15 +16,15 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriInfo; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService; -import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService; -import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService; -import org.mifosng.platform.infrastructure.api.ApiParameterHelper; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService; +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.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java index 00a0a3f3a..2509371af 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java @@ -6,8 +6,8 @@ import java.util.Collection; import java.util.List; import org.joda.time.DateTime; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.fund.data.FundData; import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java index 4649fd2c1..a992eec8c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProduct.java @@ -13,8 +13,8 @@ import javax.persistence.ManyToOne; import javax.persistence.Table; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.fund.domain.Fund; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java index 41a858093..43752cb46 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanTransactionProcessingStrategy.java @@ -4,7 +4,7 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; -import org.mifosng.platform.infrastructure.AbstractAuditableCustom; +import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidCurrencyException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/exception/InvalidCurrencyException.java similarity index 50% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidCurrencyException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/exception/InvalidCurrencyException.java index 748c644e2..f64202ee1 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidCurrencyException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/exception/InvalidCurrencyException.java @@ -1,12 +1,14 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.loanproduct.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException; /** - * {@link AbstractPlatformDomainRuleException} thrown when currency mismatch occurs + * {@link AbstractPlatformDomainRuleException} thrown when currency mismatch + * occurs */ public class InvalidCurrencyException extends AbstractPlatformDomainRuleException { public InvalidCurrencyException(final String entity, final String postFix, String defaultUserMessage, Object... defaultUserMessageArgs) { - super("error.msg."+entity+"."+postFix+".invalid.currency", defaultUserMessage, defaultUserMessageArgs); + super("error.msg." + entity + "." + postFix + ".invalid.currency", defaultUserMessage, defaultUserMessageArgs); } - -} +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/exception/LoanProductNotFoundException.java similarity index 68% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/exception/LoanProductNotFoundException.java index 35001c79e..9c308795f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/exception/LoanProductNotFoundException.java @@ -1,4 +1,6 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.loanproduct.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; /** * A {@link RuntimeException} thrown when loan product resources are not found. diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java index fd97341cc..312dce8b9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformService.java @@ -3,7 +3,7 @@ package org.mifosplatform.portfolio.loanproduct.service; import java.util.Collection; import java.util.List; -import org.mifosng.platform.api.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData; public interface LoanDropdownReadPlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java index 83a208e56..f1b70f4b0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java @@ -12,8 +12,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.loan.domain.LoanTransactionProcessingStrategyRepository; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrategyData; import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestCalculationPeriodMethod; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java index 0bdbc2028..2e9df2299 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanEnumerations.java @@ -1,8 +1,8 @@ package org.mifosplatform.portfolio.loanproduct.service; -import org.mifosng.platform.api.data.EnumOptionData; import org.mifosng.platform.loan.domain.LoanStatus; import org.mifosng.platform.loan.domain.LoanTransactionType; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestCalculationPeriodMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestMethod; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductCommandValidator.java index 28b8363a0..2a310a984 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductCommandValidator.java @@ -3,9 +3,9 @@ package org.mifosplatform.portfolio.loanproduct.service; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.DataValidatorBuilder; -import org.mifosng.platform.api.data.ApiParameterError; -import org.mifosng.platform.exceptions.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; public class LoanProductCommandValidator { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java index 97197c5d7..9074c1ab7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java @@ -6,15 +6,15 @@ import java.sql.SQLException; import java.util.Collection; import org.joda.time.DateTime; -import org.mifosng.platform.api.data.EnumOptionData; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; -import org.mifosng.platform.infrastructure.JdbcSupport; -import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; +import org.mifosplatform.infrastructure.core.domain.JdbcSupport; +import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformService.java index 1fca75482..23850024d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformService.java @@ -1,6 +1,6 @@ package org.mifosplatform.portfolio.loanproduct.service; -import org.mifosng.platform.api.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; public interface LoanProductWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java index 7baa19d81..91f77d69c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductWritePlatformServiceJpaRepositoryImpl.java @@ -4,23 +4,21 @@ import java.math.BigDecimal; import java.util.HashSet; import java.util.Set; -import org.mifosng.platform.api.data.EntityIdentifier; -import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; -import org.mifosng.platform.exceptions.ChargeIsNotActiveException; -import org.mifosng.platform.exceptions.ChargeNotFoundException; -import org.mifosng.platform.exceptions.FundNotFoundException; -import org.mifosng.platform.exceptions.InvalidCurrencyException; -import org.mifosng.platform.exceptions.LoanProductNotFoundException; import org.mifosng.platform.exceptions.LoanTransactionProcessingStrategyNotFoundException; import org.mifosng.platform.loan.domain.LoanTransactionProcessingStrategyRepository; import org.mifosng.platform.loanschedule.domain.AprCalculator; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.service.ConfigurationDomainService; +import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.ChargeRepository; +import org.mifosplatform.portfolio.charge.exception.ChargeIsNotActiveException; +import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; +import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException; import org.mifosplatform.portfolio.fund.domain.Fund; import org.mifosplatform.portfolio.fund.domain.FundRepository; +import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; import org.mifosplatform.portfolio.loanproduct.command.LoanProductCommand; import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestCalculationPeriodMethod; @@ -29,6 +27,8 @@ import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct; import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository; import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy; import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType; +import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException; +import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml b/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml index 6d3b2a4a9..5f2effc96 100644 --- a/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml +++ b/mifosng-provider/src/main/resources/META-INF/spring/appContext.xml @@ -15,13 +15,13 @@ - - + diff --git a/mifosng-provider/src/main/webapp/WEB-INF/web.xml b/mifosng-provider/src/main/webapp/WEB-INF/web.xml index c8e661683..1c267f4be 100644 --- a/mifosng-provider/src/main/webapp/WEB-INF/web.xml +++ b/mifosng-provider/src/main/webapp/WEB-INF/web.xml @@ -45,14 +45,10 @@ com.sun.jersey.spi.container.ContainerRequestFilters com.sun.jersey.api.container.filter.LoggingFilter - - com.sun.jersey.spi.container.ContainerResponseFilters - com.sun.jersey.api.container.filter.LoggingFilter, org.mifosng.platform.filters.ResponseCorsFilter - --> com.sun.jersey.spi.container.ContainerResponseFilters - org.mifosng.platform.filters.ResponseCorsFilter + org.mifosplatform.infrastructure.core.filters.ResponseCorsFilter 1