From f2e4df94b8954985dc3c3ca65f0539a1338fa5dc Mon Sep 17 00:00:00 2001 From: John Woodlock Date: Sun, 24 Mar 2013 17:00:43 +0000 Subject: [PATCH] error msg when commandId not found for maker-checker approvals --- .../exception/CommandNotFoundException.java | 18 ++++++++++++++++++ ...oCommandSourceWritePlatformServiceImpl.java | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 mifosng-provider/src/main/java/org/mifosplatform/commands/exception/CommandNotFoundException.java diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/exception/CommandNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/exception/CommandNotFoundException.java new file mode 100644 index 000000000..358fb0e72 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/exception/CommandNotFoundException.java @@ -0,0 +1,18 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.commands.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +/** + * A {@link RuntimeException} thrown when client resources are not found. + */ +public class CommandNotFoundException extends AbstractPlatformResourceNotFoundException { + + public CommandNotFoundException(Long id) { + super("error.msg.command.id.invalid", "Command with identifier " + id + " does not exist", id); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java index a537db975..53e428e53 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/PortfolioCommandSourceWritePlatformServiceImpl.java @@ -14,6 +14,7 @@ import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -86,7 +87,8 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio public CommandProcessingResult approveEntry(final Long commandId) { final CommandSource commandSourceInput = this.commandSourceRepository.findOne(commandId); - + if (commandSourceInput == null) {throw new ClientNotFoundException(commandId);} + context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode()); final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(commandId, commandSourceInput.getActionName(),