Search in sources :

Example 1 with ProjectIndexEvent

use of com.epam.ta.reportportal.core.events.activity.ProjectIndexEvent in project service-api by reportportal.

the class UpdateProjectHandlerImpl method indexProjectData.

@Override
public OperationCompletionRS indexProjectData(String projectName, ReportPortalUser user) {
    expect(analyzerServiceClient.hasClients(), Predicate.isEqual(true)).verify(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "There are no analyzer deployed.");
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
    expect(ofNullable(indexerStatusCache.getIndexingStatus().getIfPresent(project.getId())).orElse(false), equalTo(false)).verify(ErrorType.FORBIDDEN_OPERATION, "Index can not be removed until index generation proceeds.");
    Cache<Long, Long> analyzeStatus = analyzerStatusCache.getAnalyzeStatus(AUTO_ANALYZER_KEY).orElseThrow(() -> new ReportPortalException(ErrorType.ANALYZER_NOT_FOUND, AUTO_ANALYZER_KEY));
    expect(analyzeStatus.asMap().containsValue(project.getId()), equalTo(false)).verify(ErrorType.FORBIDDEN_OPERATION, "Index can not be removed until auto-analysis proceeds.");
    logIndexer.deleteIndex(project.getId());
    logIndexer.index(project.getId(), AnalyzerUtils.getAnalyzerConfig(project)).thenAcceptAsync(indexedCount -> mailServiceFactory.getDefaultEmailService(true).sendIndexFinishedEmail("Index generation has been finished", user.getEmail(), indexedCount));
    messageBus.publishActivity(new ProjectIndexEvent(project.getId(), project.getName(), user.getUserId(), user.getUsername(), true));
    return new OperationCompletionRS("Log indexing has been started");
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ProjectIndexEvent(com.epam.ta.reportportal.core.events.activity.ProjectIndexEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Example 2 with ProjectIndexEvent

use of com.epam.ta.reportportal.core.events.activity.ProjectIndexEvent in project service-api by reportportal.

the class DeleteProjectHandlerImpl method deleteProjectIndex.

@Override
public OperationCompletionRS deleteProjectIndex(String projectName, String username) {
    expect(analyzerServiceClient.hasClients(), Predicate.isEqual(true)).verify(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "There are no analyzer deployed.");
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
    User user = userRepository.findByLogin(username).orElseThrow(() -> new ReportPortalException(ErrorType.USER_NOT_FOUND, username));
    expect(AnalyzerUtils.getAnalyzerConfig(project).isIndexingRunning(), Predicate.isEqual(false)).verify(ErrorType.FORBIDDEN_OPERATION, "Index can not be removed until index generation proceeds.");
    Cache<Long, Long> analyzeStatus = analyzerStatusCache.getAnalyzeStatus(AUTO_ANALYZER_KEY).orElseThrow(() -> new ReportPortalException(ErrorType.ANALYZER_NOT_FOUND, AUTO_ANALYZER_KEY));
    expect(analyzeStatus.asMap().containsValue(project.getId()), Predicate.isEqual(false)).verify(ErrorType.FORBIDDEN_OPERATION, "Index can not be removed until index generation proceeds.");
    logIndexer.deleteIndex(project.getId());
    messageBus.publishActivity(new ProjectIndexEvent(project.getId(), project.getName(), user.getId(), user.getLogin(), false));
    return new OperationCompletionRS("Project index with name = '" + projectName + "' is successfully deleted.");
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) User(com.epam.ta.reportportal.entity.user.User) ProjectIndexEvent(com.epam.ta.reportportal.core.events.activity.ProjectIndexEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

ProjectIndexEvent (com.epam.ta.reportportal.core.events.activity.ProjectIndexEvent)2 Project (com.epam.ta.reportportal.entity.project.Project)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 User (com.epam.ta.reportportal.entity.user.User)1