Search in sources :

Example 51 with InvalidRequestException

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

the class TaskAttachmentResourceImpl method getAttachmentData.

@Override
public InputStream getAttachmentData(String attachmentId) {
    ensureHistoryEnabled(Status.NOT_FOUND);
    InputStream attachmentData = engine.getTaskService().getTaskAttachmentContent(taskId, attachmentId);
    if (attachmentData != null) {
        return attachmentData;
    } else {
        throw new InvalidRequestException(Status.NOT_FOUND, "Attachment content for attachment with id '" + attachmentId + "' does not exist for task id '" + taskId + "'.");
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 52 with InvalidRequestException

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

the class TaskAttachmentResourceImpl method getAttachment.

@Override
public AttachmentDto getAttachment(String attachmentId) {
    ensureHistoryEnabled(Status.NOT_FOUND);
    Attachment attachment = engine.getTaskService().getTaskAttachment(taskId, attachmentId);
    if (attachment == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Task attachment with id " + attachmentId + " does not exist for task id '" + taskId + "'.");
    }
    return AttachmentDto.fromAttachment(attachment);
}
Also used : Attachment(org.camunda.bpm.engine.task.Attachment) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 53 with InvalidRequestException

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

the class MessageEventSubscriptionResource method getEventSubscription.

@Override
public EventSubscriptionDto getEventSubscription() {
    RuntimeService runtimeService = engine.getRuntimeService();
    EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().executionId(executionId).eventName(messageName).eventType(MESSAGE_EVENT_TYPE).singleResult();
    if (eventSubscription == null) {
        String errorMessage = String.format("Message event subscription for execution %s named %s does not exist", executionId, messageName);
        throw new InvalidRequestException(Status.NOT_FOUND, errorMessage);
    }
    return EventSubscriptionDto.fromEventSubscription(eventSubscription);
}
Also used : EventSubscription(org.camunda.bpm.engine.runtime.EventSubscription) RuntimeService(org.camunda.bpm.engine.RuntimeService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 54 with InvalidRequestException

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

the class FetchAndLockHandlerTest method shouldResumeAsyncResponseDueToTooManyRequests.

@Test
public void shouldResumeAsyncResponseDueToTooManyRequests() {
    // given
    // when
    AsyncResponse asyncResponse = mock(AsyncResponse.class);
    handler.errorTooManyRequests(asyncResponse);
    // then
    ArgumentCaptor<InvalidRequestException> argumentCaptor = ArgumentCaptor.forClass(InvalidRequestException.class);
    verify(asyncResponse).resume(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getMessage(), is("At the moment the server has to handle too " + "many requests at the same time. Please try again later."));
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) AsyncResponse(javax.ws.rs.container.AsyncResponse) Test(org.junit.Test)

Example 55 with InvalidRequestException

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

the class FetchAndLockHandlerTest method shouldRejectRequestDueToShutdown.

@Test
public void shouldRejectRequestDueToShutdown() {
    // given
    AsyncResponse asyncResponse = mock(AsyncResponse.class);
    handler.addPendingRequest(createDto(5000L), asyncResponse, processEngine);
    handler.acquire();
    // assume
    assertThat(handler.getPendingRequests().size(), is(1));
    // when
    handler.rejectPendingRequests();
    // then
    ArgumentCaptor<InvalidRequestException> argumentCaptor = ArgumentCaptor.forClass(InvalidRequestException.class);
    verify(asyncResponse).resume(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getMessage(), is("Request rejected due to shutdown of application server."));
}
Also used : InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) AsyncResponse(javax.ws.rs.container.AsyncResponse) Test(org.junit.Test)

Aggregations

InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)116 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)30 RestException (org.camunda.bpm.engine.rest.exception.RestException)25 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)20 NotValidException (org.camunda.bpm.engine.exception.NotValidException)12 ArrayList (java.util.ArrayList)11 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)11 ManagementService (org.camunda.bpm.engine.ManagementService)11 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)11 VariableQueryParameterDto (org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto)10 HistoryService (org.camunda.bpm.engine.HistoryService)9 RuntimeService (org.camunda.bpm.engine.RuntimeService)9 InputStream (java.io.InputStream)8 RepositoryService (org.camunda.bpm.engine.RepositoryService)8 Batch (org.camunda.bpm.engine.batch.Batch)8 URI (java.net.URI)6 VariableMap (org.camunda.bpm.engine.variable.VariableMap)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 FormService (org.camunda.bpm.engine.FormService)5 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)5