fix permissions small repackaging on command related classes into future package structure of org.mifosplatform

This commit is contained in:
Keith Woodlock
2012-11-27 00:48:12 +00:00
parent 65206daf30
commit 71d573cae0
26 changed files with 92 additions and 88 deletions
@@ -26,7 +26,6 @@ import org.apache.commons.lang.StringUtils;
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.CommandSourceData;
import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.api.data.NoteData;
import org.mifosng.platform.api.data.OfficeLookup;
@@ -39,10 +38,11 @@ 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.mifosng.platform.makerchecker.service.PortfolioCommandSourceWritePlatformService;
import org.mifosng.platform.makerchecker.service.PortfolioCommandsReadPlatformService;
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandSourceWritePlatformService;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandsReadPlatformService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,7 +19,6 @@ import javax.ws.rs.core.UriInfo;
import org.mifosng.platform.api.commands.RoleCommand;
import org.mifosng.platform.api.commands.RolePermissionCommand;
import org.mifosng.platform.api.data.CommandSourceData;
import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.api.data.PermissionUsageData;
import org.mifosng.platform.api.data.RoleData;
@@ -27,11 +26,12 @@ import org.mifosng.platform.api.data.RolePermissionsData;
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService;
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
import org.mifosng.platform.makerchecker.service.PortfolioCommandSourceWritePlatformService;
import org.mifosng.platform.makerchecker.service.PortfolioCommandsReadPlatformService;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.user.service.PermissionReadPlatformService;
import org.mifosng.platform.user.service.RoleReadPlatformService;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandSourceWritePlatformService;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandsReadPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -23,10 +23,10 @@ import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.api.data.OfficeLookup;
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
import org.mifosng.platform.makerchecker.service.PortfolioCommandSourceWritePlatformService;
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.user.service.AppUserReadPlatformService;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandSourceWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -5,36 +5,39 @@ package org.mifosng.platform.api.data;
*/
public class EntityIdentifier {
private Long entityId;
@SuppressWarnings("unused")
private Long makerCheckerId;
private Long entityId;
public static EntityIdentifier makerChecker(final Long makerCheckerId) {
return new EntityIdentifier(null, makerCheckerId);
}
public static EntityIdentifier makerChecker(final Long resourceId, final Long makerCheckerId) {
return new EntityIdentifier(resourceId, makerCheckerId);
}
public EntityIdentifier() {
//
}
// TODO - Rename variable to commandId or taskId or something that shows
// this is the id of a command in a table/queue for processing.
@SuppressWarnings("unused")
private Long makerCheckerId;
public EntityIdentifier(final Long entityId) {
this.entityId = entityId;
}
private EntityIdentifier(final Long entityId, final Long makerCheckerId) {
this.entityId = entityId;
this.makerCheckerId = makerCheckerId;
}
public static EntityIdentifier makerChecker(final Long makerCheckerId) {
return new EntityIdentifier(null, makerCheckerId);
}
public Long getEntityId() {
return this.entityId;
}
public static EntityIdentifier makerChecker(final Long resourceId, final Long makerCheckerId) {
return new EntityIdentifier(resourceId, makerCheckerId);
}
public void setEntityId(final Long entityId) {
this.entityId = entityId;
}
public EntityIdentifier() {
//
}
public EntityIdentifier(final Long entityId) {
this.entityId = entityId;
}
private EntityIdentifier(final Long entityId, final Long makerCheckerId) {
this.entityId = entityId;
this.makerCheckerId = makerCheckerId;
}
public Long getEntityId() {
return this.entityId;
}
public void setEntityId(final Long entityId) {
this.entityId = entityId;
}
}
@@ -14,7 +14,6 @@ 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.CodeData;
import org.mifosng.platform.api.data.CommandSourceData;
import org.mifosng.platform.api.data.ConfigurationData;
import org.mifosng.platform.api.data.DatatableData;
import org.mifosng.platform.api.data.DepositAccountData;
@@ -42,6 +41,7 @@ import org.mifosng.platform.api.data.SavingAccountData;
import org.mifosng.platform.api.data.SavingProductData;
import org.mifosng.platform.api.data.StaffData;
import org.mifosng.platform.infrastructure.api.GoogleGsonSerializerHelper;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -12,7 +12,6 @@ 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.CodeData;
import org.mifosng.platform.api.data.CommandSourceData;
import org.mifosng.platform.api.data.ConfigurationData;
import org.mifosng.platform.api.data.DatatableData;
import org.mifosng.platform.api.data.DepositAccountData;
@@ -39,6 +38,7 @@ import org.mifosng.platform.api.data.RolePermissionsData;
import org.mifosng.platform.api.data.SavingAccountData;
import org.mifosng.platform.api.data.SavingProductData;
import org.mifosng.platform.api.data.StaffData;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
public interface PortfolioApiJsonSerializerService {
@@ -1,5 +0,0 @@
package org.mifosng.platform.makerchecker.service;
public interface CommandSourceHandler {
}
@@ -1,10 +0,0 @@
package org.mifosng.platform.makerchecker.service;
public interface PortfolioMakerCheckerWriteService {
//TODO - permissions on this to be done after development completes
Long logNewEntry(String taskName, String taskJson);
Long approveEntry(Long id);
}
@@ -357,10 +357,14 @@ public class AppUser extends AbstractAuditableCustom<AppUser, Long> implements P
return getId().equals(userId);
}
private boolean hasAnyPermission(final List<String> requiredPermissions) {
private boolean hasNotAnyPermission(final List<String> permissions) {
return !hasAnyPermission(permissions);
}
private boolean hasAnyPermission(final List<String> permissions) {
boolean hasAtLeastOneOf = false;
for (final String permissionCode : requiredPermissions) {
for (final String permissionCode : permissions) {
if (hasPermissionTo(permissionCode)) {
hasAtLeastOneOf = true;
break;
@@ -371,7 +375,7 @@ public class AppUser extends AbstractAuditableCustom<AppUser, Long> implements P
}
public void validateHasPermissionTo(final String function, final List<String> allowedPermissions) {
if (hasAnyPermission(allowedPermissions)) {
if (hasNotAnyPermission(allowedPermissions)) {
final String authorizationMessage = "User has no authority to: " + function;
throw new NoAuthorizationException(authorizationMessage);
}
@@ -4,6 +4,6 @@ import org.mifosng.platform.infrastructure.PlatformUser;
public interface PlatformUserRepository {
PlatformUser findByUsername(String username);
PlatformUser findByUsername(String username);
}
@@ -1,4 +1,4 @@
package org.mifosng.platform.api;
package org.mifosplatform.infrastructure.commands.api;
import java.util.Collection;
import java.util.Set;
@@ -17,13 +17,13 @@ import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils;
import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.api.data.CommandSourceData;
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
import org.mifosng.platform.exceptions.UnrecognizedQueryParamException;
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.makerchecker.service.PortfolioCommandsReadPlatformService;
import org.mifosng.platform.makerchecker.service.PortfolioCommandSourceWritePlatformService;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandSourceWritePlatformService;
import org.mifosplatform.infrastructure.commands.service.PortfolioCommandsReadPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@@ -62,15 +62,15 @@ public class CommandsApiResource {
}
@POST
@Path("{makerCheckerId}")
@Path("{commandId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String approveMakerCheckerEntry(@PathParam("makerCheckerId") final Long makerCheckerId,
public String approveMakerCheckerEntry(@PathParam("commandId") final Long commandId,
@QueryParam("command") final String commandParam) {
EntityIdentifier result = null;
if (is(commandParam, "approve")) {
result = this.writePlatformService.approveEntry(makerCheckerId);
result = this.writePlatformService.approveEntry(commandId);
} else {
throw new UnrecognizedQueryParamException("command", commandParam);
}
@@ -83,12 +83,12 @@ public class CommandsApiResource {
}
@DELETE
@Path("{makerCheckerId}")
@Path("{commandId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String deleteMakerCheckerEntry(@PathParam("makerCheckerId") final Long makerCheckerId) {
public String deleteMakerCheckerEntry(@PathParam("commandId") final Long commandId) {
final Long id = this.writePlatformService.deleteEntry(makerCheckerId);
final Long id = this.writePlatformService.deleteEntry(commandId);
return this.apiJsonSerializerService.serializeEntityIdentifier(EntityIdentifier.makerChecker(id));
}
@@ -1,4 +1,4 @@
package org.mifosng.platform.api.data;
package org.mifosplatform.infrastructure.commands.api.data;
import org.joda.time.LocalDate;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.domain;
package org.mifosplatform.infrastructure.commands.domain;
import java.util.Date;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.domain;
package org.mifosplatform.infrastructure.commands.domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.handler;
import java.util.Arrays;
import java.util.List;
@@ -10,9 +10,10 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
import org.mifosng.platform.client.service.ClientWritePlatformService;
import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.user.domain.AppUser;
import org.mifosplatform.infrastructure.commands.domain.CommandSource;
import org.mifosplatform.infrastructure.commands.service.ChangeDetectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -0,0 +1,5 @@
package org.mifosplatform.infrastructure.commands.handler;
public interface CommandSourceHandler {
}
@@ -1,8 +1,8 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.handler;
import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException;
import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosplatform.infrastructure.commands.domain.CommandSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.handler;
import java.util.Arrays;
import java.util.List;
@@ -11,10 +11,11 @@ import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerServi
import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService;
import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException;
import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.user.domain.AppUser;
import org.mifosng.platform.user.service.RoleWritePlatformService;
import org.mifosplatform.infrastructure.commands.domain.CommandSource;
import org.mifosplatform.infrastructure.commands.service.ChangeDetectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.handler;
import java.util.Arrays;
import java.util.List;
@@ -9,10 +9,11 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService
import org.mifosng.platform.api.infrastructure.PortfolioCommandDeserializerService;
import org.mifosng.platform.api.infrastructure.PortfolioCommandSerializerService;
import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.user.domain.AppUser;
import org.mifosng.platform.user.service.AppUserWritePlatformService;
import org.mifosplatform.infrastructure.commands.domain.CommandSource;
import org.mifosplatform.infrastructure.commands.service.ChangeDetectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.service;
public interface ChangeDetectionService {
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.service;
import org.mifosng.platform.api.commands.ClientCommand;
import org.mifosng.platform.api.data.ClientData;
@@ -1,4 +1,4 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.service;
import org.mifosng.platform.api.data.EntityIdentifier;
@@ -1,15 +1,17 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.service;
import org.joda.time.LocalDate;
import org.mifosng.platform.api.data.EntityIdentifier;
import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.makerchecker.domain.CommandSourceRepository;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosng.platform.user.domain.AppUser;
import org.mifosplatform.infrastructure.commands.domain.CommandSource;
import org.mifosplatform.infrastructure.commands.domain.CommandSourceRepository;
import org.mifosplatform.infrastructure.commands.handler.CommandSourceHandlerDelegator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
// TODO RENAME SO matches interface name
@Service
public class PortfolioCommandSourceWriteServiceImpl implements PortfolioCommandSourceWritePlatformService {
@@ -1,8 +1,8 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.service;
import java.util.Collection;
import org.mifosng.platform.api.data.CommandSourceData;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
public interface PortfolioCommandsReadPlatformService {
@@ -1,14 +1,14 @@
package org.mifosng.platform.makerchecker.service;
package org.mifosplatform.infrastructure.commands.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import org.joda.time.LocalDate;
import org.mifosng.platform.api.data.CommandSourceData;
import org.mifosng.platform.infrastructure.JdbcSupport;
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.mifosplatform.infrastructure.commands.api.data.CommandSourceData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
@@ -16,7 +16,8 @@
<tx:annotation-driven />
<context:component-scan base-package="org.mifosng.platform.security, org.mifosng.platform.infrastructure,
org.mifosng.platform.*.domain, org.mifosng.platform">
org.mifosng.platform.*.domain, org.mifosng.platform,
org.mifosplatform.*.*.service, org.mifosplatform.*.*.domain, org.mifosplatform">
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation" />
</context:component-scan>
@@ -24,6 +25,7 @@
<jpa:auditing auditor-aware-ref="auditorAware" />
<jpa:repositories base-package="org.mifosng.platform.*.domain" />
<jpa:repositories base-package="org.mifosplatform.infrastructure.commands.domain" />
<import resource="infrastructure.xml" />