Package org.fcrepo.http.api.services
Class HttpRdfService
- java.lang.Object
-
- org.fcrepo.http.api.services.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 RdfStream
bodyToExternalStream(String extResourceId, RdfStream stream, HttpIdentifierConverter idTranslator)
Convert internal IDs to external URIsorg.apache.jena.rdf.model.Model
bodyToInternalModel(FedoraId extResourceId, InputStream stream, javax.ws.rs.core.MediaType contentType, 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(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.
-
-
-
Constructor Detail
-
HttpRdfService
public HttpRdfService()
-
-
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 resourcestream
- the input stream containing the RDFcontentType
- the media type of the RDFidTranslator
- the identifier convertlenientHandling
- 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 parsedjavax.ws.rs.BadRequestException
- in the case where the RDF syntax is badRepositoryRuntimeException
-
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 bodycontentType
- content type of bodyextResourceId
- the external ID of the Fedora resource- Returns:
- Model containing triples from request body
- Throws:
MalformedRdfException
- in case rdf json cannot be parsedjavax.ws.rs.BadRequestException
- in the case where the RDF syntax is badRepositoryRuntimeException
-
-