tidy up error handling and services around loan product.

This commit is contained in:
Keith Woodlock
2012-05-10 21:09:37 +01:00
parent 01adabab47
commit 6f4a47a1ca
33 changed files with 839 additions and 1087 deletions
@@ -22,8 +22,8 @@ import org.mifosng.data.RoleData;
import org.mifosng.data.command.AdjustLoanTransactionCommand;
import org.mifosng.data.command.CalculateLoanScheduleCommand;
import org.mifosng.data.command.ChangePasswordCommand;
import org.mifosng.data.command.CreateLoanProductCommand;
import org.mifosng.data.command.EnrollClientCommand;
import org.mifosng.data.command.LoanProductCommand;
import org.mifosng.data.command.LoanStateTransitionCommand;
import org.mifosng.data.command.LoanTransactionCommand;
import org.mifosng.data.command.NoteCommand;
@@ -32,7 +32,6 @@ import org.mifosng.data.command.RoleCommand;
import org.mifosng.data.command.SubmitLoanApplicationCommand;
import org.mifosng.data.command.UndoLoanApprovalCommand;
import org.mifosng.data.command.UndoLoanDisbursalCommand;
import org.mifosng.data.command.UpdateLoanProductCommand;
import org.mifosng.data.command.UpdateOrganisationCurrencyCommand;
import org.mifosng.data.command.UserCommand;
import org.mifosng.data.reports.GenericResultset;
@@ -101,9 +100,9 @@ public interface CommonRestOperations {
Collection<EnumOptionReadModel> retrieveAllowedNominalInterestFrequencyOptions();
EntityIdentifier createLoanProduct(CreateLoanProductCommand command);
EntityIdentifier createLoanProduct(LoanProductCommand command);
EntityIdentifier updateLoanProduct(UpdateLoanProductCommand command);
EntityIdentifier updateLoanProduct(LoanProductCommand command);
LoanProductData retrieveLoanProductDetails(Long selectedLoanProductOption);
@@ -39,8 +39,8 @@ import org.mifosng.data.UserList;
import org.mifosng.data.command.AdjustLoanTransactionCommand;
import org.mifosng.data.command.CalculateLoanScheduleCommand;
import org.mifosng.data.command.ChangePasswordCommand;
import org.mifosng.data.command.CreateLoanProductCommand;
import org.mifosng.data.command.EnrollClientCommand;
import org.mifosng.data.command.LoanProductCommand;
import org.mifosng.data.command.LoanStateTransitionCommand;
import org.mifosng.data.command.LoanTransactionCommand;
import org.mifosng.data.command.NoteCommand;
@@ -49,7 +49,6 @@ import org.mifosng.data.command.RoleCommand;
import org.mifosng.data.command.SubmitLoanApplicationCommand;
import org.mifosng.data.command.UndoLoanApprovalCommand;
import org.mifosng.data.command.UndoLoanDisbursalCommand;
import org.mifosng.data.command.UpdateLoanProductCommand;
import org.mifosng.data.command.UpdateOrganisationCurrencyCommand;
import org.mifosng.data.command.UserCommand;
import org.mifosng.data.reports.GenericResultset;
@@ -137,13 +136,13 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
}
@Override
public EntityIdentifier createLoanProduct(final CreateLoanProductCommand command) {
public EntityIdentifier createLoanProduct(final LoanProductCommand command) {
try {
URI restUri = URI
.create(getBaseServerUrl().concat("api/protected/product/loan/new"));
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate.postForEntity(restUri,
createLoanProductRequest(command), EntityIdentifier.class);
updateLoanProductRequest(command), EntityIdentifier.class);
return s.getBody();
} catch (HttpStatusCodeException e) {
@@ -153,7 +152,7 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
}
@Override
public EntityIdentifier updateLoanProduct(UpdateLoanProductCommand command) {
public EntityIdentifier updateLoanProduct(LoanProductCommand command) {
try {
URI restUri = URI
.create(getBaseServerUrl().concat("api/protected/product/loan/update"));
@@ -192,24 +191,13 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
return errorList;
}
private HttpEntity<UpdateLoanProductCommand> updateLoanProductRequest(
final UpdateLoanProductCommand command) {
private HttpEntity<LoanProductCommand> updateLoanProductRequest(
final LoanProductCommand command) {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("Accept", "application/xml");
requestHeaders.set("Content-Type", "application/xml");
HttpEntity<UpdateLoanProductCommand> requestEntity = new HttpEntity<UpdateLoanProductCommand>(
command, requestHeaders);
return requestEntity;
}
private HttpEntity<CreateLoanProductCommand> createLoanProductRequest(
final CreateLoanProductCommand command) {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("Accept", "application/xml");
requestHeaders.set("Content-Type", "application/xml");
HttpEntity<CreateLoanProductCommand> requestEntity = new HttpEntity<CreateLoanProductCommand>(
HttpEntity<LoanProductCommand> requestEntity = new HttpEntity<LoanProductCommand>(
command, requestHeaders);
return requestEntity;
}
@@ -2,7 +2,6 @@ package org.mifosng.ui.admin;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mifosng.data.AppUserData;
@@ -16,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -62,7 +60,7 @@ public class AdministrationController {
}
@RequestMapping(value = "/org/admin/settings", method = RequestMethod.GET)
public String userSettingsScreen(Model model) {
public String userSettingsScreen() {
return "admin/accountsettings";
}
@@ -74,7 +72,7 @@ public class AdministrationController {
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "org/admin/settings/details", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody EntityIdentifier updateUserDetails(HttpServletRequest request,
public @ResponseBody EntityIdentifier updateUserDetails(
@RequestParam(value="username", required=false) String username,
@RequestParam(value="firstname", required=false) String firstname,
@RequestParam(value="lastname", required=false) String lastname,
@@ -93,7 +91,7 @@ public class AdministrationController {
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "org/admin/settings/password", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody EntityIdentifier updateUserDetails(HttpServletRequest request,
public @ResponseBody EntityIdentifier updateUserDetails(
@RequestParam(value="password", required=false) String password,
@RequestParam(value="passwordrepeat", required=false) String passwordrepeat) {
@@ -8,15 +8,13 @@ import java.util.Collection;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.mifosng.data.EntityIdentifier;
import org.mifosng.data.ErrorResponse;
import org.mifosng.data.LoanProductData;
import org.mifosng.data.command.CreateLoanProductCommand;
import org.mifosng.data.command.UpdateLoanProductCommand;
import org.mifosng.data.command.LoanProductCommand;
import org.mifosng.ui.CommonRestOperations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
@@ -90,7 +88,7 @@ public class LoanProductController {
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/product/loan/new", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody EntityIdentifier createLoanProduct(HttpServletRequest request,
public @ResponseBody EntityIdentifier createLoanProduct(
@RequestParam("name") String name,
@RequestParam("description") String description,
@RequestParam("selectedCurrency") String currencyCode, @RequestParam("selectedDigitsAfterDecimal") Integer digitsAfterDecimal,
@@ -106,7 +104,7 @@ public class LoanProductController {
@RequestParam(value="interestRateCalculatedInPeriod", required=false) Integer interestCalculationPeriodMethod
) {
CreateLoanProductCommand command = new CreateLoanProductCommand();
LoanProductCommand command = new LoanProductCommand();
command.setName(name);
command.setDescription(description);
command.setCurrencyCode(currencyCode);
@@ -146,7 +144,7 @@ public class LoanProductController {
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/product/loan/{productId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody EntityIdentifier updateLoanProduct(@PathVariable("productId") final Long productId, HttpServletRequest request,
public @ResponseBody EntityIdentifier updateLoanProduct(@PathVariable("productId") final Long productId,
@RequestParam("name") String name, @RequestParam("description") String description,
@RequestParam("selectedCurrency") String currencyCode, @RequestParam("selectedDigitsAfterDecimal") Integer digitsAfterDecimal,
@RequestParam("amount") String principalAsNumber,
@@ -161,7 +159,7 @@ public class LoanProductController {
@RequestParam(value="interestRateCalculatedInPeriod", required=false) Integer interestCalculationPeriodMethod
) {
UpdateLoanProductCommand command = new UpdateLoanProductCommand();
LoanProductCommand command = new LoanProductCommand();
command.setId(productId);
command.setName(name);
command.setDescription(description);
@@ -5,7 +5,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
@@ -94,7 +93,7 @@ public class OfficeController {
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/org/office/new", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody EntityIdentifier createOffice(HttpServletRequest request,
public @ResponseBody EntityIdentifier createOffice(
@RequestParam("name") String name,
@RequestParam(value="parentId", required=false) Long parentId,
@RequestParam("openingDate") String openingDate,
@@ -114,7 +113,7 @@ public class OfficeController {
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/org/office/{officeId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody EntityIdentifier updateOffice(HttpServletRequest request, @PathVariable("officeId") final Long officeId,
public @ResponseBody EntityIdentifier updateOffice(@PathVariable("officeId") final Long officeId,
@RequestParam("name") String name,
@RequestParam(value="parentId", required=false) Long parentId,
@RequestParam("openingDate") String openingDate,