use of javax.ws.rs.NotFoundException in project graylog2-server by Graylog2.
the class ClusterConfigResource method update.
@PUT
@Timed
@Path("{configClass}")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update configuration in database")
@RequiresPermissions({ RestPermissions.CLUSTER_CONFIG_ENTRY_CREATE, RestPermissions.CLUSTER_CONFIG_ENTRY_EDIT })
@AuditEvent(type = AuditEventTypes.CLUSTER_CONFIGURATION_UPDATE)
public Response update(@ApiParam(name = "configClass", value = "The name of the cluster configuration class", required = true) @PathParam("configClass") @NotBlank String configClass, @ApiParam(name = "body", value = "The payload of the cluster configuration", required = true) @NotNull InputStream body) throws IOException {
final Class<?> cls = classFromName(configClass);
if (cls == null) {
throw new NotFoundException("Couldn't find configuration class \"" + configClass + "\"");
}
final Object o;
try {
o = objectMapper.readValue(body, cls);
} catch (Exception e) {
final String msg = "Couldn't parse cluster configuration \"" + configClass + "\".";
LOG.error(msg, e);
throw new BadRequestException(msg);
}
try {
clusterConfigService.write(o);
} catch (Exception e) {
final String msg = "Couldn't write cluster config \"" + configClass + "\".";
LOG.error(msg, e);
throw new InternalServerErrorException(msg, e);
}
return Response.accepted(o).build();
}
use of javax.ws.rs.NotFoundException in project graylog2-server by Graylog2.
the class LoggersResource method setSubsystemLoggerLevel.
@PUT
@Timed
@ApiOperation(value = "Set the loglevel of a whole subsystem", notes = "Provided level is falling back to DEBUG if it does not exist")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such subsystem.") })
@Path("/subsystems/{subsystem}/level/{level}")
@AuditEvent(type = AuditEventTypes.LOG_LEVEL_UPDATE)
public void setSubsystemLoggerLevel(@ApiParam(name = "subsystem", required = true) @PathParam("subsystem") @NotEmpty String subsystemTitle, @ApiParam(name = "level", required = true) @PathParam("level") @NotEmpty String level) {
if (!SUBSYSTEMS.containsKey(subsystemTitle)) {
final String msg = "No such logging subsystem: [" + subsystemTitle + "]";
LOG.warn(msg);
throw new NotFoundException(msg);
}
checkPermission(RestPermissions.LOGGERS_EDITSUBSYSTEM, subsystemTitle);
final Subsystem subsystem = SUBSYSTEMS.get(subsystemTitle);
final Level newLevel = Level.toLevel(level.toUpperCase(Locale.ENGLISH));
setLoggerLevel(subsystem.getCategory(), newLevel);
LOG.debug("Successfully set log level for subsystem \"{}\" to \"{}\"", subsystem.getTitle(), newLevel);
}
use of javax.ws.rs.NotFoundException in project ddf by codice.
the class EndpointUtil method getMetacard.
public Metacard getMetacard(String id) throws UnsupportedQueryException, SourceUnavailableException, FederationException {
Filter idFilter = filterBuilder.attribute(Metacard.ID).is().equalTo().text(id);
Filter tagsFilter = filterBuilder.attribute(Metacard.TAGS).is().like().text("*");
Filter filter = filterBuilder.allOf(idFilter, tagsFilter);
QueryResponse queryResponse = catalogFramework.query(new QueryRequestImpl(new QueryImpl(filter), false));
if (queryResponse.getResults().isEmpty()) {
throw new NotFoundException("Could not find metacard for id: " + id);
}
Result result = queryResponse.getResults().get(0);
return result.getMetacard();
}
Aggregations