Search in sources :

Example 11 with NullValueException

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

the class ProcessInstanceRestServiceImpl method setRetriesByProcess.

@Override
public BatchDto setRetriesByProcess(SetJobRetriesByProcessDto setJobRetriesDto) {
    try {
        EnsureUtil.ensureNotNull("setJobRetriesDto", setJobRetriesDto);
        EnsureUtil.ensureNotNull("retries", setJobRetriesDto.getRetries());
    } catch (NullValueException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
    ProcessInstanceQuery processInstanceQuery = null;
    if (setJobRetriesDto.getProcessInstanceQuery() != null) {
        processInstanceQuery = setJobRetriesDto.getProcessInstanceQuery().toQuery(getProcessEngine());
    }
    try {
        Batch batch = getProcessEngine().getManagementService().setJobRetriesAsync(setJobRetriesDto.getProcessInstances(), processInstanceQuery, setJobRetriesDto.getRetries().intValue());
        return BatchDto.fromBatch(batch);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) Batch(org.camunda.bpm.engine.batch.Batch) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) NullValueException(org.camunda.bpm.engine.exception.NullValueException)

Example 12 with NullValueException

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

the class JobRestServiceImpl method setRetries.

@Override
public BatchDto setRetries(SetJobRetriesDto setJobRetriesDto) {
    try {
        EnsureUtil.ensureNotNull("setJobRetriesDto", setJobRetriesDto);
        EnsureUtil.ensureNotNull("retries", setJobRetriesDto.getRetries());
    } catch (NullValueException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
    JobQuery jobQuery = null;
    if (setJobRetriesDto.getJobQuery() != null) {
        jobQuery = setJobRetriesDto.getJobQuery().toQuery(getProcessEngine());
    }
    try {
        Batch batch = getProcessEngine().getManagementService().setJobRetriesAsync(setJobRetriesDto.getJobIds(), jobQuery, setJobRetriesDto.getRetries().intValue());
        return BatchDto.fromBatch(batch);
    } catch (BadUserRequestException e) {
        throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
    }
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) NullValueException(org.camunda.bpm.engine.exception.NullValueException)

Example 13 with NullValueException

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

the class SaveTaskCmd method execute.

public Void execute(CommandContext commandContext) {
    ensureNotNull("task", task);
    String operation;
    if (task.getRevision() == 0) {
        try {
            checkCreateTask(task, commandContext);
            task.insert(null);
            commandContext.getHistoricTaskInstanceManager().createHistoricTask(task);
            operation = UserOperationLogEntry.OPERATION_TYPE_CREATE;
            task.executeMetrics(Metrics.ACTIVTY_INSTANCE_START);
        } catch (NullValueException e) {
            throw new NotValidException(e.getMessage(), e);
        }
    } else {
        checkTaskAssign(task, commandContext);
        task.update();
        operation = UserOperationLogEntry.OPERATION_TYPE_UPDATE;
    }
    task.fireAuthorizationProvider();
    task.fireEvents();
    task.createHistoricTaskDetails(operation);
    return null;
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) NullValueException(org.camunda.bpm.engine.exception.NullValueException)

Example 14 with NullValueException

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

the class DeploymentQueryTest method testQueryDeploymentAfter.

public void testQueryDeploymentAfter() throws Exception {
    Date later = DateTimeUtil.now().plus(10 * 3600).toDate();
    Date earlier = DateTimeUtil.now().minus(10 * 3600).toDate();
    long count = repositoryService.createDeploymentQuery().deploymentAfter(later).count();
    assertEquals(0, count);
    count = repositoryService.createDeploymentQuery().deploymentAfter(earlier).count();
    assertEquals(2, count);
    try {
        repositoryService.createDeploymentQuery().deploymentAfter(null);
        fail("Exception expected");
    } catch (NullValueException e) {
    // expected
    }
}
Also used : Date(java.util.Date) NullValueException(org.camunda.bpm.engine.exception.NullValueException)

Example 15 with NullValueException

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

the class RuntimeServiceTest method testGetInvalidActivityInstancesForActivity.

@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testGetActivityInstancesForActivity.bpmn20.xml")
@Test
public void testGetInvalidActivityInstancesForActivity() {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("miSubprocess");
    ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
    try {
        tree.getActivityInstances(null);
        fail("exception expected");
    } catch (NullValueException e) {
    // happy path
    }
}
Also used : ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) NullValueException(org.camunda.bpm.engine.exception.NullValueException) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

NullValueException (org.camunda.bpm.engine.exception.NullValueException)18 Test (org.junit.Test)7 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)3 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 Date (java.util.Date)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 Batch (org.camunda.bpm.engine.batch.Batch)2 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)2 CompositeDbHistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.CompositeDbHistoryEventHandler)2 CompositeHistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.CompositeHistoryEventHandler)2 HistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.HistoryEventHandler)2 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 Matchers.anyString (org.mockito.Matchers.anyString)2 HashMap (java.util.HashMap)1 FilterService (org.camunda.bpm.engine.FilterService)1 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)1 TaskService (org.camunda.bpm.engine.TaskService)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1