Search in sources :

Example 21 with UserAccount

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;
}
Also used : ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount)

Example 22 with UserAccount

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;
}
Also used : CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) RefreshDataViewsResponse(com.hack23.cia.service.api.action.admin.RefreshDataViewsResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Example 23 with UserAccount

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;
}
Also used : SendEmailResponse(com.hack23.cia.service.api.action.admin.SendEmailResponse) 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 24 with UserAccount

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;
}
Also used : UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) Secured(org.springframework.security.access.annotation.Secured)

Example 25 with UserAccount

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;
}
Also used : UpdateSearchIndexResponse(com.hack23.cia.service.api.action.admin.UpdateSearchIndexResponse) 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)

Aggregations

UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)37 Test (org.junit.Test)19 Secured (org.springframework.security.access.annotation.Secured)18 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)14 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)14 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)13 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)13 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)13 PerfTest (org.databene.contiperf.PerfTest)10 LoginResponse (com.hack23.cia.service.api.action.application.LoginResponse)8 LoginRequest (com.hack23.cia.service.api.action.application.LoginRequest)7 PageModeMenuCommand (com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand)7 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)6 ArrayList (java.util.ArrayList)6 WebDriver (org.openqa.selenium.WebDriver)6 ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)5 Required (org.databene.contiperf.Required)5 LogoutRequest (com.hack23.cia.service.api.action.application.LogoutRequest)4 VerticalLayout (com.vaadin.ui.VerticalLayout)4 WebElement (org.openqa.selenium.WebElement)4