use of org.trellisldp.vocabulary.AS in project trellis by trellis-ldp.
the class TrellisWebDAV method copyResource.
/**
* Copy a resource.
* @return the async response
*/
@COPY
@Timed
public CompletionStage<Response> copyResource() {
final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, security);
final Session session = HttpSession.from(security);
final IRI destination = getDestination(headers, getBaseUrl(req));
final IRI identifier = rdf.createIRI(TRELLIS_DATA_PREFIX + req.getPath());
// Default is recursive copy as per RFC-4918
final Depth.DEPTH depth = getDepth(headers.getHeaderString("Depth"));
return getParent(destination).thenCombine(services.getResourceService().get(destination), this::checkResources).thenCompose(parent -> services.getResourceService().touch(parent.getIdentifier())).thenCompose(future -> services.getResourceService().get(identifier)).thenApply(this::checkResource).thenCompose(res -> copyTo(res, session, depth, destination, getBaseUrl(req))).thenApply(future -> status(NO_CONTENT).build()).exceptionally(this::handleException);
}
use of org.trellisldp.vocabulary.AS in project trellis by trellis-ldp.
the class PutHandler method setResource.
/**
* Store the resource to the persistence layer.
* @param builder the response builder
* @return the response builder
*/
public CompletionStage<ResponseBuilder> setResource(final ResponseBuilder builder) {
LOGGER.debug("Setting resource as {}", getIdentifier());
final IRI ldpType = getLdpType();
// Verify that the persistence layer supports the given interaction model
if (!supportsInteractionModel(ldpType)) {
throw new BadRequestException("Unsupported interaction model provided", status(BAD_REQUEST).link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()).build());
}
// It is not possible to change the LDP type to a type that is not a subclass
if (hasInteractionModelChangeRestriction(ldpType)) {
LOGGER.error("Cannot change the LDP type to {} for {}", ldpType, getIdentifier());
throw new ClientErrorException("Cannot change the LDP type to " + ldpType, status(CONFLICT).build());
}
LOGGER.debug("Using LDP Type: {}", ldpType);
final Dataset mutable = rdf.createDataset();
final Dataset immutable = rdf.createDataset();
LOGGER.trace("Persisting {} with mutable data:\n{}\n and immutable data:\n{}", getIdentifier(), mutable, immutable);
return handleResourceUpdate(mutable, immutable, builder, ldpType).whenComplete((a, b) -> closeDataset(mutable)).whenComplete((a, b) -> closeDataset(immutable));
}
use of org.trellisldp.vocabulary.AS in project trellis by trellis-ldp.
the class PostHandler method createResource.
/**
* Create a new resource.
* @param builder the response builder
* @return the response builder
*/
public CompletionStage<ResponseBuilder> createResource(final ResponseBuilder builder) {
LOGGER.debug("Creating resource as {}", getIdentifier());
final Dataset mutable = rdf.createDataset();
final Dataset immutable = rdf.createDataset();
return handleResourceCreation(mutable, immutable, builder).whenComplete((a, b) -> closeDataset(mutable)).whenComplete((a, b) -> closeDataset(immutable));
}
Aggregations