Package org.dspace.rdf
Class RDFUtil
java.lang.Object
org.dspace.rdf.RDFUtil
- Author:
- Pascal-Nicolas Becker (dspace -at- pascal -hyphen- becker -dot- de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringProperty key to load the URL of the dspace-rdf module.static final StringKey of the Property to load the types of DSpaceObjects that should get converted.static final StringProperty key to load the public address of the SPARQL endpoint.static final StringProperty key to load the address of the SPARQL 1.1 GRAPH STORE HTTP PROTOCOL endpoint.static final StringProperty key to load the username if authentication for the graph store endpoint is required.static final StringProperty key to load the password if authentication for the graph store endpoint is required.static final StringProperty key to load the address of the SPARQL endpoint to use within DSpace.static final StringProperty key to load the username if authentication for the internal SPARQL endpoint is required.static final StringProperty key to load the password if authentication for the internal SPARQL endpoint is required. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.jena.rdf.model.Modelconvert(Context context, DSpaceObject dso) Converts the the provided DSpaceObject into RDF and returns the model.static org.apache.jena.rdf.model.ModelconvertAndStore(Context context, DSpaceObject dso) Converts a DSpaceObject into RDF data and stores them using the configuredRDFStorage.static voidDeletes the data identified by the URI from the triple store.static voidThis is a shortcut to generate an RDF identifier for a DSpaceObject and to delete the identified data from the named graph.static StringGenerates a URI identifying the provided DSpaceObject.static StringgenerateIdentifier(Context context, DSpaceObject dso) Generates a URI identifying the provided DSpaceObject.static voidisPublic(Context context, DSpaceObject dso) Checks whether the provided DSpaceObject is readable within the provided context and if the DSO is an Item whether it is archived, discoverable and not withdrawn.static booleanisPublicBoolean(Context context, DSpaceObject dso) Does the same asisPublic(Context, DSpaceObject)but returns a boolean instead of throwing exceptions.static org.apache.jena.rdf.model.ModelLoads converted data of a DSpaceObject identified by the URI provided asidentifier.
-
Field Details
-
CONTENT_NEGOTIATION_KEY
- See Also:
-
CONVERTER_DSOTYPES_KEY
Key of the Property to load the types of DSpaceObjects that should get converted.- See Also:
-
STORAGE_GRAPHSTORE_PASSWORD_KEY
Property key to load the password if authentication for the graph store endpoint is required.- See Also:
-
CONTEXT_PATH_KEY
Property key to load the URL of the dspace-rdf module. This is necessary to create links from the UI to RDF representation of DSpaceObjects.- See Also:
-
SPARQL_ENDPOINT_KEY
Property key to load the public address of the SPARQL endpoint.- See Also:
-
STORAGE_SPARQL_LOGIN_KEY
Property key to load the username if authentication for the internal SPARQL endpoint is required.- See Also:
-
STORAGE_SPARQL_PASSWORD_KEY
Property key to load the password if authentication for the internal SPARQL endpoint is required.- See Also:
-
STORAGE_GRAPHSTORE_ENDPOINT_KEY
Property key to load the address of the SPARQL 1.1 GRAPH STORE HTTP PROTOCOL endpoint.- See Also:
-
STORAGE_SPARQL_ENDPOINT_KEY
Property key to load the address of the SPARQL endpoint to use within DSpace. If the property is empty or does not exist, the public SPARQL endpoint will be used.- See Also:
-
STORAGE_GRAPHSTORE_LOGIN_KEY
Property key to load the username if authentication for the graph store endpoint is required.- See Also:
-
-
Method Details
-
loadModel
Loads converted data of a DSpaceObject identified by the URI provided asidentifier. This method uses the RDFStorage configured in the DSpace configuration. Close the model (Model.close()) as soon as possible to free system resources.- Parameters:
identifier- A URI representing the object you want to load data about.- Returns:
- A model containing the RDF data to the specified identifier or null if no data could be found.
-
generateIdentifier
Generates a URI identifying the provided DSpaceObject. This method automatically loads and instantiates the URIGenerator configured in DSpace configuration. Please note that URIs can be generated for DSpaceObjects of the type SITE, COMMUNITY, COLLECTION or ITEM only. Currently dspace-rdf doesn't support Bundles or Bitstreams as independent entity.- Parameters:
context- DSpace Context.dso- DSpace Object you want to get an identifier for.- Returns:
- URI to identify the DSO or null if no URI could be generated. This can happen f.e. if you use a URIGenerator that uses persistent identifier like DOIs or Handles but there is no such identifier assigned to the provided DSO.
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
generateIdentifier
public static String generateIdentifier(Context context, int type, UUID id, String handle, List<String> identifier) throws SQLException Generates a URI identifying the provided DSpaceObject. This method automatically loads and instantiates the URIGenerator configured in DSpace configuration. Please note that URIs can be generated for DSpaceObjects of the type SITE, COMMUNITY, COLLECTION or ITEM only. Currently dspace-rdf doesn't support Bundles or Bitstreams as independent entity.- Parameters:
context- DSpace Context.type- Type of the DSpaceObject you want to generate a URI for (e.g.Constants.ITEM.id- UUID of the DSpaceObject you want to generate a URI for.handle- Handle of the DSpaceObject you want to generate a URI for.identifier- identifiers of the object.- Returns:
- URI to identify the DSO or null if no URI could be generated. This can happen f.e. if you use a URIGenerator that uses persistent identifier like DOIs or Handles but there is no such identifier assigned to the provided DSO.
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
convert
public static org.apache.jena.rdf.model.Model convert(Context context, DSpaceObject dso) throws org.dspace.rdf.RDFMissingIdentifierException, SQLException, ItemNotArchivedException, ItemWithdrawnException, ItemNotDiscoverableException, AuthorizeException, IllegalArgumentException Converts the the provided DSpaceObject into RDF and returns the model. Please note that dspace-rdf doesn't support Bundles or Bitstreams as independent entity. You can convert DSpaceObjects of type SITE, COMMUNITY, COLLECTION or ITEM.- Parameters:
context- Consider that the converted data will be stored in a triple store, that is outside the range of the DSpace authorization mechanism. Unless you are really sure what you are doing, you should provide the context of an anonymous user here, as the triple store probably provides a public SPARQL endpoint.dso- DSpaceObject to convert.- Returns:
- The converted data or null if the conversion result is empty. Remember to close the model as soon as you don't need it anymore.
- Throws:
org.dspace.rdf.RDFMissingIdentifierException- If no identifier could be generated.SQLException- if database errorItemNotArchivedException- If you want to convert an Item that is not archived.ItemWithdrawnException- If you want to convert an Item that is withdrawn.ItemNotDiscoverableException- If you want to convert an Item that is not discoverable.AuthorizeException- If the DSpaceObject does not have READ permissions with the provided context.IllegalArgumentException- If the DSpaceObject is not of type SITE, COMMUNITY, COLLECTION or ITEM.
-
convertAndStore
public static org.apache.jena.rdf.model.Model convertAndStore(Context context, DSpaceObject dso) throws org.dspace.rdf.RDFMissingIdentifierException, SQLException, ItemNotArchivedException, ItemWithdrawnException, ItemNotDiscoverableException, AuthorizeException, IllegalArgumentException Converts a DSpaceObject into RDF data and stores them using the configuredRDFStorage. Please note that dspace-rdf doesn't support Bundles or Bitstreams as independent entity. You can convert DSpaceObjects of type SITE, COMMUNITY, COLLECTION or ITEM.- Parameters:
context- Consider that the converted data will be stored in a triple store, that is outside the range of the DSpace authorization mechanism. Unless you are really sure what you are doing, you should provide the context of an anonymous user here, as the triple store probably provides a public SPARQL endpoint.dso- DSpaceObject to convert.- Returns:
- The converted data or null if the conversion result is empty. Remember to close the model as soon as you don't need it anymore.
- Throws:
org.dspace.rdf.RDFMissingIdentifierException- If no identifier could be generated.SQLException- if database errorItemNotArchivedException- If you want to convert an Item that is not archived.ItemWithdrawnException- If you want to convert an Item that is withdrawn.ItemNotDiscoverableException- If you want to convert an Item that is not discoverable.AuthorizeException- If the DSpaceObject does not have READ permissions with the provided context.IllegalArgumentException- If the DSpaceObject is not of type SITE, COMMUNITY, COLLECTION or ITEM.
-
isPublic
public static void isPublic(Context context, DSpaceObject dso) throws SQLException, ItemNotArchivedException, ItemWithdrawnException, ItemNotDiscoverableException, AuthorizeException Checks whether the provided DSpaceObject is readable within the provided context and if the DSO is an Item whether it is archived, discoverable and not withdrawn.- Parameters:
context- Consider that the converted data will be stored in a triple store, that is outside the range of the DSpace authorization mechanism. Unless you are really sure what you are doing, you should provide the context of an anonymous user here, as the triple store probably provides a public SPARQL endpoint.dso- The DSpaceObjet to check.- Throws:
SQLException- if database errorItemNotArchivedException- Ifdsois an Item and is not archived.ItemWithdrawnException- Ifdsois an Item and is withdrawn.ItemNotDiscoverableException- Ifdsois an Item and is not discoverable.AuthorizeException- Ifcontextdoes not grantREADpermissions fordso.
-
isPublicBoolean
Does the same asisPublic(Context, DSpaceObject)but returns a boolean instead of throwing exceptions. For those who don't want to deal with catching exceptions.- Parameters:
context- Consider that the converted data will be stored in a triple store, that is outside the range of the DSpace authorization mechanism. Unless you are really sure what you are doing, you should provide the context of an anonymous user here, as the triple store probably provides a public SPARQL endpoint.dso- The DSpaceObjet to check.- Returns:
- true if
isPublic(Context, DSpaceObject)doesn't throw an exception, false if it did. - Throws:
SQLException- if database error
-
delete
Deletes the data identified by the URI from the triple store.- Parameters:
uri- URI to identify the named graph to delete.
-
delete
public static void delete(Context ctx, int type, UUID id, String handle, List<String> identifiers) throws SQLException, org.dspace.rdf.RDFMissingIdentifierException This is a shortcut to generate an RDF identifier for a DSpaceObject and to delete the identified data from the named graph.- Parameters:
ctx- The relevant DSpace Context.type- DSpaceObject type (e.g.Constants.ITEM).id- Id of the DspaceObject.handle- Handle of the DSpaceObject.identifiers- list of identifiers- Throws:
SQLException- if database errororg.dspace.rdf.RDFMissingIdentifierException- In case that no Identifier could be generated.
-