Search in sources :

Example 66 with DELETE

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;
}
Also used : SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) QueryResponse(ddf.catalog.operation.QueryResponse) Response(javax.ws.rs.core.Response) CreateResponse(ddf.catalog.operation.CreateResponse) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) InternalIngestException(ddf.catalog.source.InternalIngestException) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) IngestException(ddf.catalog.source.IngestException) InternalIngestException(ddf.catalog.source.InternalIngestException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 67 with DELETE

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();
}
Also used : BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) ChildEdge(org.opennms.netmgt.bsm.service.model.edge.ChildEdge) Edge(org.opennms.netmgt.bsm.service.model.edge.Edge) IpServiceEdge(org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge) ReductionKeyEdge(org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 68 with DELETE

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();
}
Also used : BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 69 with DELETE

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();
    }
}
Also used : GET(javax.ws.rs.GET) POST(javax.ws.rs.POST) PUT(javax.ws.rs.PUT) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 70 with DELETE

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();
    }
}
Also used : GET(javax.ws.rs.GET) POST(javax.ws.rs.POST) PUT(javax.ws.rs.PUT) Criteria(org.opennms.core.criteria.Criteria) DELETE(javax.ws.rs.DELETE)

Aggregations

DELETE (javax.ws.rs.DELETE)587 Path (javax.ws.rs.Path)539 Produces (javax.ws.rs.Produces)194 ApiOperation (io.swagger.annotations.ApiOperation)153 ApiResponses (io.swagger.annotations.ApiResponses)127 Consumes (javax.ws.rs.Consumes)78 Timed (com.codahale.metrics.annotation.Timed)59 Response (javax.ws.rs.core.Response)54 IOException (java.io.IOException)47 WebApplicationException (javax.ws.rs.WebApplicationException)46 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)42 Identity (org.olat.core.id.Identity)36 AuditEvent (org.graylog2.audit.jersey.AuditEvent)32 NotFoundException (javax.ws.rs.NotFoundException)23 POST (javax.ws.rs.POST)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)20 ApiResponse (io.swagger.annotations.ApiResponse)20 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)20 HashMap (java.util.HashMap)19 GET (javax.ws.rs.GET)19