Search in sources :

Example 1 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class JobDefinitionResourceImpl method getJobDefinition.

public JobDefinitionDto getJobDefinition() {
    ManagementService managementService = engine.getManagementService();
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinitionId).singleResult();
    if (jobDefinition == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Job Definition with id " + jobDefinitionId + " does not exist");
    }
    return JobDefinitionDto.fromJobDefinition(jobDefinition);
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 2 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class ProcessDefinitionResourceImpl method getActivityStatistics.

@Override
public List<StatisticsResultDto> getActivityStatistics(Boolean includeFailedJobs, Boolean includeIncidents, String includeIncidentsForType) {
    if (includeIncidents != null && includeIncidentsForType != null) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeIncidentsForType can be set.");
    }
    ManagementService mgmtService = engine.getManagementService();
    ActivityStatisticsQuery query = mgmtService.createActivityStatisticsQuery(processDefinitionId);
    if (includeFailedJobs != null && includeFailedJobs) {
        query.includeFailedJobs();
    }
    if (includeIncidents != null && includeIncidents) {
        query.includeIncidents();
    } else if (includeIncidentsForType != null) {
        query.includeIncidentsForType(includeIncidentsForType);
    }
    List<ActivityStatistics> queryResults = query.list();
    List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
    for (ActivityStatistics queryResult : queryResults) {
        StatisticsResultDto dto = ActivityStatisticsResultDto.fromActivityStatistics(queryResult);
        results.add(dto);
    }
    return results;
}
Also used : ActivityStatistics(org.camunda.bpm.engine.management.ActivityStatistics) ManagementService(org.camunda.bpm.engine.ManagementService) ArrayList(java.util.ArrayList) ActivityStatisticsResultDto(org.camunda.bpm.engine.rest.dto.repository.ActivityStatisticsResultDto) StatisticsResultDto(org.camunda.bpm.engine.rest.dto.StatisticsResultDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ActivityStatisticsQuery(org.camunda.bpm.engine.management.ActivityStatisticsQuery)

Example 3 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class JobResourceImpl method executeJob.

@Override
public void executeJob() {
    try {
        ManagementService managementService = engine.getManagementService();
        managementService.executeJob(this.jobId);
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e.getMessage());
    } catch (RuntimeException r) {
        throw new RestException(Status.INTERNAL_SERVER_ERROR, r.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) RestException(org.camunda.bpm.engine.rest.exception.RestException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 4 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class JobResourceImpl method getStacktrace.

@Override
public String getStacktrace() {
    try {
        ManagementService managementService = engine.getManagementService();
        String stacktrace = managementService.getJobExceptionStacktrace(jobId);
        return stacktrace;
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.NOT_FOUND, e.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 5 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class JobResourceImpl method setJobRetries.

@Override
public void setJobRetries(RetriesDto dto) {
    try {
        ManagementService managementService = engine.getManagementService();
        managementService.setJobRetries(jobId, dto.getRetries());
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

ManagementService (org.camunda.bpm.engine.ManagementService)20 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)11 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 HistoryService (org.camunda.bpm.engine.HistoryService)4 Batch (org.camunda.bpm.engine.batch.Batch)4 ArrayList (java.util.ArrayList)3 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)3 Job (org.camunda.bpm.engine.runtime.Job)3 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)2 RestException (org.camunda.bpm.engine.rest.exception.RestException)2 HashMap (java.util.HashMap)1 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 CaseService (org.camunda.bpm.engine.CaseService)1 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 FilterService (org.camunda.bpm.engine.FilterService)1 FormService (org.camunda.bpm.engine.FormService)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1