use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class SendEmailService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final SendEmailRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.CREATE);
eventRequest.setActionName(SendEmailRequest.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 SendEmailService method processService.
@Override
@Secured({ "ROLE_ADMIN" })
public SendEmailResponse processService(final SendEmailRequest serviceRequest) {
final SendEmailResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
LOGGER.info("{} started:{}", serviceRequest.getClass().getSimpleName(), userAccount.getEmail());
eventRequest.setUserId(userAccount.getUserId());
}
SendEmailResponse response;
if (isValidEmailAddress(serviceRequest.getEmail())) {
emailService.sendEmail(serviceRequest.getEmail(), serviceRequest.getSubject(), serviceRequest.getContent());
response = new SendEmailResponse(ServiceResult.SUCCESS);
} else {
response = new SendEmailResponse(ServiceResult.FAILURE);
response.setErrorMessage(EMAIL_IS_NOT_A_VALID_EMAIL_ADDRESS);
}
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 processService.
@Override
@Secured({ "ROLE_ADMIN" })
public UpdateApplicationConfigurationResponse processService(final UpdateApplicationConfigurationRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UpdateApplicationConfigurationResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
}
UpdateApplicationConfigurationResponse response;
final ApplicationConfiguration applicationConfiguration = applicationConfigurationDAO.load(serviceRequest.getApplicationConfigurationId());
if (applicationConfiguration != null) {
eventRequest.setElementId(serviceRequest.getApplicationConfigurationId().toString());
applicationConfiguration.setConfigTitle(serviceRequest.getConfigTitle());
applicationConfiguration.setConfigDescription(serviceRequest.getConfigDescription());
applicationConfiguration.setComponentTitle(serviceRequest.getComponentTitle());
applicationConfiguration.setComponentDescription(serviceRequest.getComponentDescription());
applicationConfiguration.setPropertyValue(serviceRequest.getPropertyValue());
applicationConfigurationDAO.persist(applicationConfiguration);
response = new UpdateApplicationConfigurationResponse(ServiceResult.SUCCESS);
} else {
response = new UpdateApplicationConfigurationResponse(ServiceResult.FAILURE);
}
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 UpdateSearchIndexService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final UpdateSearchIndexRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.ADMIN);
eventRequest.setApplicationOperation(ApplicationOperationType.UPDATE);
eventRequest.setActionName(UpdateSearchIndexRequest.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 UpdateSearchIndexService method processService.
@Override
@Secured({ "ROLE_ADMIN" })
public UpdateSearchIndexResponse processService(final UpdateSearchIndexRequest serviceRequest) {
final UpdateSearchIndexResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
LOGGER.info("{} started:{}", serviceRequest.getClass().getSimpleName(), userAccount.getEmail());
eventRequest.setUserId(userAccount.getUserId());
}
UpdateSearchIndexResponse response;
try {
searchIndexer.updateSearchIndex();
response = new UpdateSearchIndexResponse(ServiceResult.SUCCESS);
} catch (final InterruptedException e) {
LOGGER.warn("Update Index failed", e);
Thread.currentThread().interrupt();
response = new UpdateSearchIndexResponse(ServiceResult.FAILURE);
}
eventRequest.setApplicationMessage(response.getResult().toString());
createApplicationEventService.processService(eventRequest);
return response;
}
Aggregations