Package org.fcrepo.http.commons.api.rdf
Class HttpIdentifierConverter
- java.lang.Object
-
- org.fcrepo.http.commons.api.rdf.HttpIdentifierConverter
-
public class HttpIdentifierConverter extends Object
Convert between HTTP URIs (LDP paths) and internal Fedora ID using a JAX-RS UriBuilder to mediate the URI translation.- Since:
- 2019-09-26
- Author:
- whikloj
-
-
Constructor Summary
Constructors Constructor Description HttpIdentifierConverter(javax.ws.rs.core.UriBuilder uriBuilder)
Create a new identifier converter with the given URI template.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
inExternalDomain(String httpUri)
Test if the provided external URI is in the domain of this repository.boolean
inInternalDomain(String fedoraId)
Check if the provided internal identifier is in the domain of the repository.FedoraId
pathToInternalId(String externalPath)
Function to convert from the external path of a URI to an internal FedoraId.String
toDomain(String path)
Convert a path to a full url using the UriBuilder template.String
toExternalId(String fedoraId)
Convert an internal identifier to an external URI.String
toInternalId(String httpUri)
Convert an external URI to an internal ID.String
toInternalId(String httpUri, boolean encoded)
Convert an external URI to an internal ID.String
translateUri(String httpUri)
Make a URI into an absolute URI (if relative), an internal encoded ID (if in repository domain) or leave it alone.
-
-
-
Constructor Detail
-
HttpIdentifierConverter
public HttpIdentifierConverter(javax.ws.rs.core.UriBuilder uriBuilder)
Create a new identifier converter with the given URI template.- Parameters:
uriBuilder
- the uri builder
-
-
Method Detail
-
toInternalId
public String toInternalId(String httpUri)
Convert an external URI to an internal ID.- Parameters:
httpUri
- the external URI.- Returns:
- the internal identifier.
-
toInternalId
public String toInternalId(String httpUri, boolean encoded)
Convert an external URI to an internal ID.- Parameters:
httpUri
- the external URI.encoded
- whether the internal ID is encoded or not.- Returns:
- the internal identifier.
-
inExternalDomain
public boolean inExternalDomain(String httpUri)
Test if the provided external URI is in the domain of this repository. If it is not in the domain we can't convert it.- Parameters:
httpUri
- the external URI.- Returns:
- true if it is in domain.
-
translateUri
public String translateUri(String httpUri)
Make a URI into an absolute URI (if relative), an internal encoded ID (if in repository domain) or leave it alone.- Parameters:
httpUri
- the URI- Returns:
- an absolute URI, the original URI or an internal ID.
-
toExternalId
public String toExternalId(String fedoraId)
Convert an internal identifier to an external URI.- Parameters:
fedoraId
- the internal identifier.- Returns:
- the external URI.
-
inInternalDomain
public boolean inInternalDomain(String fedoraId)
Check if the provided internal identifier is in the domain of the repository. If it is not in the domain we can't convert it.- Parameters:
fedoraId
- the internal identifier.- Returns:
- true if it is in domain.
-
toDomain
public String toDomain(String path)
Convert a path to a full url using the UriBuilder template.- Parameters:
path
- the external path.- Returns:
- the full url.
-
pathToInternalId
public FedoraId pathToInternalId(String externalPath)
Function to convert from the external path of a URI to an internal FedoraId.- Parameters:
externalPath
- the path part of the external URI.- Returns:
- the FedoraId.
-
-