public ResponseBuilder deleteResource(final Resource res) {
        final String baseUrl = getBaseUrl();
        final String identifier = baseUrl + req.getPartition() + req.getPath();

        final Session session = ofNullable(req.getSession()).orElseGet(HttpSession::new);

        // Check if this is already deleted
        checkDeleted(res, identifier);

        // Check the cache
        final EntityTag etag = new EntityTag(md5Hex(res.getModified() + identifier));
        checkCache(req.getRequest(), res.getModified(), etag);

        LOGGER.debug("Deleting {}", identifier);

        try (final TrellisDataset dataset = TrellisDataset.createDataset()) {

            // Add the audit quads
            audit.ifPresent(svc -> svc.deletion(res.getIdentifier(), session).stream()
                    .map(skolemizeQuads(resourceService, baseUrl)).forEachOrdered(dataset::add));

            // When deleting just the ACL graph, keep the user managed triples in tact
            if (ACL.equals(req.getExt())) {
                try (final Stream<? extends Triple> triples = res.stream(PreferUserManaged)) {
                    triples.map(t -> rdf.createQuad(PreferUserManaged, t.getSubject(), t.getPredicate(), t.getObject()))
                        .forEachOrdered(dataset::add);
                }
            }

            // delete the resource
            if (resourceService.put(res.getIdentifier(), dataset.asDataset())) {
                return status(NO_CONTENT);
            }
        }

        LOGGER.error("Unable to delete resource at {}", res.getIdentifier());
        return serverError().entity("Unable to delete resource. Please consult the logs for more information");
    }
public ResponseBuilder deleteResource ( final Resource res ) { final String baseUrl = getBaseUrl ( ) ; final String identifier = baseUrl + req . getPartition ( ) + req . getPath ( ) ; final Session session = ofNullable ( req . getSession ( ) ) . orElseGet ( HttpSession :: new ) ; checkDeleted ( res , identifier ) ; final EntityTag etag = new EntityTag ( md5Hex ( res . getModified ( ) + identifier ) ) ; checkCache ( req . getRequest ( ) , res . getModified ( ) , etag ) ; LOGGER . debug ( "Deleting {}" , identifier ) ; try ( final TrellisDataset dataset = TrellisDataset . createDataset ( ) ) { audit . ifPresent ( svc -> svc . deletion ( res . getIdentifier ( ) , session ) . stream ( ) . map ( skolemizeQuads ( resourceService , baseUrl ) ) . forEachOrdered ( dataset :: add ) ) ; if ( ACL . equals ( req . getExt ( ) ) ) { try ( final Stream < ? extends Triple > triples = res . stream ( PreferUserManaged ) ) { triples . map ( t -> rdf . createQuad ( PreferUserManaged , t . getSubject ( ) , t . getPredicate ( ) , t . getObject ( ) ) ) . forEachOrdered ( dataset :: add ) ; } } if ( resourceService . put ( res . getIdentifier ( ) , dataset . asDataset ( ) ) ) { return status ( NO_CONTENT ) ; } } LOGGER . error ( "Unable to delete resource at {}" , res . getIdentifier ( ) ) ; return serverError ( ) . entity ( "Unable to delete resource. Please consult the logs for more information" ) ; }
Delete the given resource
@param res the resource
@return a response builder