use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class ManageUserAccountService method processService.
@Override
@Secured({ "ROLE_ADMIN" })
public ManageUserAccountResponse processService(final ManageUserAccountRequest serviceRequest) {
final ManageUserAccountResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
}
ManageUserAccountResponse response;
final Set<ConstraintViolation<ManageUserAccountRequest>> requestConstraintViolations = validateRequest(serviceRequest);
if (!requestConstraintViolations.isEmpty()) {
response = new ManageUserAccountResponse(ServiceResult.FAILURE);
final String errorMessage = requestConstraintViolations.stream().sorted((p1, p2) -> p1.getPropertyPath().toString().compareTo(p2.getPropertyPath().toString())).map(p -> p.getPropertyPath().toString() + " " + p.getMessage()).collect(Collectors.joining(", "));
response.setErrorMessage(errorMessage);
eventRequest.setErrorMessage(errorMessage);
} else {
response = performOperation(serviceRequest, eventRequest);
}
createApplicationEventService.processService(eventRequest);
return response;
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class ManageUserAccountService method performOperation.
/**
* Perform operation.
*
* @param serviceRequest
* the service request
* @param eventRequest
* the event request
* @return the manage user account response
*/
private ManageUserAccountResponse performOperation(final ManageUserAccountRequest serviceRequest, final CreateApplicationEventRequest eventRequest) {
ManageUserAccountResponse response;
eventRequest.setElementId(serviceRequest.getUserAcountId());
eventRequest.setApplicationMessage(serviceRequest.getAccountOperation().toString());
final UserAccount accountToModify = userDAO.findFirstByProperty(UserAccount_.userId, serviceRequest.getUserAcountId());
final UserCommand userCommand = userCommandMap.get(serviceRequest.getAccountOperation());
if (accountToModify != null && userCommand != null) {
response = userCommand.execute(accountToModify);
} else {
response = new ManageUserAccountResponse(ServiceResult.FAILURE);
}
eventRequest.setApplicationMessage(response.getResult().toString());
return response;
}
use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class RefreshDataViewsService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final RefreshDataViewsRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.UPDATE);
eventRequest.setActionName(RefreshDataViewsRequest.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 RefreshDataViewsService method processService.
@Override
@Secured({ "ROLE_ADMIN" })
public RefreshDataViewsResponse processService(final RefreshDataViewsRequest serviceRequest) {
final RefreshDataViewsResponse 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 RefreshDataViewsResponse response = new RefreshDataViewsResponse(ServiceResult.SUCCESS);
viewDataManager.refreshViews();
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 RemoveDataService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final RemoveDataRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.DELETE);
eventRequest.setActionName(RemoveDataRequest.class.getSimpleName() + ":" + serviceRequest.getDataType());
eventRequest.setSessionId(serviceRequest.getSessionId());
return eventRequest;
}
Aggregations