use of com.hack23.cia.model.internal.application.user.impl.UserAccount 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.model.internal.application.user.impl.UserAccount 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.model.internal.application.user.impl.UserAccount 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.model.internal.application.user.impl.UserAccount 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.model.internal.application.user.impl.UserAccount 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