@ MOVE @ Timed public void moveResource ( @ Suspended final AsyncResponse response , @ Context final Request request , @ Context final UriInfo uriInfo , @ Context final HttpHeaders headers , @ Context final SecurityContext security ) { final TrellisRequest req = new TrellisRequest ( request , uriInfo , headers , security ) ; final String baseUrl = getBaseUrl ( req ) ; final IRI identifier = rdf . createIRI ( TRELLIS_DATA_PREFIX + req . getPath ( ) ) ; final IRI destination = getDestination ( headers , baseUrl ) ; final Session session = getSession ( req . getPrincipalName ( ) ) ; 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 ) // Note: all MOVE operations are recursive (Depth: infinity), hence recursiveCopy . thenAccept ( res -> recursiveCopy ( services , session , res , destination , baseUrl ) ) . thenAccept ( future -> recursiveDelete ( services , session , identifier , baseUrl ) ) . thenCompose ( future -> services . getResourceService ( ) . delete ( Metadata . builder ( identifier ) . interactionModel ( LDP . Resource ) . build ( ) ) ) . thenCompose ( future -> { final TrellisDataset immutable = TrellisDataset . createDataset ( ) ; services . getAuditService ( ) . creation ( identifier , session ) . stream ( ) . map ( skolemizeQuads ( services . getResourceService ( ) , baseUrl ) ) . forEachOrdered ( immutable :: add ) ; return services . getResourceService ( ) . add ( identifier , immutable . asDataset ( ) ) . whenComplete ( ( a , b ) -> immutable . close ( ) ) ; } ) . thenAccept ( future -> services . getEventService ( ) . emit ( new SimpleEvent ( externalUrl ( identifier , baseUrl ) , session . getAgent ( ) , asList ( PROV . Activity , AS . Delete ) , singletonList ( LDP . Resource ) ) ) ) . thenApply ( future -> status ( NO_CONTENT ) . build ( ) ) . exceptionally ( this :: handleException ) . thenApply ( response :: resume ) ; }
Move a resource .