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