Search in sources :

Example 1 with UpdateSearchIndexResponse

use of com.hack23.cia.service.api.action.admin.UpdateSearchIndexResponse 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)

Example 2 with UpdateSearchIndexResponse

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

the class UpdateSearchIndexServiceITest method Test.

/**
 * Test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void Test() throws Exception {
    setAuthenticatedAdminuser();
    final CreateApplicationSessionRequest createSessionRequest = createTestApplicationSession();
    final UpdateSearchIndexRequest serviceRequest = new UpdateSearchIndexRequest();
    serviceRequest.setSessionId(createSessionRequest.getSessionId());
    final UpdateSearchIndexResponse response = (UpdateSearchIndexResponse) applicationManager.service(serviceRequest);
    assertNotNull(EXPECT_A_RESULT, response);
}
Also used : CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) UpdateSearchIndexResponse(com.hack23.cia.service.api.action.admin.UpdateSearchIndexResponse) UpdateSearchIndexRequest(com.hack23.cia.service.api.action.admin.UpdateSearchIndexRequest) Test(org.junit.Test) AbstractServiceFunctionalIntegrationTest(com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)

Aggregations

UpdateSearchIndexResponse (com.hack23.cia.service.api.action.admin.UpdateSearchIndexResponse)2 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)1 UpdateSearchIndexRequest (com.hack23.cia.service.api.action.admin.UpdateSearchIndexRequest)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