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");
}
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.");
}
Aggregations