use of org.mifos.config.servicefacade.ConfigurationServiceFacade 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.mifos.config.servicefacade.ConfigurationServiceFacade in project head by mifos.
the class CreateSavingsAccountFormBeanTest method setUp.
@Before
public void setUp() {
MifosBeanValidator validator = new MifosBeanValidator();
LocalValidatorFactoryBean targetValidator = new LocalValidatorFactoryBean();
targetValidator.afterPropertiesSet();
validator.setTargetValidator(targetValidator);
formBean = new CreateSavingsAccountFormBean();
formBean.setValidator(validator);
questionnaireServiceFacade = mock(QuestionnaireServiceFacade.class);
formBean.setQuestionnaireServiceFascade(questionnaireServiceFacade);
configurationDto = new AccountingConfigurationDto();
configurationDto.setDigitsBeforeDecimal((short) 14);
configurationDto.setDigitsAfterDecimal((short) 1);
configurationServiceFacade = mock(ConfigurationServiceFacade.class);
when(configurationServiceFacade.getAccountingConfiguration()).thenReturn(configurationDto);
formBean.setConfigurationServiceFacade(configurationServiceFacade);
validationContext = new StubValidationContext();
validationException = new ValidationException("Root");
validationException.addChildException(new ValidationException("Child"));
}
use of org.mifos.config.servicefacade.ConfigurationServiceFacade in project head by mifos.
the class ApprovalMethodInvocationHandler method process.
@Override
public Object process(MethodInvocation invocation) throws Throwable {
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 (!RESTConfigKey.isApprovalRequired(configurationServiceFacade)) {
LOG.debug(invocation + " skip approval");
return invocation.proceed();
}
Method m = invocation.getMethod();
RequestMapping mapping = m.getAnnotation(RequestMapping.class);
if (isReadOnly(mapping)) {
LOG.debug(m.getName() + " is read only, hence returning control");
return invocation.proceed();
}
Class<?> methodClassType = m.getDeclaringClass();
if (!methodClassType.getSimpleName().endsWith("RESTController")) {
LOG.debug(m.getName() + " is not from REST controller, hence returning control");
return invocation.proceed();
}
if (methodClassType.equals(ApprovalRESTController.class)) {
LOG.debug(m.getName() + " is from Approval REST controller, hence returning control");
return invocation.proceed();
}
Object[] argValues = invocation.getArguments();
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 invocation.proceed();
}
Aggregations