use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.
the class SearchDocumentService method processService.
@Override
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_ANONYMOUS" })
public SearchDocumentResponse processService(final SearchDocumentRequest serviceRequest) {
final SearchDocumentResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
LOGGER.info("{}:{}", serviceRequest.getClass().getSimpleName(), serviceRequest.getSearchExpression());
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
}
final SearchDocumentResponse response = new SearchDocumentResponse(ServiceResult.SUCCESS);
final List<DocumentElement> searchResultTitles = documentElementDAO.search(serviceRequest.getSearchExpression(), serviceRequest.getMaxResults(), "id", "title", "subTitle");
if (!searchResultTitles.isEmpty()) {
response.setResultElement(searchResultTitles);
} else {
final List<DocumentContentData> searchResultContent = documentContentDataDAO.search(serviceRequest.getSearchExpression(), serviceRequest.getMaxResults(), "id", "content");
if (!searchResultContent.isEmpty()) {
final List<DocumentElement> searchResultTitlesForContent = new ArrayList<>();
for (final DocumentContentData documentContent : searchResultContent) {
searchResultTitlesForContent.add(documentElementDAO.load(documentContent.getId()));
}
response.setResultElement(searchResultTitlesForContent);
}
}
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 SearchDocumentService method createApplicationEventForService.
@Override
protected CreateApplicationEventRequest createApplicationEventForService(final SearchDocumentRequest serviceRequest) {
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.USER);
eventRequest.setApplicationOperation(ApplicationOperationType.READ);
eventRequest.setActionName(SearchDocumentRequest.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 SetGoogleAuthenticatorCredentialService method processService.
@Override
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
public SetGoogleAuthenticatorCredentialResponse processService(final SetGoogleAuthenticatorCredentialRequest serviceRequest) {
final SetGoogleAuthenticatorCredentialResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
LOGGER.info("{}:{}", serviceRequest.getClass().getSimpleName(), serviceRequest.getSessionId());
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
final SetGoogleAuthenticatorCredentialResponse response = new SetGoogleAuthenticatorCredentialResponse(ServiceResult.SUCCESS);
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
final GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey gKey = gAuth.createCredentials();
final UserAccount updateUserAccount = userDAO.load(userAccount.getHjid());
updateUserAccount.setGoogleAuthKey(gKey.getKey());
updateUserAccount.setGoogleAuthVerificationCode(gKey.getVerificationCode());
updateUserAccount.setGoogleAuthScratchCodes(gKey.getScratchCodes());
userDAO.merge(updateUserAccount);
final String otpAuthTotpURL = GoogleAuthenticatorQRGenerator.getOtpAuthTotpURL(agencyDAO.getAll().get(0).getAgencyName(), updateUserAccount.getEmail(), gKey);
response.setOtpAuthTotpURL(otpAuthTotpURL);
response.setGoogleAuthKey(gKey.getKey());
response.setGoogleAuthVerificationCode(gKey.getVerificationCode());
response.setGoogleAuthScratchCodes(gKey.getScratchCodes());
}
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 PageActionEventHelperImpl method createPageEvent.
@Override
public void createPageEvent(final ViewAction viewAction, final ApplicationEventGroup applicationEventGroup, final String page, final String pageMode, final String elementId) {
String pageModeToUse;
if (pageMode != null && elementId != null && pageMode.contains(elementId)) {
pageModeToUse = pageMode.replace(elementId, "").replace("/", "");
} else {
pageModeToUse = pageMode;
}
if ((pageModeToUse == null || "".equals(pageModeToUse)) && ApplicationEventGroup.USER == applicationEventGroup) {
pageModeToUse = "Overview";
}
final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
serviceRequest.setEventGroup(applicationEventGroup);
serviceRequest.setApplicationOperation(ApplicationOperationType.READ);
serviceRequest.setPage(StringUtils.defaultString(page));
serviceRequest.setPageMode(StringUtils.defaultString(pageModeToUse));
serviceRequest.setElementId(StringUtils.defaultString(elementId));
serviceRequest.setActionName(viewAction.toString());
serviceRequest.setUserId(UserContextUtil.getUserIdFromSecurityContext());
serviceRequest.setApplicationMessage(viewAction.toString());
applicationManager.service(serviceRequest);
}
Aggregations