use of javax.ws.rs.NotFoundException in project jersey by jersey.
the class DomainResource method getProgress.
@Path("process/{id}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
@GET
public EventOutput getProgress(@PathParam("id") int id, @DefaultValue("false") @QueryParam("testSource") boolean testSource) {
final Process process = processes.get(id);
if (process != null) {
if (testSource) {
process.release();
}
final EventOutput eventOutput = new EventOutput();
process.getBroadcaster().add(eventOutput);
return eventOutput;
} else {
throw new NotFoundException();
}
}
use of javax.ws.rs.NotFoundException in project jersey by jersey.
the class ViewableMessageBodyWriter method writeTo.
@Override
public void writeTo(final Viewable viewable, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException {
try {
final ResolvedViewable resolvedViewable = resolve(viewable);
if (resolvedViewable == null) {
final String message = LocalizationMessages.TEMPLATE_NAME_COULD_NOT_BE_RESOLVED(viewable.getTemplateName());
throw new WebApplicationException(new ProcessingException(message), Response.Status.NOT_FOUND);
}
httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, resolvedViewable.getMediaType());
resolvedViewable.writeTo(entityStream, httpHeaders);
} catch (ViewableContextException vce) {
throw new NotFoundException(vce);
}
}
use of javax.ws.rs.NotFoundException in project graylog2-server by Graylog2.
the class MessageResource method parse.
@POST
@Path("/parse")
@Timed
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Parse a raw message")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Specified codec does not exist."), @ApiResponse(code = 400, message = "Could not decode message.") })
@NoAuditEvent("only used to parse a test message")
public ResultMessage parse(@ApiParam(name = "JSON body", required = true) MessageParseRequest request) {
Codec codec;
try {
final Configuration configuration = new Configuration(request.configuration());
codec = codecFactory.create(request.codec(), configuration);
} catch (IllegalArgumentException e) {
throw new NotFoundException(e);
}
final ResolvableInetSocketAddress remoteAddress = ResolvableInetSocketAddress.wrap(new InetSocketAddress(request.remoteAddress(), 1234));
final RawMessage rawMessage = new RawMessage(0, new UUID(), Tools.nowUTC(), remoteAddress, request.message().getBytes(StandardCharsets.UTF_8));
final Message message = decodeMessage(codec, remoteAddress, rawMessage);
return ResultMessage.createFromMessage(message);
}
use of javax.ws.rs.NotFoundException in project keywhiz by square.
the class AutomationGroupResource method deleteGroup.
/**
* Deletes a group
*
* @param groupId the ID of the group to delete
* @excludeParams automationClient
* @description Deletes a single group by id
* @responseMessage 200 Deleted group
* @responseMessage 404 Group not found by id
*/
@Timed
@ExceptionMetered
@DELETE
@Path("{groupId}")
public Response deleteGroup(@Auth AutomationClient automationClient, @PathParam("groupId") LongParam groupId) {
Group group = groupDAO.getGroupById(groupId.get()).orElseThrow(NotFoundException::new);
groupDAO.deleteGroup(group);
Map<String, String> extraInfo = new HashMap<>();
extraInfo.put("deprecated", "true");
auditLog.recordEvent(new Event(Instant.now(), EventTag.GROUP_CREATE, automationClient.getName(), group.getName(), extraInfo));
return Response.ok().build();
}
use of javax.ws.rs.NotFoundException in project keywhiz by square.
the class AutomationGroupResource method getGroupById.
/**
* Retrieve Group by ID
*
* @param groupId the ID of the group to retrieve
* @excludeParams automationClient
* @description Returns a single Group if found
* @responseMessage 200 Found and retrieved Group with given ID
* @responseMessage 404 Group with given ID not Found
*/
@Timed
@ExceptionMetered
@GET
@Path("{groupId}")
public GroupDetailResponse getGroupById(@Auth AutomationClient automationClient, @PathParam("groupId") LongParam groupId) {
Group group = groupDAO.getGroupById(groupId.get()).orElseThrow(NotFoundException::new);
ImmutableList<Client> clients = ImmutableList.copyOf(aclDAO.getClientsFor(group));
ImmutableList<SanitizedSecret> sanitizedSecrets = ImmutableList.copyOf(aclDAO.getSanitizedSecretsFor(group));
return GroupDetailResponse.fromGroup(group, sanitizedSecrets, clients);
}
Aggregations