use of javax.ws.rs.DELETE in project ddf by codice.
the class RESTEndpoint method deleteDocument.
/**
* REST Delete. Deletes a record from the catalog.
*
* @param id
* @return
*/
@DELETE
@Path("/{id}")
public Response deleteDocument(@PathParam("id") String id, @Context HttpServletRequest httpRequest) {
LOGGER.debug("DELETE");
Response response;
try {
if (id != null) {
DeleteRequestImpl deleteReq = new DeleteRequestImpl(id);
catalogFramework.delete(deleteReq);
response = Response.ok(id).build();
LOGGER.debug("Attempting to delete Metacard with id: {}", id);
} else {
String errorMessage = "ID of entry not specified, cannot do DELETE.";
LOGGER.info(errorMessage);
throw new ServerErrorException(errorMessage, Status.BAD_REQUEST);
}
} catch (SourceUnavailableException ce) {
String exceptionMessage = "Could not delete entry from catalog since the source is unavailable: ";
LOGGER.info(exceptionMessage, ce);
throw new ServerErrorException(exceptionMessage, Status.INTERNAL_SERVER_ERROR);
} catch (InternalIngestException e) {
String exceptionMessage = "Error deleting entry from catalog: ";
LOGGER.info(exceptionMessage, e);
throw new ServerErrorException(exceptionMessage, Status.INTERNAL_SERVER_ERROR);
} catch (IngestException e) {
String exceptionMessage = "Error deleting entry from catalog: ";
LOGGER.info(exceptionMessage, e);
throw new ServerErrorException(exceptionMessage, Status.BAD_REQUEST);
}
return response;
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class BusinessServiceRestService method removeEdge.
@DELETE
@Path("{id}/edges/{edgeId}")
public Response removeEdge(@PathParam("id") final Long serviceId, @PathParam("edgeId") final Long edgeId) {
final BusinessService service = getManager().getBusinessServiceById(serviceId);
final Edge edge = getManager().getEdgeById(edgeId);
boolean changed = getManager().deleteEdge(service, edge);
if (!changed) {
return Response.notModified().build();
}
service.save();
return Response.ok().build();
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class BusinessServiceRestService method delete.
@DELETE
@Path("{id}")
public Response delete(@PathParam("id") Long id) {
final BusinessService service = getManager().getBusinessServiceById(id);
getManager().deleteBusinessService(service);
return Response.ok().build();
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class AbstractDaoRestServiceWithDTO method delete.
@DELETE
@Path("{id}")
public Response delete(@Context final SecurityContext securityContext, @Context final UriInfo uriInfo, @PathParam("id") final I id) {
writeLock();
try {
final T object = doGet(uriInfo, id);
if (object == null) {
return Response.status(Status.NOT_FOUND).build();
}
doDelete(securityContext, uriInfo, object);
return Response.noContent().build();
} finally {
writeUnlock();
}
}
use of javax.ws.rs.DELETE in project opennms by OpenNMS.
the class AbstractDaoRestServiceWithDTO method deleteMany.
@DELETE
public Response deleteMany(@Context final SecurityContext securityContext, @Context final UriInfo uriInfo, @Context final SearchContext searchContext) {
writeLock();
try {
Criteria crit = getCriteria(uriInfo, searchContext);
final List<T> objects = getDao().findMatching(crit);
if (objects == null || objects.size() == 0) {
return Response.status(Status.NOT_FOUND).build();
}
for (T object : objects) {
doDelete(securityContext, uriInfo, object);
}
return Response.noContent().build();
} finally {
writeUnlock();
}
}
Aggregations