use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class CreateApplicationEventServiceITest method serviceCreateApplicationEventRequestSuccessTest.
/**
* Service create application event request success test.
*
* @throws Exception
* the exception
*/
@Test
@PerfTest(threads = 4, duration = 3000, warmUp = 1500)
@Required(max = 1000, average = 400, percentile95 = 450, throughput = 10)
public void serviceCreateApplicationEventRequestSuccessTest() throws Exception {
setAuthenticatedAnonymousUser();
final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
serviceRequest.setSessionId(createSessionRequest.getSessionId());
serviceRequest.setApplicationMessage("applicationMessage");
serviceRequest.setEventGroup(ApplicationEventGroup.USER);
serviceRequest.setApplicationOperation(ApplicationOperationType.CREATE);
serviceRequest.setPage("Test");
serviceRequest.setPageMode("PageMode");
serviceRequest.setElementId("ElementId");
serviceRequest.setActionName("Content");
serviceRequest.setApplicationMessage("applicationMessage");
serviceRequest.setErrorMessage("errorMessage");
final CreateApplicationEventResponse response = (CreateApplicationEventResponse) applicationManager.service(serviceRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
final List<ApplicationSession> findListByProperty = applicationSessionDAO.findListByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
assertEquals(1, findListByProperty.size());
final ApplicationSession applicationSession = findListByProperty.get(0);
assertNotNull(applicationSession);
assertEquals(1, applicationSession.getEvents().size());
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class ManageUserAccountService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final ManageUserAccountRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.UPDATE);
eventRequest.setActionName(ManageUserAccountRequest.class.getSimpleName());
eventRequest.setSessionId(serviceRequest.getSessionId());
return eventRequest;
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class RemoveDataService method processService.
@Override
@Secured({ "ROLE_ADMIN" })
public RemoveDataResponse processService(final RemoveDataRequest serviceRequest) {
final RemoveDataResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
}
final RemoveDataResponse response = new RemoveDataResponse(ServiceResult.SUCCESS);
switch(serviceRequest.getDataType()) {
case POLITICIAN:
removeDataManager.removePersonData();
break;
case DOCUMENTS:
removeDataManager.removeDocuments();
removeDataManager.removeCommitteeProposals();
removeDataManager.removeDocumentStatus();
break;
case APPLICATION_HISTORY:
removeDataManager.removeApplicationHistory();
break;
}
eventRequest.setApplicationMessage(response.getResult().toString());
createApplicationEventService.processService(eventRequest);
return response;
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class UpdateApplicationConfigurationService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final UpdateApplicationConfigurationRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.UPDATE);
eventRequest.setActionName(UpdateApplicationConfigurationRequest.class.getSimpleName());
eventRequest.setSessionId(serviceRequest.getSessionId());
return eventRequest;
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class AuthorizationFailureEventListener method onApplicationEvent.
@Override
public void onApplicationEvent(final AuthorizationFailureEvent authorizationFailureEvent) {
final String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();
final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
serviceRequest.setSessionId(sessionId);
serviceRequest.setEventGroup(ApplicationEventGroup.APPLICATION);
serviceRequest.setApplicationOperation(ApplicationOperationType.AUTHORIZATION);
serviceRequest.setUserId(UserContextUtil.getUserIdFromSecurityContext());
final Page currentPageIfAny = Page.getCurrent();
final String requestUrl = UserContextUtil.getRequestUrl(currentPageIfAny);
final UI currentUiIfAny = UI.getCurrent();
String methodInfo = "";
if (currentPageIfAny != null && currentUiIfAny != null && currentUiIfAny.getNavigator() != null && currentUiIfAny.getNavigator().getCurrentView() != null) {
serviceRequest.setPage(currentUiIfAny.getNavigator().getCurrentView().getClass().getSimpleName());
serviceRequest.setPageMode(currentPageIfAny.getUriFragment());
}
if (authorizationFailureEvent.getSource() instanceof ReflectiveMethodInvocation) {
final ReflectiveMethodInvocation methodInvocation = (ReflectiveMethodInvocation) authorizationFailureEvent.getSource();
if (methodInvocation.getMethod() != null && methodInvocation.getThis() != null) {
methodInfo = methodInvocation.getThis().getClass().getSimpleName() + "." + methodInvocation.getMethod().getName();
}
}
final Collection<? extends GrantedAuthority> authorities = authorizationFailureEvent.getAuthentication().getAuthorities();
final Collection<ConfigAttribute> configAttributes = authorizationFailureEvent.getConfigAttributes();
serviceRequest.setErrorMessage(MessageFormat.format(ERROR_MESSAGE_FORMAT, requestUrl, methodInfo, AUTHORITIES, authorities, REQUIRED_AUTHORITIES, configAttributes, authorizationFailureEvent.getSource()));
serviceRequest.setApplicationMessage(ACCESS_DENIED);
applicationManager.service(serviceRequest);
LOGGER.info(LOG_MSG_AUTHORIZATION_FAILURE_SESSION_ID_AUTHORITIES_REQUIRED_AUTHORITIES, requestUrl.replaceAll(CRLF, CRLF_REPLACEMENT), methodInfo.replaceAll(CRLF, CRLF_REPLACEMENT), sessionId.replaceAll(CRLF, CRLF_REPLACEMENT), authorities, configAttributes);
}
Aggregations