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 ( getResource ( ) != null && ! isBinaryDescription ( ) && ldpResourceTypes ( ldpType ) . noneMatch ( getResource ( ) . getInteractionModel ( ) :: equals ) ) { 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 TrellisDataset mutable = TrellisDataset . createDataset ( ) ; final TrellisDataset immutable = TrellisDataset . createDataset ( ) ; LOGGER . debug ( "Persisting {} with mutable data:\n{}\n and immutable data:\n{}" , getIdentifier ( ) , mutable , immutable ) ; return handleResourceUpdate ( mutable , immutable , builder , ldpType ) . whenComplete ( ( a , b ) -> mutable . close ( ) ) . whenComplete ( ( a , b ) -> immutable . close ( ) ) ; }
Store the resource to the persistence layer .