Search in sources :

Example 1 with UpdateApplicationConfigurationResponse

use of com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse 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 2 with UpdateApplicationConfigurationResponse

use of com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse in project cia by Hack23.

the class AbstractServiceFunctionalIntegrationTest method updateApplicationConfiguration.

/**
 * Update application configuration.
 *
 * @param createTestApplicationSession
 *            the create test application session
 * @param applicationConfiguration
 *            the application configuration
 * @param propertyValue
 *            the property value
 */
private void updateApplicationConfiguration(final CreateApplicationSessionRequest createTestApplicationSession, final ApplicationConfiguration applicationConfiguration, final String propertyValue) {
    final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
    serviceRequest.setApplicationConfigurationId(applicationConfiguration.getHjid());
    serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
    serviceRequest.setComponentDescription(applicationConfiguration.getComponentDescription());
    serviceRequest.setConfigDescription(applicationConfiguration.getConfigDescription());
    serviceRequest.setConfigTitle(applicationConfiguration.getConfigTitle());
    serviceRequest.setComponentTitle(applicationConfiguration.getComponentTitle());
    serviceRequest.setPropertyValue(propertyValue);
    final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)

Example 3 with UpdateApplicationConfigurationResponse

use of com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse in project cia by Hack23.

the class UpdateApplicationConfigurationServiceITest method successTest.

/**
 * Success test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void successTest() throws Exception {
    setAuthenticatedAdminuser();
    final CreateApplicationSessionRequest createTestApplicationSession = createTestApplicationSession();
    final String randomUUID = UUID.randomUUID().toString();
    final ApplicationConfiguration applicationConfigurationToUpdate = applicationConfigurationService.checkValueOrLoadDefault("UpdateApplicationRequestTest property", "UpdateApplicationRequestTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, UpdateApplicationConfigurationServiceITest.class.getSimpleName(), "UpdateApplicationConfigurationService ITest", "FunctionalIntegrationTest", "UpdateApplicationRequestTest." + randomUUID, "true");
    final UpdateApplicationConfigurationRequest serviceRequest = new UpdateApplicationConfigurationRequest();
    serviceRequest.setApplicationConfigurationId(applicationConfigurationToUpdate.getHjid());
    serviceRequest.setSessionId(createTestApplicationSession.getSessionId());
    serviceRequest.setComponentDescription("componentDescription");
    serviceRequest.setConfigDescription("configDescription");
    serviceRequest.setConfigTitle("configTitle");
    serviceRequest.setComponentTitle("componentTitle");
    serviceRequest.setPropertyValue("false");
    final UpdateApplicationConfigurationResponse response = (UpdateApplicationConfigurationResponse) applicationManager.service(serviceRequest);
    assertNotNull(EXPECT_A_RESULT, response);
    assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
    final ApplicationConfiguration applicationConfigurationUpdated = applicationConfigurationService.checkValueOrLoadDefault("UpdateApplicationRequestTest property", "UpdateApplicationRequestTest should be set to true/false", ConfigurationGroup.AUTHORIZATION, UpdateApplicationConfigurationServiceITest.class.getSimpleName(), "UpdateApplicationConfigurationService ITest", "FunctionalIntegrationTest", "UpdateApplicationRequestTest." + randomUUID, "true");
    assertEquals("false", applicationConfigurationUpdated.getPropertyValue());
    assertEquals("configTitle", applicationConfigurationUpdated.getConfigTitle());
    assertEquals("configDescription", applicationConfigurationUpdated.getConfigDescription());
    assertEquals("componentTitle", applicationConfigurationUpdated.getComponentTitle());
    assertEquals("componentDescription", applicationConfigurationUpdated.getComponentDescription());
}
Also used : UpdateApplicationConfigurationRequest(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) UpdateApplicationConfigurationResponse(com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse) ApplicationConfiguration(com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Aggregations

UpdateApplicationConfigurationResponse (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationResponse)3 ApplicationConfiguration (com.hack23.cia.model.internal.application.system.impl.ApplicationConfiguration)2 UpdateApplicationConfigurationRequest (com.hack23.cia.service.api.action.admin.UpdateApplicationConfigurationRequest)2 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)1 Test (org.junit.Test)1 Secured (org.springframework.security.access.annotation.Secured)1