MIFOSX-97: refactor into command handling logic, prepare for sql based approach for change detection.

This commit is contained in:
Keith Woodlock
2012-11-21 14:23:16 +00:00
parent b8961d7914
commit 9aa9b870f0
16 changed files with 2731 additions and 2920 deletions
@@ -2,9 +2,9 @@ package org.mifosng.platform.api.infrastructure;
public class ApiConstants { public class ApiConstants {
// TODO:Vishwas Need to move these settings to the Database // TODO:Vishwas Need to move these settings to the Database
public static final Integer MAX_FILE_UPLOAD_SIZE_IN_MB = 5; public static final Integer MAX_FILE_UPLOAD_SIZE_IN_MB = 5;
// TODO:Vishwas Need to move these settings to the Database // TODO:Vishwas Need to move these settings to the Database
public static final Integer MAX_IMAGE_UPLOAD_SIZE_IN_MB = 1; public static final Integer MAX_IMAGE_UPLOAD_SIZE_IN_MB = 1;
} }
@@ -34,66 +34,65 @@ public interface PortfolioApiDataConversionService {
ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json); ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json);
FundCommand convertJsonToFundCommand(Long resourceIdentifier, String json); FundCommand convertJsonToFundCommand(Long resourceIdentifier, String json);
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json); OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json); RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json);
UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json); UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json);
BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(String json); BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(String json);
LoanProductCommand convertJsonToLoanProductCommand(Long resourceIdentifier, String json); LoanProductCommand convertJsonToLoanProductCommand(Long resourceIdentifier, String json);
SavingProductCommand convertJsonToSavingProductCommand(Long resourceIdentifier, String json); SavingProductCommand convertJsonToSavingProductCommand(Long resourceIdentifier, String json);
DepositProductCommand convertJsonToDepositProductCommand(Long resourceIdentifier, String json); DepositProductCommand convertJsonToDepositProductCommand(Long resourceIdentifier, String json);
ClientCommand convertApiRequestJsonToClientCommand(Long resourceIdentifier, String json); ClientCommand convertApiRequestJsonToClientCommand(Long resourceIdentifier, String json);
ClientCommand convertInternalJsonFormatToClientCommand(Long resourceIdentifier, String json, boolean checkerApproved); ClientCommand convertInternalJsonFormatToClientCommand(Long resourceIdentifier, String json, boolean checkerApproved);
ClientData convertInternalJsonFormatToClientDataChange(Long clientId, String json); ClientData convertInternalJsonFormatToClientDataChange(Long clientId, String json);
ClientCommand detectChanges(Long resourceId, String baseJson, String workingJson); ClientCommand detectChanges(Long resourceId, String baseJson, String workingJson);
GroupCommand convertJsonToGroupCommand(Long resourceIdentifier, String json); GroupCommand convertJsonToGroupCommand(Long resourceIdentifier, String json);
LoanApplicationCommand convertJsonToLoanApplicationCommand(Long resourceIdentifier, String json); LoanApplicationCommand convertJsonToLoanApplicationCommand(Long resourceIdentifier, String json);
LoanChargeCommand convertJsonToLoanChargeCommand(Long loanChargeId, Long loanId, String json); LoanChargeCommand convertJsonToLoanChargeCommand(Long loanChargeId, Long loanId, String json);
LoanStateTransitionCommand convertJsonToLoanStateTransitionCommand(Long resourceIdentifier, String json); LoanStateTransitionCommand convertJsonToLoanStateTransitionCommand(Long resourceIdentifier, String json);
LoanTransactionCommand convertJsonToLoanTransactionCommand(Long resourceIdentifier, String json); LoanTransactionCommand convertJsonToLoanTransactionCommand(Long resourceIdentifier, String json);
AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand( AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand(Long loanId, Long transactionId, String json);
Long loanId, Long transactionId, String json);
OrganisationCurrencyCommand convertJsonToOrganisationCurrencyCommand(String json); OrganisationCurrencyCommand convertJsonToOrganisationCurrencyCommand(String json);
NoteCommand convertJsonToNoteCommand(Long resourceIdentifier, Long clientId, String json); NoteCommand convertJsonToNoteCommand(Long resourceIdentifier, Long clientId, String json);
DepositAccountCommand convertJsonToDepositAccountCommand(Long resourceIdentifier, String json); DepositAccountCommand convertJsonToDepositAccountCommand(Long resourceIdentifier, String json);
DepositStateTransitionCommand convertJsonToDepositStateTransitionCommand(Long resourceIdentifier, String json); DepositStateTransitionCommand convertJsonToDepositStateTransitionCommand(Long resourceIdentifier, String json);
DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(Long resourceIdentifier, String json); DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(Long resourceIdentifier, String json);
StaffCommand convertJsonToStaffCommand(Long resourceIdentifier, String json); StaffCommand convertJsonToStaffCommand(Long resourceIdentifier, String json);
LoanReassignmentCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json); LoanReassignmentCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json);
LoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(String json); LoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(String json);
DepositAccountWithdrawalCommand convertJsonToDepositWithdrawalCommand(Long resourceIdentifier, String json); DepositAccountWithdrawalCommand convertJsonToDepositWithdrawalCommand(Long resourceIdentifier, String json);
DepositAccountWithdrawInterestCommand convertJsonToDepositAccountWithdrawInterestCommand(Long resourceIdentifier, String json); DepositAccountWithdrawInterestCommand convertJsonToDepositAccountWithdrawInterestCommand(Long resourceIdentifier, String json);
ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json); ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json);
CodeCommand convertJsonToCodeCommand(Long resourceIdentifier, String json); CodeCommand convertJsonToCodeCommand(Long resourceIdentifier, String json);
SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier,String json); SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier, String json);
} }
@@ -42,114 +42,121 @@ import org.mifosng.platform.api.data.StaffData;
public interface PortfolioApiJsonSerializerService { public interface PortfolioApiJsonSerializerService {
String serializeAuthenticatedUserDataToJson(boolean prettyPrint, AuthenticatedUserData authenticatedUserData); String serializeAuthenticatedUserDataToJson(boolean prettyPrint, AuthenticatedUserData authenticatedUserData);
String serializeGenericResultsetDataToJson(boolean prettyPrint, GenericResultsetData result); String serializeGenericResultsetDataToJson(boolean prettyPrint, GenericResultsetData result);
String serializeAdditionalFieldsSetDataToJson(boolean prettyPrint, Collection<AdditionalFieldsSetData> result); String serializeAdditionalFieldsSetDataToJson(boolean prettyPrint, Collection<AdditionalFieldsSetData> result);
String serializeDatatableDataToJson(boolean prettyPrint, Collection<DatatableData> result); String serializeDatatableDataToJson(boolean prettyPrint, Collection<DatatableData> result);
String serializePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<PermissionData> permissions); String serializePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<PermissionData> permissions);
String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<RoleData> roles); String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<RoleData> roles);
String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, RoleData role); String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, RoleData role);
String serializeRolePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, RolePermissionData rolePermissionData); String serializeRolePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, RolePermissionData rolePermissionData);
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<AppUserData> users); String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<AppUserData> users);
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, AppUserData user); String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, AppUserData user);
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeData> offices); String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeData> offices);
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office); String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office);
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeTransactionData> officeTransactions); String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters,
Collection<OfficeTransactionData> officeTransactions);
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransaction); String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransaction);
String serializeConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData configuration); String serializeConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData configuration);
String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<FundData> funds); String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<FundData> funds);
String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, FundData fund); String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, FundData fund);
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<LoanProductData> products); String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<LoanProductData> products);
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanProductData loanProduct); String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanProductData loanProduct);
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingProductData> products); String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingProductData> products);
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingProductData savingProduct); String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingProductData savingProduct);
String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositProductData> products); String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositProductData> products);
String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositProductData depositProduct); String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositProductData depositProduct);
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositAccountData> accounts); String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositAccountData> accounts);
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositAccountData account); String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositAccountData account);
String serializeClientCommandToJson(ClientCommand command); String serializeClientCommandToJson(ClientCommand command);
String serializeClientDataToJson(ClientData clientData); String serializeClientDataToJson(ClientData clientData);
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData); String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData);
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientData> clients); String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientData> clients);
String serializeClientAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientAccountSummaryCollectionData clientAccount); String serializeClientAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters,
ClientAccountSummaryCollectionData clientAccount);
String serializeGroupAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters, GroupAccountSummaryCollectionData groupAccount); String serializeGroupAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters,
GroupAccountSummaryCollectionData groupAccount);
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<GroupData> groups); String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<GroupData> groups);
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, GroupData group); String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, GroupData group);
String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<NoteData> notes); String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<NoteData> notes);
String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, NoteData note); String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, NoteData note);
String serializeLoanScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanScheduleData loanSchedule); String serializeLoanScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanScheduleData loanSchedule);
String serializeLoanAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanAccountData loanAccount); String serializeLoanAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanAccountData loanAccount);
String serializeLoanTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanTransactionData newTransactionData); String serializeLoanTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanTransactionData newTransactionData);
String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanReassignmentData loanReassignmentData); String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters,
LoanReassignmentData loanReassignmentData);
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ChargeData> charges); String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ChargeData> charges);
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, ChargeData charge); String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, ChargeData charge);
String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge); String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge);
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, StaffData staff); String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, StaffData staff);
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff); String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff);
String serializeEntityIdentifier(EntityIdentifier identifier); String serializeEntityIdentifier(EntityIdentifier identifier);
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientIdentifierData> clientIdentifiers); String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
Collection<ClientIdentifierData> clientIdentifiers);
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientIdentifierData clientIdentifierData); String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
ClientIdentifierData clientIdentifierData);
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DocumentData> documentDatas); String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DocumentData> documentDatas);
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, DocumentData documentData); String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, DocumentData documentData);
String serializeCodeDataToJson(boolean prettyPrint,Set<String> responseParameters, Collection<CodeData> codes); String serializeCodeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CodeData> codes);
String serializeCodeDataToJson(boolean prettyPrint,Set<String> responseParameters, CodeData code); String serializeCodeDataToJson(boolean prettyPrint, Set<String> responseParameters, CodeData code);
String serializeMakerCheckerDataToJson(boolean prettyPrint,Set<String> responseParameters, Collection<CommandSourceData> entries); String serializeMakerCheckerDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CommandSourceData> entries);
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account); String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account);
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingAccountData> accounts); String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingAccountData> accounts);
// TODO - KW - might devide serialize up into portfolio and account to reduce interface // TODO - KW - might devide serialize up into portfolio and account to
String serializeChartOfAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, ChartOfAccountsData chartOfAccounts); // reduce interface
String serializeChartOfAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, ChartOfAccountsData chartOfAccounts);
} }
@@ -11,36 +11,36 @@ import org.springframework.security.access.prepost.PreAuthorize;
public interface ClientWritePlatformService { public interface ClientWritePlatformService {
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENT')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENT')")
Long createClient(ClientCommand command); Long createClient(ClientCommand command);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENT')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENT')")
EntityIdentifier updateClientDetails(ClientCommand command); EntityIdentifier updateClientDetails(ClientCommand command);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENT')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENT')")
EntityIdentifier deleteClient(ClientCommand command); EntityIdentifier deleteClient(ClientCommand command);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream); EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage); EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIMAGE')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIMAGE')")
EntityIdentifier deleteClientImage(Long clientId); EntityIdentifier deleteClientImage(Long clientId);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTNOTE')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTNOTE')")
EntityIdentifier addClientNote(NoteCommand command); EntityIdentifier addClientNote(NoteCommand command);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTNOTE')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTNOTE')")
EntityIdentifier updateNote(NoteCommand command); EntityIdentifier updateNote(NoteCommand command);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIDENTIFIER')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIDENTIFIER')")
Long addClientIdentifier(ClientIdentifierCommand clientIdentifierCommand); Long addClientIdentifier(ClientIdentifierCommand clientIdentifierCommand);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTIDENTIFIER')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTIDENTIFIER')")
EntityIdentifier updateClientIdentifier(ClientIdentifierCommand clientIdentifierCommand); EntityIdentifier updateClientIdentifier(ClientIdentifierCommand clientIdentifierCommand);
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIDENTIFIER')") @PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIDENTIFIER')")
EntityIdentifier deleteClientIdentifier(Long clientIdentifierId); EntityIdentifier deleteClientIdentifier(Long clientIdentifierId);
} }
@@ -40,382 +40,332 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService { public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
private final static Logger logger = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class); private final static Logger logger = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class);
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final ClientRepository clientRepository; private final ClientRepository clientRepository;
private final ClientIdentifierRepository clientIdentifierRepository; private final ClientIdentifierRepository clientIdentifierRepository;
private final OfficeRepository officeRepository; private final OfficeRepository officeRepository;
private final NoteRepository noteRepository; private final NoteRepository noteRepository;
private final CodeValueRepository codeValueRepository; private final CodeValueRepository codeValueRepository;
// FIXME - kw - this value is hardcoded for now but will be retrieved from configuration // FIXME - kw - this value is hardcoded for now but will be retrieved from
private boolean makerCheckerEnabledForTask = false; // configuration
private boolean makerCheckerEnabledForTask = false;
@Autowired
public ClientWritePlatformServiceJpaRepositoryImpl( @Autowired
final PlatformSecurityContext context, public ClientWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, final ClientRepository clientRepository,
final ClientRepository clientRepository, final ClientIdentifierRepository clientIdentifierRepository, final OfficeRepository officeRepository,
final ClientIdentifierRepository clientIdentifierRepository, NoteRepository noteRepository, final CodeValueRepository codeValueRepository) {
final OfficeRepository officeRepository, this.context = context;
NoteRepository noteRepository, this.clientRepository = clientRepository;
final CodeValueRepository codeValueRepository) { this.clientIdentifierRepository = clientIdentifierRepository;
this.context = context; this.officeRepository = officeRepository;
this.clientRepository = clientRepository; this.noteRepository = noteRepository;
this.clientIdentifierRepository = clientIdentifierRepository; this.codeValueRepository = codeValueRepository;
this.officeRepository = officeRepository; }
this.noteRepository = noteRepository;
this.codeValueRepository = codeValueRepository; @Transactional
} @Override
public EntityIdentifier deleteClient(final ClientCommand command) {
@Transactional
@Override final Long clientId = command.getId();
public EntityIdentifier deleteClient(final ClientCommand command) { final Client client = this.clientRepository.findOne(clientId);
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
final Long clientId = command.getId();
final Client client = this.clientRepository.findOne(clientId); client.delete();
if (client == null || client.isDeleted()) { this.clientRepository.save(client);
throw new ClientNotFoundException(clientId);
} if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); }
client.delete(); return new EntityIdentifier(client.getId());
this.clientRepository.save(client); }
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { /*
throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); * Guaranteed to throw an exception no matter what the data integrity issue
} * is.
*/
return new EntityIdentifier(client.getId()); private void handleDataIntegrityIssues(final ClientCommand command, final DataIntegrityViolationException dve) {
}
Throwable realCause = dve.getMostSpecificCause();
/* if (realCause.getMessage().contains("external_id")) { throw new PlatformDataIntegrityException(
* Guaranteed to throw an exception no matter what the data integrity issue "error.msg.client.duplicate.externalId", "Client with externalId `" + command.getExternalId() + "` already exists",
* is. "externalId", command.getExternalId()); }
*/
private void handleDataIntegrityIssues(final ClientCommand command, logger.error(dve.getMessage(), dve);
final DataIntegrityViolationException dve) { throw new PlatformDataIntegrityException("error.msg.client.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
Throwable realCause = dve.getMostSpecificCause(); }
if (realCause.getMessage().contains("external_id")) {
throw new PlatformDataIntegrityException( @Transactional
"error.msg.client.duplicate.externalId", @Override
"Client with externalId `" + command.getExternalId() public Long createClient(final ClientCommand command) {
+ "` already exists", "externalId",
command.getExternalId()); try {
} context.authenticatedUser();
logger.error(dve.getMessage(), dve); final ClientCommandValidator validator = new ClientCommandValidator(command);
throw new PlatformDataIntegrityException( validator.validateForCreate();
"error.msg.client.unknown.data.integrity.issue",
"Unknown data integrity issue with resource."); final Office clientOffice = this.officeRepository.findOne(command.getOfficeId());
} if (clientOffice == null) { throw new OfficeNotFoundException(command.getOfficeId()); }
@Transactional String firstname = command.getFirstname();
@Override String lastname = command.getLastname();
public Long createClient(final ClientCommand command) { if (StringUtils.isNotBlank(command.getClientOrBusinessName())) {
lastname = command.getClientOrBusinessName();
try { firstname = null;
context.authenticatedUser(); }
final ClientCommandValidator validator = new ClientCommandValidator(command); final Client newClient = Client.newClient(clientOffice, firstname, lastname, command.getJoiningDate(), command.getExternalId());
validator.validateForCreate();
this.clientRepository.save(newClient);
final Office clientOffice = this.officeRepository.findOne(command.getOfficeId());
if (clientOffice == null) { if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); }
throw new OfficeNotFoundException(command.getOfficeId());
} return newClient.getId();
} catch (DataIntegrityViolationException dve) {
String firstname = command.getFirstname(); handleDataIntegrityIssues(command, dve);
String lastname = command.getLastname(); return Long.valueOf(-1);
if (StringUtils.isNotBlank(command.getClientOrBusinessName())) { }
lastname = command.getClientOrBusinessName(); }
firstname = null;
} @Transactional
@Override
final Client newClient = Client public EntityIdentifier updateClientDetails(final ClientCommand command) {
.newClient(clientOffice, firstname, lastname,
command.getJoiningDate(), command.getExternalId()); try {
context.authenticatedUser();
this.clientRepository.save(newClient);
final ClientCommandValidator validator = new ClientCommandValidator(command);
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { validator.validateForUpdate();
throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException();
} Office clientOffice = null;
Long officeId = command.getOfficeId();
return newClient.getId(); if (command.isOfficeChanged() && officeId != null) {
} catch (DataIntegrityViolationException dve) { clientOffice = this.officeRepository.findOne(officeId);
handleDataIntegrityIssues(command, dve); if (clientOffice == null) { throw new OfficeNotFoundException(command.getOfficeId()); }
return Long.valueOf(-1); }
}
} final Client clientForUpdate = this.clientRepository.findOne(command.getId());
if (clientForUpdate == null || clientForUpdate.isDeleted()) { throw new ClientNotFoundException(command.getId()); }
@Transactional clientForUpdate.update(clientOffice, command);
@Override
public EntityIdentifier updateClientDetails(final ClientCommand command) { this.clientRepository.saveAndFlush(clientForUpdate);
try { if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); }
context.authenticatedUser();
return new EntityIdentifier(clientForUpdate.getId());
final ClientCommandValidator validator = new ClientCommandValidator(command); } catch (DataIntegrityViolationException dve) {
validator.validateForUpdate(); handleDataIntegrityIssues(command, dve);
return new EntityIdentifier(Long.valueOf(-1));
Office clientOffice = null; }
Long officeId = command.getOfficeId(); }
if (command.isOfficeChanged() && officeId != null) {
clientOffice = this.officeRepository.findOne(officeId); @Transactional
if (clientOffice == null) { @Override
throw new OfficeNotFoundException(command.getOfficeId()); public EntityIdentifier addClientNote(final NoteCommand command) {
}
} context.authenticatedUser();
final Client clientForUpdate = this.clientRepository.findOne(command.getId()); final Client clientForUpdate = this.clientRepository.findOne(command.getClientId());
if (clientForUpdate == null || clientForUpdate.isDeleted()) { if (clientForUpdate == null) { throw new ClientNotFoundException(command.getClientId()); }
throw new ClientNotFoundException(command.getId());
} final Note note = Note.clientNote(clientForUpdate, command.getNote());
clientForUpdate.update(clientOffice, command);
this.noteRepository.save(note);
this.clientRepository.saveAndFlush(clientForUpdate);
return new EntityIdentifier(note.getId());
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { }
throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException();
} @Transactional
@Override
return new EntityIdentifier(clientForUpdate.getId()); public EntityIdentifier updateNote(final NoteCommand command) {
} catch (DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve); context.authenticatedUser();
return new EntityIdentifier(Long.valueOf(-1));
} final Note noteForUpdate = this.noteRepository.findOne(command.getId());
} if (noteForUpdate == null || noteForUpdate.isNotAgainstClientWithIdOf(command.getClientId())) { throw new NoteNotFoundException(
command.getId(), command.getClientId(), "client"); }
@Transactional
@Override noteForUpdate.update(command.getNote());
public EntityIdentifier addClientNote(final NoteCommand command) {
return new EntityIdentifier(noteForUpdate.getId());
context.authenticatedUser(); }
final Client clientForUpdate = this.clientRepository.findOne(command.getClientId()); @Transactional
if (clientForUpdate == null) { @Override
throw new ClientNotFoundException(command.getClientId()); public Long addClientIdentifier(final ClientIdentifierCommand command) {
}
String documentTypeLabel = null;
final Note note = Note.clientNote(clientForUpdate, command.getNote()); Long documentTypeId = null;
final String documentKey = command.getDocumentKey();
this.noteRepository.save(note);
try {
return new EntityIdentifier(note.getId()); context.authenticatedUser();
}
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command);
@Transactional validator.validateForCreate();
@Override
public EntityIdentifier updateNote(final NoteCommand command) { final Client client = this.clientRepository.findOne(command.getClientId());
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(command.getClientId()); }
context.authenticatedUser();
final CodeValue documentType = this.codeValueRepository.findOne(command.getDocumentTypeId());
final Note noteForUpdate = this.noteRepository.findOne(command.getId()); if (documentType == null) { throw new CodeValueNotFoundException(command.getDocumentTypeId()); }
if (noteForUpdate == null documentTypeId = documentType.getId();
|| noteForUpdate.isNotAgainstClientWithIdOf(command.getClientId())) { documentTypeLabel = documentType.getLabel();
throw new NoteNotFoundException(command.getId(),command.getClientId(), "client");
} final ClientIdentifier clientIdentifier = ClientIdentifier.createNew(client, documentType, documentKey,
command.getDescription());
noteForUpdate.update(command.getNote());
this.clientIdentifierRepository.save(clientIdentifier);
return new EntityIdentifier(noteForUpdate.getId());
} return clientIdentifier.getId();
} catch (DataIntegrityViolationException dve) {
@Transactional handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
@Override return Long.valueOf(-1);
public Long addClientIdentifier(final ClientIdentifierCommand command) { }
}
String documentTypeLabel = null;
Long documentTypeId = null; @Transactional
final String documentKey = command.getDocumentKey(); @Override
public EntityIdentifier updateClientIdentifier(final ClientIdentifierCommand command) {
try {
context.authenticatedUser(); String documentTypeLabel = null;
Long documentTypeId = null;
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command); String documentKey = command.getDocumentKey();
validator.validateForCreate();
try {
final Client client = this.clientRepository.findOne(command.getClientId()); context.authenticatedUser();
if (client == null || client.isDeleted()) {
throw new ClientNotFoundException(command.getClientId()); final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command);
} validator.validateForUpdate();
final CodeValue documentType = this.codeValueRepository.findOne(command.getDocumentTypeId()); CodeValue documentType = null;
if (documentType == null) { documentTypeId = command.getDocumentTypeId();
throw new CodeValueNotFoundException(command.getDocumentTypeId()); if (command.isDocumentTypeChanged() && documentTypeId != null) {
} documentType = this.codeValueRepository.findOne(documentTypeId);
documentTypeId = documentType.getId(); if (documentType == null) { throw new CodeValueNotFoundException(command.getDocumentTypeId()); }
documentTypeLabel = documentType.getLabel(); documentTypeId = documentType.getId();
documentTypeLabel = documentType.getLabel();
final ClientIdentifier clientIdentifier = ClientIdentifier.createNew(client, documentType, documentKey, command.getDescription()); }
this.clientIdentifierRepository.save(clientIdentifier); final ClientIdentifier clientIdentifierForUpdate = this.clientIdentifierRepository.findOne(command.getId());
if (clientIdentifierForUpdate == null) { throw new ClientIdentifierNotFoundException(command.getId()); }
return clientIdentifier.getId();
} catch (DataIntegrityViolationException dve) { // TODO - KW - why need to check what changed when integrity
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve); // violation occurs?
return Long.valueOf(-1); if (command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
} documentTypeId = command.getDocumentTypeId();
} documentKey = command.getDocumentKey();
} else if (command.isDocumentTypeChanged() && !command.isDocumentKeyChanged()) {
@Transactional documentTypeId = command.getDocumentTypeId();
@Override documentKey = clientIdentifierForUpdate.getDocumentKey();
public EntityIdentifier updateClientIdentifier(final ClientIdentifierCommand command) { } else if (!command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
documentTypeId = clientIdentifierForUpdate.getDocumentType().getId();
String documentTypeLabel = null; documentKey = clientIdentifierForUpdate.getDocumentKey();
Long documentTypeId = null; }
String documentKey = command.getDocumentKey();
clientIdentifierForUpdate.update(command, documentType);
try {
context.authenticatedUser(); this.clientIdentifierRepository.saveAndFlush(clientIdentifierForUpdate);
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command); return new EntityIdentifier(clientIdentifierForUpdate.getId());
validator.validateForUpdate(); } catch (DataIntegrityViolationException dve) {
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
CodeValue documentType = null; return new EntityIdentifier(Long.valueOf(-1));
documentTypeId = command.getDocumentTypeId(); }
if (command.isDocumentTypeChanged() && documentTypeId != null) { }
documentType = this.codeValueRepository.findOne(documentTypeId);
if (documentType == null) { private void handleClientIdentifierDataIntegrityViolation(final String documentTypeLabel, final Long documentTypeId,
throw new CodeValueNotFoundException(command.getDocumentTypeId()); final String documentKey, final DataIntegrityViolationException dve) {
}
documentTypeId = documentType.getId(); if (dve.getMostSpecificCause().getMessage().contains("unique_client_identifier")) {
documentTypeLabel = documentType.getLabel(); throw new DuplicateClientIdentifierException(documentTypeLabel);
} } else if (dve.getMostSpecificCause().getMessage().contains("unique_identifier_key")) { throw new DuplicateClientIdentifierException(
documentTypeId, documentTypeLabel, documentKey); }
final ClientIdentifier clientIdentifierForUpdate = this.clientIdentifierRepository.findOne(command.getId());
if (clientIdentifierForUpdate == null) { // only log as error if unexpected data integrity violation.
throw new ClientIdentifierNotFoundException(command.getId()); logger.error(dve.getMessage(), dve);
} throw new PlatformDataIntegrityException("error.msg.clientIdentifier.unknown.data.integrity.issue",
"Unknown data integrity issue with resource.");
// TODO - KW - why need to check what changed when integrity violation occurs? }
if (command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
documentTypeId = command.getDocumentTypeId(); @Transactional
documentKey = command.getDocumentKey(); @Override
} else if (command.isDocumentTypeChanged() && !command.isDocumentKeyChanged()) { public EntityIdentifier deleteClientIdentifier(final Long clientIdentifierId) {
documentTypeId = command.getDocumentTypeId(); final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(clientIdentifierId);
documentKey = clientIdentifierForUpdate.getDocumentKey(); if (clientIdentifier == null) { throw new ClientIdentifierNotFoundException(clientIdentifierId); }
} else if (!command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) { this.clientIdentifierRepository.delete(clientIdentifier);
documentTypeId = clientIdentifierForUpdate.getDocumentType().getId();
documentKey = clientIdentifierForUpdate.getDocumentKey(); return new EntityIdentifier(clientIdentifierId);
} }
clientIdentifierForUpdate.update(command, documentType); @Transactional
@Override
this.clientIdentifierRepository.saveAndFlush(clientIdentifierForUpdate); public EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream) {
try {
return new EntityIdentifier(clientIdentifierForUpdate.getId()); final Client client = this.clientRepository.findOne(clientId);
} catch (DataIntegrityViolationException dve) { String imageUploadLocation = setupForClientImageUpdate(clientId, client);
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
return new EntityIdentifier(Long.valueOf(-1)); String imageLocation = FileUtils.saveToFileSystem(inputStream, imageUploadLocation, imageName);
}
} return updateClientImage(clientId, client, imageLocation);
} catch (IOException ioe) {
private void handleClientIdentifierDataIntegrityViolation( logger.error(ioe.getMessage(), ioe);
final String documentTypeLabel, throw new DocumentManagementException(imageName);
final Long documentTypeId, }
final String documentKey, }
final DataIntegrityViolationException dve) {
@Transactional
if (dve.getMostSpecificCause().getMessage().contains("unique_client_identifier")) { @Override
throw new DuplicateClientIdentifierException(documentTypeLabel); public EntityIdentifier deleteClientImage(final Long clientId) {
} else if (dve.getMostSpecificCause().getMessage().contains("unique_identifier_key")) {
throw new DuplicateClientIdentifierException(documentTypeId, documentTypeLabel, documentKey); final Client client = this.clientRepository.findOne(clientId);
} if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
// only log as error if unexpected data integrity violation. // delete image from the file system
logger.error(dve.getMessage(), dve); if (StringUtils.isNotEmpty(client.getImageKey())) {
throw new PlatformDataIntegrityException( FileUtils.deleteClientImage(clientId, client.getImageKey());
"error.msg.clientIdentifier.unknown.data.integrity.issue", }
"Unknown data integrity issue with resource."); return updateClientImage(clientId, client, null);
} }
@Transactional @Override
@Override public EntityIdentifier saveOrUpdateClientImage(final Long clientId, final Base64EncodedImage encodedImage) {
public EntityIdentifier deleteClientIdentifier(final Long clientIdentifierId) { try {
final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(clientIdentifierId); final Client client = this.clientRepository.findOne(clientId);
if (clientIdentifier == null) { final String imageUploadLocation = setupForClientImageUpdate(clientId, client);
throw new ClientIdentifierNotFoundException(clientIdentifierId);
} final String imageLocation = FileUtils.saveToFileSystem(encodedImage, imageUploadLocation, "image");
this.clientIdentifierRepository.delete(clientIdentifier);
return updateClientImage(clientId, client, imageLocation);
return new EntityIdentifier(clientIdentifierId); } catch (IOException ioe) {
} logger.error(ioe.getMessage(), ioe);
throw new DocumentManagementException("image");
@Transactional }
@Override }
public EntityIdentifier saveOrUpdateClientImage(Long clientId,
String imageName, InputStream inputStream) { private String setupForClientImageUpdate(final Long clientId, final Client client) {
try { if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
final Client client = this.clientRepository.findOne(clientId);
String imageUploadLocation = setupForClientImageUpdate(clientId, final String imageUploadLocation = FileUtils.generateClientImageParentDirectory(clientId);
client); // delete previous image from the file system
if (StringUtils.isNotEmpty(client.getImageKey())) {
String imageLocation = FileUtils.saveToFileSystem(inputStream, FileUtils.deleteClientImage(clientId, client.getImageKey());
imageUploadLocation, imageName); }
/** Recursively create the directory if it does not exist **/
return updateClientImage(clientId, client, imageLocation); if (!new File(imageUploadLocation).isDirectory()) {
} catch (IOException ioe) { new File(imageUploadLocation).mkdirs();
logger.error(ioe.getMessage(), ioe); }
throw new DocumentManagementException(imageName); return imageUploadLocation;
} }
}
private EntityIdentifier updateClientImage(final Long clientId, final Client client, final String imageLocation) {
@Transactional client.setImageKey(imageLocation);
@Override this.clientRepository.save(client);
public EntityIdentifier deleteClientImage(final Long clientId) {
return new EntityIdentifier(clientId);
final Client client = this.clientRepository.findOne(clientId); }
if (client == null || client.isDeleted()) {
throw new ClientNotFoundException(clientId);
}
// delete image from the file system
if (StringUtils.isNotEmpty(client.getImageKey())) {
FileUtils.deleteClientImage(clientId, client.getImageKey());
}
return updateClientImage(clientId, client, null);
}
@Override
public EntityIdentifier saveOrUpdateClientImage(final Long clientId, final Base64EncodedImage encodedImage) {
try {
final Client client = this.clientRepository.findOne(clientId);
final String imageUploadLocation = setupForClientImageUpdate(clientId, client);
final String imageLocation = FileUtils.saveToFileSystem(encodedImage, imageUploadLocation, "image");
return updateClientImage(clientId, client, imageLocation);
} catch (IOException ioe) {
logger.error(ioe.getMessage(), ioe);
throw new DocumentManagementException("image");
}
}
private String setupForClientImageUpdate(final Long clientId, final Client client) {
if (client == null || client.isDeleted()) {
throw new ClientNotFoundException(clientId);
}
final String imageUploadLocation = FileUtils.generateClientImageParentDirectory(clientId);
// delete previous image from the file system
if (StringUtils.isNotEmpty(client.getImageKey())) {
FileUtils.deleteClientImage(clientId, client.getImageKey());
}
/** Recursively create the directory if it does not exist **/
if (!new File(imageUploadLocation).isDirectory()) {
new File(imageUploadLocation).mkdirs();
}
return imageUploadLocation;
}
private EntityIdentifier updateClientImage(final Long clientId, final Client client, final String imageLocation) {
client.setImageKey(imageLocation);
this.clientRepository.save(client);
return new EntityIdentifier(clientId);
}
} }
@@ -0,0 +1,19 @@
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;
}
}
@@ -0,0 +1,42 @@
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<UnsupportedCommandException> {
@Override
public Response toResponse(final UnsupportedCommandException exception) {
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
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();
}
}
@@ -19,99 +19,108 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "m_portfolio_command_source") @Table(name = "m_portfolio_command_source")
public class CommandSource extends AbstractPersistable<Long> { public class CommandSource extends AbstractPersistable<Long> {
@Column(name = "api_operation", length = 20) @Column(name = "api_operation", length = 20)
private String apiOperation; private String apiOperation;
@Column(name = "api_resource", length = 20) @Column(name = "api_resource", length = 20)
private String resource; private String resource;
@Column(name = "resource_id") @Column(name = "resource_id")
private Long resourceId; private Long resourceId;
@Column(name = "command_as_json", length = 1000) @Column(name = "command_as_json", length = 1000)
private String commandAsJson; private String commandAsJson;
// should maker and checker be a staff member as opposed to just any application user? @ManyToOne
@SuppressWarnings("unused") @JoinColumn(name = "maker_id", nullable = false)
@ManyToOne private AppUser maker;
@JoinColumn(name = "maker_id", nullable = false)
private AppUser maker;
@SuppressWarnings("unused") @Column(name = "made_on_date", nullable = false)
@Column(name = "made_on_date", nullable = false)
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
private Date madeOnDate; private Date madeOnDate;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ManyToOne @ManyToOne
@JoinColumn(name = "checker_id", nullable = true) @JoinColumn(name = "checker_id", nullable = true)
private AppUser checker; private AppUser checker;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Column(name = "checked_on_date", nullable = false) @Column(name = "checked_on_date", nullable = false)
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
private Date checkedOnDate; private Date checkedOnDate;
public static CommandSource createdBy( public static CommandSource createdBy(final String apiOperation, final String resource, final Long resourceId, final AppUser maker,
final String apiOperation, final LocalDate madeOnDate) {
final String resource, return new CommandSource(apiOperation, resource, resourceId, maker, madeOnDate);
final Long resourceId, }
final AppUser maker,
final LocalDate madeOnDate) {
return new CommandSource(apiOperation, resource, resourceId, maker, madeOnDate);
}
protected CommandSource() { protected CommandSource() {
// //
} }
private CommandSource( private CommandSource(final String apiOperation, final String resource, final Long resourceId, final AppUser maker,
final String apiOperation, final LocalDate madeOnDate) {
final String resource, this.apiOperation = StringUtils.defaultIfEmpty(apiOperation, null);
final Long resourceId, this.resource = StringUtils.defaultIfEmpty(resource, null);
final AppUser maker, this.resourceId = resourceId;
final LocalDate madeOnDate) { this.maker = maker;
this.apiOperation = StringUtils.defaultIfEmpty(apiOperation, null); this.madeOnDate = madeOnDate.toDate();
this.resource = StringUtils.defaultIfEmpty(resource, null); }
this.resourceId = resourceId;
this.maker = maker;
this.madeOnDate = madeOnDate.toDate();
}
public void markAsChecked(final AppUser checker, final LocalDate checkedOnDate) { public CommandSource copy() {
this.checker = checker; LocalDate madeOnLocalDate = null;
this.checkedOnDate = checkedOnDate.toDate(); if (this.madeOnDate != null) {
} madeOnLocalDate = new LocalDate(this.madeOnDate);
}
return new CommandSource(this.apiOperation, this.resource, this.resourceId, this.maker, madeOnLocalDate);
}
public void updateResourceId(final Long resourceId) { public void markAsChecked(final AppUser checker, final LocalDate checkedOnDate) {
this.resourceId = resourceId; this.checker = checker;
} this.checkedOnDate = checkedOnDate.toDate();
}
public void updateJsonTo(final String json) { public void updateResourceId(final Long resourceId) {
this.commandAsJson = json; this.resourceId = resourceId;
} }
public Long resourceId() { public void updateJsonTo(final String json) {
return this.resourceId; this.commandAsJson = json;
} }
public String json() { public Long resourceId() {
return this.commandAsJson; return this.resourceId;
} }
public boolean isClientResource() { public String json() {
return this.resource.equalsIgnoreCase("CLIENTS"); return this.commandAsJson;
} }
public boolean isCreate() { public String commandName() {
return this.apiOperation.equalsIgnoreCase("CREATE"); return this.apiOperation + '-' + this.resource;
} }
public boolean isUpdate() { public String resourceName() {
return this.apiOperation.equalsIgnoreCase("UPDATE") && this.resourceId != null; return this.resource;
} }
public boolean isDelete() { public String operation() {
return this.apiOperation.equalsIgnoreCase("DELETE") && this.resourceId != null; return this.apiOperation;
} }
public boolean isClientResource() {
return this.resource.equalsIgnoreCase("CLIENTS");
}
public boolean isCreate() {
return this.apiOperation.equalsIgnoreCase("CREATE");
}
public boolean isUpdate() {
return this.apiOperation.equalsIgnoreCase("UPDATE") && this.resourceId != null;
}
public boolean isDelete() {
return this.apiOperation.equalsIgnoreCase("DELETE") && this.resourceId != null;
}
} }
@@ -0,0 +1,7 @@
package org.mifosng.platform.makerchecker.service;
public interface ChangeDetectionService {
String detectChanges(String operation, String resourceName, Long resourceId, String commandSerializedAsJson);
}
@@ -0,0 +1,48 @@
package org.mifosng.platform.makerchecker.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.client.service.ClientReadPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ChangeDetectionServiceJdbc implements ChangeDetectionService {
private final PortfolioApiDataConversionService apiDataConversionService;
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
private final ClientReadPlatformService clientReadPlatformService;
@Autowired
public ChangeDetectionServiceJdbc(final PortfolioApiDataConversionService apiDataConversionService,
final PortfolioApiJsonSerializerService apiJsonSerializerService, final ClientReadPlatformService clientReadPlatformService) {
this.apiDataConversionService = apiDataConversionService;
this.apiJsonSerializerService = apiJsonSerializerService;
this.clientReadPlatformService = clientReadPlatformService;
}
@Override
public String detectChanges(final String operation, final String resourceName, final Long resourceId,
final String commandSerializedAsJson) {
String changesOnlyJson = "";
// FIXME - KW/JW - this change detection code for update of clients
// using ClientCommand can re placed when more suitable sql version is
// implemented.
final ClientData originalClient = this.clientReadPlatformService.retrieveIndividualClient(resourceId);
final ClientData changedClient = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(resourceId,
commandSerializedAsJson);
final String baseJson = this.apiJsonSerializerService.serializeClientDataToJson(originalClient);
final String workingJson = this.apiJsonSerializerService.serializeClientDataToJson(changedClient);
final ClientCommand changesOnly = this.apiDataConversionService.detectChanges(resourceId, baseJson, workingJson);
changesOnlyJson = this.apiJsonSerializerService.serializeClientCommandToJson(changesOnly);
return changesOnlyJson;
}
}
@@ -0,0 +1,113 @@
package org.mifosng.platform.makerchecker.service;
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.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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ClientCommandHandler implements CommandSourceHandler {
private final PlatformSecurityContext context;
private final ChangeDetectionService changeDetectionService;
private final PortfolioApiDataConversionService apiDataConversionService;
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
private final ClientWritePlatformService clientWritePlatformService;
@Autowired
public ClientCommandHandler(final PlatformSecurityContext context, final ChangeDetectionService changeDetectionService,
final PortfolioApiDataConversionService apiDataConversionService,
final PortfolioApiJsonSerializerService apiJsonSerializerService, final ClientWritePlatformService clientWritePlatformService) {
this.context = context;
this.changeDetectionService = changeDetectionService;
this.apiDataConversionService = apiDataConversionService;
this.apiJsonSerializerService = apiJsonSerializerService;
this.clientWritePlatformService = clientWritePlatformService;
}
public CommandSource handle(final CommandSource commandSource, final String apiRequestBodyInJson) {
final AppUser maker = context.authenticatedUser();
final LocalDate asToday = new LocalDate();
CommandSource commandSourceResult = commandSource.copy();
final Long resourceId = commandSource.resourceId();
Long newResourceId = null;
final ClientCommand command = this.apiDataConversionService.convertApiRequestJsonToClientCommand(resourceId, apiRequestBodyInJson);
final String commandSerializedAsJson = this.apiJsonSerializerService.serializeClientCommandToJson(command);
commandSourceResult.updateJsonTo(commandSerializedAsJson);
if (commandSource.isCreate()) {
try {
newResourceId = this.clientWritePlatformService.createClient(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.detectChanges(commandSource.operation(),
commandSource.resourceName(), commandSource.resourceId(), commandSerializedAsJson);
commandSourceResult.updateJsonTo(jsonOfChangesOnly);
final ClientCommand changesOnly = this.apiDataConversionService.convertInternalJsonFormatToClientCommand(
commandSource.resourceId(), jsonOfChangesOnly, false);
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(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.deleteClient(command);
newResourceId = result.getEntityId();
commandSourceResult.markAsChecked(maker, asToday);
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
// swallow this rollback transaction by design
}
}
return commandSourceResult;
}
public CommandSource handle(final CommandSource commandSourceResult) {
Long resourceId = null;
if (commandSourceResult.isClientResource()) {
final ClientCommand command = this.apiDataConversionService.convertInternalJsonFormatToClientCommand(
commandSourceResult.resourceId(), commandSourceResult.json(), true);
if (commandSourceResult.isCreate()) {
resourceId = this.clientWritePlatformService.createClient(command);
} else if (commandSourceResult.isUpdate()) {
// TODO - is there a case for doing change detection at this
// point also?
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(command);
resourceId = result.getEntityId();
} else if (commandSourceResult.isDelete()) {
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
resourceId = result.getEntityId();
}
}
commandSourceResult.updateResourceId(resourceId);
return commandSourceResult;
}
}
@@ -0,0 +1,5 @@
package org.mifosng.platform.makerchecker.service;
public interface CommandSourceHandler {
}
@@ -0,0 +1,48 @@
package org.mifosng.platform.makerchecker.service;
import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException;
import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.security.PlatformSecurityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* A class to delegate handling of commands to appropriate handler.
*/
@Service
public class CommandSourceHandlerDelegator {
private final PlatformSecurityContext context;
private final ClientCommandHandler clientCommandHandler;
@Autowired
public CommandSourceHandlerDelegator(final PlatformSecurityContext context, final ClientCommandHandler clientCommandHandler) {
this.context = context;
this.clientCommandHandler = clientCommandHandler;
}
public CommandSource handle(final CommandSource commandSource, final String apiRequestBodyInJson) {
context.authenticatedUser();
CommandSource commandSourceResult = null;
if (commandSource.isClientResource()) {
commandSourceResult = clientCommandHandler.handle(commandSource, apiRequestBodyInJson);
} else {
throw new UnsupportedCommandException(commandSource.commandName());
}
return commandSourceResult;
}
public CommandSource handleExistingCommand(final CommandSource commandSource) {
CommandSource commandSourceResult = null;
if (commandSource.isClientResource()) {
commandSourceResult = clientCommandHandler.handle(commandSource);
} else {
throw new UnsupportedCommandException(commandSource.commandName());
}
return commandSourceResult;
}
}
@@ -1,14 +1,7 @@
package org.mifosng.platform.makerchecker.service; package org.mifosng.platform.makerchecker.service;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.mifosng.platform.api.commands.ClientCommand;
import org.mifosng.platform.api.data.ClientData;
import org.mifosng.platform.api.data.EntityIdentifier; 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.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
import org.mifosng.platform.makerchecker.domain.CommandSource; import org.mifosng.platform.makerchecker.domain.CommandSource;
import org.mifosng.platform.makerchecker.domain.CommandSourceRepository; import org.mifosng.platform.makerchecker.domain.CommandSourceRepository;
import org.mifosng.platform.security.PlatformSecurityContext; import org.mifosng.platform.security.PlatformSecurityContext;
@@ -20,128 +13,58 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class PortfolioCommandSourceWriteServiceImpl implements PortfolioCommandSourceWritePlatformService { public class PortfolioCommandSourceWriteServiceImpl implements PortfolioCommandSourceWritePlatformService {
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final CommandSourceRepository commandSourceRepository; private final CommandSourceRepository commandSourceRepository;
private final PortfolioApiDataConversionService apiDataConversionService; private final CommandSourceHandlerDelegator commandSourceHandlerDelegator;
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
private final ClientWritePlatformService clientWritePlatformService;
private final ClientReadPlatformService clientReadPlatformService;
@Autowired @Autowired
public PortfolioCommandSourceWriteServiceImpl(final PlatformSecurityContext context, final CommandSourceRepository makerCheckerRepository, public PortfolioCommandSourceWriteServiceImpl(final PlatformSecurityContext context,
final PortfolioApiDataConversionService apiDataConversionService, final CommandSourceRepository makerCheckerRepository,
final PortfolioApiJsonSerializerService apiJsonSerializerService, final CommandSourceHandlerDelegator commandSourceHandlerDelegator) {
final ClientWritePlatformService clientWritePlatformService, this.context = context;
final ClientReadPlatformService clientReadPlatformService) { this.commandSourceRepository = makerCheckerRepository;
this.context = context; this.commandSourceHandlerDelegator = commandSourceHandlerDelegator;
this.commandSourceRepository = makerCheckerRepository; }
this.apiDataConversionService = apiDataConversionService;
this.apiJsonSerializerService = apiJsonSerializerService;
this.clientWritePlatformService = clientWritePlatformService;
this.clientReadPlatformService = clientReadPlatformService;
}
// NOT TRANSACTIONAL BY DESIGN FOR NOW // NOT TRANSACTIONAL BY DESIGN FOR NOW
@Override @Override
public EntityIdentifier logCommandSource(final String apiOperation, final String resource, final Long resourceId, final String jsonRequestBody) { public EntityIdentifier logCommandSource(final String apiOperation, final String resource, final Long resourceId,
final String apiRequestBodyInJson) {
final AppUser maker = context.authenticatedUser(); final AppUser maker = context.authenticatedUser();
final LocalDate asToday = new LocalDate();
final LocalDate asToday = new LocalDate(); final CommandSource commandSourceInput = CommandSource.createdBy(apiOperation, resource, resourceId, maker, asToday);
final CommandSource commandSourceResult = this.commandSourceHandlerDelegator.handle(commandSourceInput, apiRequestBodyInJson);
commandSourceRepository.save(commandSourceResult);
final CommandSource commandSource = CommandSource.createdBy(apiOperation, resource, resourceId, maker, asToday); return EntityIdentifier.makerChecker(commandSourceResult.resourceId(), commandSourceResult.getId());
}
Long newResourceId = null; @Transactional
if (commandSource.isClientResource()) { @Override
public EntityIdentifier approveEntry(final Long id) {
// translate incoming api request json into java object catering for local and dateFormat parts of api final AppUser checker = context.authenticatedUser();
final ClientCommand command = this.apiDataConversionService.convertApiRequestJsonToClientCommand(resourceId, jsonRequestBody);
// produce serialized json of internal java object representation for persistence.
final String internalCommandSerializedAsJson = this.apiJsonSerializerService.serializeClientCommandToJson(command);
commandSource.updateJsonTo(internalCommandSerializedAsJson);
if (commandSource.isCreate()) { final CommandSource commandSourceInput = this.commandSourceRepository.findOne(id);
try { commandSourceInput.markAsChecked(checker, new LocalDate());
newResourceId = this.clientWritePlatformService.createClient(command);
commandSource.markAsChecked(maker, asToday);
commandSource.updateResourceId(newResourceId);
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
// swallow this rollback transaction by design
}
} else if (commandSource.isUpdate()) {
try {
// useful to employ change detection on update scenario to only store what details have changed
final ClientData originalClient = this.clientReadPlatformService.retrieveIndividualClient(resourceId);
final ClientData changedClient = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(resourceId, internalCommandSerializedAsJson);
final String baseJson = this.apiJsonSerializerService.serializeClientDataToJson(originalClient); final CommandSource commandSourceResult = this.commandSourceHandlerDelegator.handleExistingCommand(commandSourceInput);
final String workingJson = this.apiJsonSerializerService.serializeClientDataToJson(changedClient);
final ClientCommand changesOnly = this.apiDataConversionService.detectChanges(resourceId, baseJson, workingJson);
final String changesOnlyJson = this.apiJsonSerializerService.serializeClientCommandToJson(changesOnly); commandSourceRepository.save(commandSourceResult);
commandSource.updateJsonTo(changesOnlyJson);
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(changesOnly); return EntityIdentifier.makerChecker(commandSourceResult.resourceId(), commandSourceResult.getId());
newResourceId = result.getEntityId(); }
commandSource.markAsChecked(maker, asToday); @Transactional
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) { @Override
// swallow this rollback transaction by design public Long deleteEntry(final Long makerCheckerId) {
}
} else if (commandSource.isDelete()) {
try {
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
newResourceId = result.getEntityId();
commandSource.markAsChecked(maker, asToday);
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
// swallow this rollback transaction by design
}
}
}
commandSourceRepository.save(commandSource); context.authenticatedUser();
return EntityIdentifier.makerChecker(newResourceId, commandSource.getId()); this.commandSourceRepository.delete(makerCheckerId);
}
@Transactional return makerCheckerId;
@Override }
public EntityIdentifier approveEntry(final Long id) {
final AppUser checker = context.authenticatedUser();
final CommandSource entity = this.commandSourceRepository.findOne(id);
entity.markAsChecked(checker, new LocalDate());
Long resourceId = null;
if (entity.isClientResource()) {
final ClientCommand command = this.apiDataConversionService.convertInternalJsonFormatToClientCommand(entity.resourceId(), entity.json(), true);
if (entity.isCreate()) {
resourceId = this.clientWritePlatformService.createClient(command);
} else if (entity.isUpdate()) {
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(command);
resourceId = result.getEntityId();
} else if (entity.isDelete()) {
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
resourceId = result.getEntityId();
}
}
entity.updateResourceId(resourceId);
commandSourceRepository.save(entity);
return EntityIdentifier.makerChecker(resourceId, entity.getId());
}
@Transactional
@Override
public Long deleteEntry(final Long makerCheckerId) {
context.authenticatedUser();
this.commandSourceRepository.delete(makerCheckerId);
return makerCheckerId;
}
} }