Search in sources :

Example 26 with CreateApplicationEventRequest

use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.

the class AbstractBusinessServiceImpl method inputValidation.

protected final V inputValidation(final T serviceRequest) {
    final Set<ConstraintViolation<T>> validateRequest = validateRequest(serviceRequest);
    if (!validateRequest.isEmpty()) {
        final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
        final V response = handleInputViolations(eventRequest, validateRequest, createErrorResponse());
        createApplicationEventService.processService(eventRequest);
        return response;
    } else {
        return null;
    }
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)

Example 27 with CreateApplicationEventRequest

use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.

the class ComplianceCheckServiceImpl method createApplicationEventForService.

@Override
protected CreateApplicationEventRequest createApplicationEventForService(final ComplianceCheckRequest serviceRequest) {
    final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
    eventRequest.setEventGroup(ApplicationEventGroup.USER);
    eventRequest.setApplicationOperation(ApplicationOperationType.READ);
    eventRequest.setActionName(ComplianceCheckRequest.class.getSimpleName());
    eventRequest.setSessionId(serviceRequest.getSessionId());
    return eventRequest;
}
Also used : CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) ComplianceCheckRequest(com.hack23.cia.service.api.action.kpi.ComplianceCheckRequest)

Example 28 with CreateApplicationEventRequest

use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.

the class DisableGoogleAuthenticatorCredentialService method processService.

@Override
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
public DisableGoogleAuthenticatorCredentialResponse processService(final DisableGoogleAuthenticatorCredentialRequest serviceRequest) {
    final DisableGoogleAuthenticatorCredentialResponse 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 DisableGoogleAuthenticatorCredentialResponse response = new DisableGoogleAuthenticatorCredentialResponse(ServiceResult.SUCCESS);
    if (userAccount != null) {
        eventRequest.setUserId(userAccount.getUserId());
        final UserAccount updateUserAccount = userDAO.load(userAccount.getHjid());
        updateUserAccount.setGoogleAuthKey(null);
        updateUserAccount.setGoogleAuthVerificationCode(null);
        updateUserAccount.setGoogleAuthScratchCodes(null);
        userDAO.merge(updateUserAccount);
    }
    eventRequest.setApplicationMessage(response.getResult().toString());
    createApplicationEventService.processService(eventRequest);
    return response;
}
Also used : DisableGoogleAuthenticatorCredentialResponse(com.hack23.cia.service.api.action.user.DisableGoogleAuthenticatorCredentialResponse) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Example 29 with CreateApplicationEventRequest

use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.

the class DocumentWordCountService method processService.

@Override
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_ANONYMOUS" })
public DocumentWordCountResponse processService(final DocumentWordCountRequest serviceRequest) {
    final DocumentWordCountResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    LOGGER.info("{}:{}", serviceRequest.getClass().getSimpleName(), serviceRequest.getDocumentId());
    final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
    final UserAccount userAccount = getUserAccountFromSecurityContext();
    if (userAccount != null) {
        eventRequest.setUserId(userAccount.getUserId());
    }
    final DocumentWordCountResponse response = new DocumentWordCountResponse(ServiceResult.SUCCESS);
    final DocumentContentData documentContentData = documentContentDataDAO.findFirstByProperty(DocumentContentData_.id, serviceRequest.getDocumentId());
    if (documentContentData == null) {
        response.setWordCountMap(new HashMap<>());
    } else {
        response.setWordCountMap(wordCounter.calculateWordCount(documentContentData, serviceRequest.getMaxResults()));
    }
    eventRequest.setApplicationMessage(response.getResult().toString());
    createApplicationEventService.processService(eventRequest);
    return response;
}
Also used : DocumentWordCountResponse(com.hack23.cia.service.api.action.user.DocumentWordCountResponse) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) DocumentContentData(com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData) Secured(org.springframework.security.access.annotation.Secured)

Example 30 with CreateApplicationEventRequest

use of com.hack23.cia.service.api.action.application.CreateApplicationEventRequest in project cia by Hack23.

the class DocumentWordCountService method createApplicationEventForService.

@Override
protected CreateApplicationEventRequest createApplicationEventForService(final DocumentWordCountRequest serviceRequest) {
    final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
    eventRequest.setEventGroup(ApplicationEventGroup.USER);
    eventRequest.setApplicationOperation(ApplicationOperationType.READ);
    eventRequest.setActionName(DocumentWordCountRequest.class.getSimpleName());
    eventRequest.setSessionId(serviceRequest.getSessionId());
    return eventRequest;
}
Also used : CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) DocumentWordCountRequest(com.hack23.cia.service.api.action.user.DocumentWordCountRequest)

Aggregations

CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)32 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)15 Secured (org.springframework.security.access.annotation.Secured)14 ArrayList (java.util.ArrayList)5 ConstraintViolation (javax.validation.ConstraintViolation)3 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)3 DocumentContentData (com.hack23.cia.model.external.riksdagen.documentcontent.impl.DocumentContentData)2 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)2 ApplicationSession (com.hack23.cia.model.internal.application.system.impl.ApplicationSession)2 ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)2 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)2 CreateApplicationEventResponse (com.hack23.cia.service.api.action.application.CreateApplicationEventResponse)2 Date (java.util.Date)2 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 DocumentElement (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement)1 ApplicationActionEvent (com.hack23.cia.model.internal.application.system.impl.ApplicationActionEvent)1 ApplicationEventGroup (com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup)1 ApplicationOperationType (com.hack23.cia.model.internal.application.system.impl.ApplicationOperationType)1 UserAccount_ (com.hack23.cia.model.internal.application.user.impl.UserAccount_)1 UserLockStatus (com.hack23.cia.model.internal.application.user.impl.UserLockStatus)1