Class HttpRdfService


  • @Component
    public class HttpRdfService
    extends Object
    A service that will translate the resourceURI to Fedora ID in the Rdf InputStream
    Since:
    2019-11-07
    Author:
    bseeger, bbpennel
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpRdfService()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.fcrepo.kernel.api.RdfStream bodyToExternalStream​(String extResourceId, org.fcrepo.kernel.api.RdfStream stream, org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter idTranslator)
      Convert internal IDs to external URIs
      org.apache.jena.rdf.model.Model bodyToInternalModel​(org.fcrepo.kernel.api.identifiers.FedoraId extResourceId, InputStream stream, javax.ws.rs.core.MediaType contentType, org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter idTranslator, boolean lenientHandling)
      Parse the request body to a Model, with the URI to Fedora ID translations done.
      protected static org.apache.jena.rdf.model.Model parseBodyAsModel​(InputStream requestBodyStream, javax.ws.rs.core.MediaType contentType, String extResourceId)
      Parse the request body as a Model.
      String patchRequestToInternalString​(org.fcrepo.kernel.api.identifiers.FedoraId resourceId, String requestBody, org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter idTranslator)
      Takes a PATCH request body and translates any subjects and objects that are in the domain of the repository to use internal IDs.
    • Method Detail

      • bodyToExternalStream

        public org.fcrepo.kernel.api.RdfStream bodyToExternalStream​(String extResourceId,
                                                                    org.fcrepo.kernel.api.RdfStream stream,
                                                                    org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter idTranslator)
        Convert internal IDs to external URIs
        Parameters:
        extResourceId - The external URI of the resource.
        stream - The RDF stream to be translated.
        idTranslator - The identifier converter.
        Returns:
        a converted RDF Stream.
      • bodyToInternalModel

        public org.apache.jena.rdf.model.Model bodyToInternalModel​(org.fcrepo.kernel.api.identifiers.FedoraId extResourceId,
                                                                   InputStream stream,
                                                                   javax.ws.rs.core.MediaType contentType,
                                                                   org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter idTranslator,
                                                                   boolean lenientHandling)
                                                            throws org.fcrepo.kernel.api.exception.RepositoryRuntimeException,
                                                                   javax.ws.rs.BadRequestException
        Parse the request body to a Model, with the URI to Fedora ID translations done.
        Parameters:
        extResourceId - the external ID of the Fedora resource
        stream - the input stream containing the RDF
        contentType - the media type of the RDF
        idTranslator - the identifier convert
        lenientHandling - whether the request included a handling=lenient prefer header.
        Returns:
        RdfStream containing triples from request body, with Fedora IDs in them
        Throws:
        org.fcrepo.kernel.api.exception.MalformedRdfException - in case rdf json cannot be parsed
        javax.ws.rs.BadRequestException - in the case where the RDF syntax is bad
        org.fcrepo.kernel.api.exception.RepositoryRuntimeException
      • patchRequestToInternalString

        public String patchRequestToInternalString​(org.fcrepo.kernel.api.identifiers.FedoraId resourceId,
                                                   String requestBody,
                                                   org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter idTranslator)
        Takes a PATCH request body and translates any subjects and objects that are in the domain of the repository to use internal IDs.
        Parameters:
        resourceId - the internal ID of the current resource.
        requestBody - the request body.
        idTranslator - an ID converter for the current context.
        Returns:
        the converted PATCH request.
      • parseBodyAsModel

        protected static org.apache.jena.rdf.model.Model parseBodyAsModel​(InputStream requestBodyStream,
                                                                          javax.ws.rs.core.MediaType contentType,
                                                                          String extResourceId)
                                                                   throws javax.ws.rs.BadRequestException,
                                                                          org.fcrepo.kernel.api.exception.RepositoryRuntimeException
        Parse the request body as a Model.
        Parameters:
        requestBodyStream - rdf request body
        contentType - content type of body
        extResourceId - the external ID of the Fedora resource
        Returns:
        Model containing triples from request body
        Throws:
        org.fcrepo.kernel.api.exception.MalformedRdfException - in case rdf json cannot be parsed
        javax.ws.rs.BadRequestException - in the case where the RDF syntax is bad
        org.fcrepo.kernel.api.exception.RepositoryRuntimeException