use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class AspectJRESTApprovalInterceptor method profile.
@Around("restMethods() && requestMapping() && excludeAPI() && exludeRestfulServices()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
Signature signature = pjp.getStaticPart().getSignature();
LOG.debug(this.getClass().getSimpleName() + " staring");
// FIXME : somehow autowiring is not working
if (approvalService == null) {
approvalService = ApplicationContextProvider.getBean(ApprovalService.class);
}
if (configurationServiceFacade == null) {
configurationServiceFacade = ApplicationContextProvider.getBean(ConfigurationServiceFacade.class);
}
if (parameterNameDiscoverer == null) {
parameterNameDiscoverer = ApplicationContextProvider.getBean(ParameterNameDiscoverer.class);
}
if (!RESTConfigKey.isApprovalRequired(configurationServiceFacade)) {
LOG.debug(pjp.getSignature() + " skip approval");
return pjp.proceed();
}
if (signature instanceof MethodSignature) {
MethodSignature ms = (MethodSignature) signature;
Method m = ms.getMethod();
RequestMapping mapping = m.getAnnotation(RequestMapping.class);
if (isReadOnly(mapping)) {
LOG.debug(m.getName() + " is read only, hence returning control");
return pjp.proceed();
}
Class<?> methodClassType = m.getDeclaringClass();
if (!methodClassType.getSimpleName().endsWith("RESTController")) {
LOG.debug(m.getName() + " is not from REST controller, hence returning control");
return pjp.proceed();
}
Object[] argValues = pjp.getArgs();
Class<?>[] argTypes = m.getParameterTypes();
String methodName = m.getName();
String[] names = parameterNameDiscoverer.getParameterNames(m);
MethodArgHolder args = new MethodArgHolder(argTypes, argValues, names);
ApprovalMethod method = new ApprovalMethod(methodName, methodClassType, args);
approvalService.create(method);
}
return pjp.proceed();
}
use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class ApprovalRESTController method updateMethodData.
@RequestMapping(value = "id-{id}/methodData", method = RequestMethod.POST)
public ModelMap updateMethodData(@PathVariable(value = "id") Long id, @RequestBody ApprovalMethod content) throws Exception {
ModelMap model = new ModelMap();
approvalService.updateMethodContent(id, content);
model.addAttribute("status", "success");
return model;
}
use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class MonthClosingController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@ModelAttribute("monthClosingFormBean") @Valid MonthClosingFormBean formBean, BindingResult result, SessionStatus status) {
if (!result.hasErrors()) {
Date monthClosingDate = null;
if (formBean.getDate() != null) {
monthClosingDate = formBean.getDate().toDate();
}
monthClosingServiceFacade.setMonthClosingDate(monthClosingDate);
status.setComplete();
}
return handleRequestInternal();
}
use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class MonthClosingController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequestInternal() {
Map<String, Object> model = new HashMap<String, Object>();
String monthClosingDateString = "-";
if (monthClosingServiceFacade.getMonthClosingDate() != null) {
monthClosingDateString = org.joda.time.format.DateTimeFormat.forStyle("S-").withLocale(Locale.getDefault()).print(new DateTime(monthClosingServiceFacade.getMonthClosingDate()));
}
model.put("currentDate", monthClosingDateString);
Map<String, Object> status = new HashMap<String, Object>();
List<String> errorMessages = new ArrayList<String>();
status.put("errorMessages", errorMessages);
ModelAndView modelAndView = new ModelAndView("monthClosing", "model", model);
modelAndView.addObject("status", status);
return modelAndView;
}
use of org.springframework.web.bind.annotation.RequestMapping in project head by mifos.
the class NewFundPreviewController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") FundFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
if (StringUtils.isNotBlank(edit)) {
mav = new ModelAndView("editFunds");
mav.addObject("formBean", formBean);
mav.addObject("previewView", "newFundPreview");
} else if (StringUtils.isNotBlank(cancel)) {
mav = new ModelAndView(REDIRECT_TO_VIEW_FUNDS);
status.setComplete();
} else if (result.hasErrors()) {
mav = new ModelAndView("newFundPreview");
} else {
FundCodeDto codeDto = new FundCodeDto();
codeDto.setId(formBean.getCodeId());
codeDto.setValue(formBean.getCodeValue());
FundDto fundDto = new FundDto();
fundDto.setCode(codeDto);
fundDto.setId(formBean.getId());
fundDto.setName(formBean.getName());
try {
this.fundServiceFacade.createFund(fundDto);
status.setComplete();
} catch (BusinessRuleException e) {
ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: ");
result.addError(error);
mav.setViewName("newFundPreview");
mav.addObject("formBean", formBean);
}
}
return mav;
}
Aggregations