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
    • Method Detail

      • bodyToExternalStream

        public RdfStream bodyToExternalStream​(String extResourceId,
                                              RdfStream stream,
                                              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​(FedoraId extResourceId,
                                                                   InputStream stream,
                                                                   javax.ws.rs.core.MediaType contentType,
                                                                   HttpIdentifierConverter idTranslator,
                                                                   boolean lenientHandling)
                                                            throws 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:
        MalformedRdfException - in case rdf json cannot be parsed
        javax.ws.rs.BadRequestException - in the case where the RDF syntax is bad
        RepositoryRuntimeException
      • patchRequestToInternalString

        public String patchRequestToInternalString​(FedoraId resourceId,
                                                   String requestBody,
                                                   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,
                                                                          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:
        MalformedRdfException - in case rdf json cannot be parsed
        javax.ws.rs.BadRequestException - in the case where the RDF syntax is bad
        RepositoryRuntimeException