Package org.dspace.handle
Class HandleServiceImpl
java.lang.Object
org.dspace.handle.HandleServiceImpl
- All Implemented Interfaces:
HandleService
Interface to the CNRI Handle
System.
Currently, this class simply maps handles to local facilities; handles which are owned by other sites (including other DSpaces) are treated as non-existent.
- Author:
- Peter Breton
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConfigurationServiceprotected HandleDAOprotected SiteService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcountHandlesByPrefix(Context context, String prefix) intcountTotal(Context context) createHandle(Context context, DSpaceObject dso) Creates a new handle in the database.createHandle(Context context, DSpaceObject dso, String suppliedHandle) Creates a handle entry, but with a handle supplied by the caller (new Handle not generated)createHandle(Context context, DSpaceObject dso, String suppliedHandle, boolean force) Creates a handle entry, but with a handle supplied by the caller (new Handle not generated)protected StringCreate/mint a new handle id.findHandle(Context context, DSpaceObject dso) Return the handle for an Object, or null if the Object has no handle.protected HandlefindHandleInternal(Context context, String handle) Find the database row corresponding to handle.String[]Gets the additional prefixes used for handles, mapped in configuration file.getCanonicalForm(String handle) Transforms handle into a URI using https://hdl.handle.net if not overridden by the configuration property handle.canonical.prefix.Provides handle canonical prefix using https://hdl.handle.net if not overridden by the configuration property handle.canonical.prefix.getHandlesForPrefix(Context context, String prefix) Return all the handles which start with prefix.Get the configured Handle prefix string, or a defaultvoidmodifyHandleDSpaceObject(Context context, String handle, DSpaceObject newOwner) parseHandle(String identifier) Format a handle ~ - hdl:123456789/1 -> 123456789/1 - info:hdl/123456789/1 -> 123456789/1 - https://hdl.handle.net/123456789/1 -> 123456789/1resolveToObject(Context context, String handle) Return the object which handle maps to, or null.resolveToURL(Context context, String handle) Return the local URL for handle, or null if handle cannot be found.resolveUrlToHandle(Context context, String url) Try to detect a handle in a URL.voidunbindHandle(Context context, DSpaceObject dso) Removes binding of Handle to a DSpace object, while leaving the Handle in the table so it doesn't get reallocated.intupdateHandlesWithNewPrefix(Context context, String newPrefix, String oldPrefix)
-
Field Details
-
handleDAO
-
configurationService
-
siteService
-
-
Constructor Details
-
HandleServiceImpl
protected HandleServiceImpl()Public Constructor
-
-
Method Details
-
resolveToURL
Description copied from interface:HandleServiceReturn the local URL for handle, or null if handle cannot be found. The returned URL is a (non-handle-based) location where a dissemination of the object referred to by handle can be obtained.- Specified by:
resolveToURLin interfaceHandleService- Parameters:
context- DSpace contexthandle- The handle- Returns:
- The local URL
- Throws:
SQLException- If a database error occurs
-
resolveUrlToHandle
Description copied from interface:HandleServiceTry to detect a handle in a URL.- Specified by:
resolveUrlToHandlein interfaceHandleService- Parameters:
context- DSpace contexturl- The URL- Returns:
- The handle or null if the handle couldn't be extracted of a URL or if the extracted handle couldn't be found.
- Throws:
SQLException- If a database error occurs
-
getCanonicalPrefix
Description copied from interface:HandleServiceProvides handle canonical prefix using https://hdl.handle.net if not overridden by the configuration property handle.canonical.prefix. No attempt is made to verify that handle is in fact valid.- Specified by:
getCanonicalPrefixin interfaceHandleService- Returns:
- The canonical form
-
getCanonicalForm
Description copied from interface:HandleServiceTransforms handle into a URI using https://hdl.handle.net if not overridden by the configuration property handle.canonical.prefix. No attempt is made to verify that handle is in fact valid.- Specified by:
getCanonicalFormin interfaceHandleService- Parameters:
handle- The handle- Returns:
- The canonical form
-
createHandle
Description copied from interface:HandleServiceCreates a new handle in the database.- Specified by:
createHandlein interfaceHandleService- Parameters:
context- DSpace contextdso- The DSpaceObject to create a handle for- Returns:
- The newly created handle
- Throws:
SQLException- If a database error occurs
-
createHandle
public String createHandle(Context context, DSpaceObject dso, String suppliedHandle) throws SQLException, IllegalStateException Description copied from interface:HandleServiceCreates a handle entry, but with a handle supplied by the caller (new Handle not generated)- Specified by:
createHandlein interfaceHandleService- Parameters:
context- DSpace contextdso- DSpaceObjectsuppliedHandle- existing handle value- Returns:
- the Handle
- Throws:
SQLException- An exception that provides information on a database access error or other errors.IllegalStateException- if specified handle is already in use by another object
-
createHandle
public String createHandle(Context context, DSpaceObject dso, String suppliedHandle, boolean force) throws SQLException, IllegalStateException Description copied from interface:HandleServiceCreates a handle entry, but with a handle supplied by the caller (new Handle not generated)- Specified by:
createHandlein interfaceHandleService- Parameters:
context- DSpace contextdso- DSpaceObjectsuppliedHandle- existing handle valueforce- FIXME: currently unused- Returns:
- the Handle
- Throws:
SQLException- An exception that provides information on a database access error or other errors.IllegalStateException- if specified handle is already in use by another object
-
unbindHandle
Description copied from interface:HandleServiceRemoves binding of Handle to a DSpace object, while leaving the Handle in the table so it doesn't get reallocated. The AIP implementation also needs it there for foreign key references.- Specified by:
unbindHandlein interfaceHandleService- Parameters:
context- DSpace contextdso- DSpaceObject whose Handle to unbind.- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
resolveToObject
public DSpaceObject resolveToObject(Context context, String handle) throws IllegalStateException, SQLException Description copied from interface:HandleServiceReturn the object which handle maps to, or null. This is the object itself, not a URL which points to it.- Specified by:
resolveToObjectin interfaceHandleService- Parameters:
context- DSpace contexthandle- The handle to resolve- Returns:
- The object which handle maps to, or null if handle is not mapped to any object.
- Throws:
IllegalStateException- If handle was found but is not bound to an objectSQLException- If a database error occurs
-
findHandle
Description copied from interface:HandleServiceReturn the handle for an Object, or null if the Object has no handle.- Specified by:
findHandlein interfaceHandleService- Parameters:
context- DSpace contextdso- The object to obtain a handle for- Returns:
- The handle for object, or null if the object has no handle.
- Throws:
SQLException- If a database error occurs
-
getHandlesForPrefix
Description copied from interface:HandleServiceReturn all the handles which start with prefix.- Specified by:
getHandlesForPrefixin interfaceHandleService- Parameters:
context- DSpace contextprefix- The handle prefix- Returns:
- A list of the handles starting with prefix. The list is guaranteed to be non-null. Each element of the list is a String.
- Throws:
SQLException- If a database error occurs
-
getPrefix
Description copied from interface:HandleServiceGet the configured Handle prefix string, or a default- Specified by:
getPrefixin interfaceHandleService- Returns:
- configured prefix or "123456789"
-
countHandlesByPrefix
- Specified by:
countHandlesByPrefixin interfaceHandleService- Throws:
SQLException
-
updateHandlesWithNewPrefix
public int updateHandlesWithNewPrefix(Context context, String newPrefix, String oldPrefix) throws SQLException - Specified by:
updateHandlesWithNewPrefixin interfaceHandleService- Throws:
SQLException
-
modifyHandleDSpaceObject
public void modifyHandleDSpaceObject(Context context, String handle, DSpaceObject newOwner) throws SQLException - Specified by:
modifyHandleDSpaceObjectin interfaceHandleService- Throws:
SQLException
-
findHandleInternal
Find the database row corresponding to handle.- Parameters:
context- DSpace contexthandle- The handle to resolve- Returns:
- The database row corresponding to the handle
- Throws:
SQLException- If a database error occurs
-
createId
Create/mint a new handle id.- Parameters:
context- DSpace Context- Returns:
- A new handle id
- Throws:
SQLException- If a database error occurs
-
countTotal
- Specified by:
countTotalin interfaceHandleService- Throws:
SQLException
-
parseHandle
Description copied from interface:HandleServiceFormat a handle ~ - hdl:123456789/1 -> 123456789/1 - info:hdl/123456789/1 -> 123456789/1 - https://hdl.handle.net/123456789/1 -> 123456789/1- Specified by:
parseHandlein interfaceHandleService- Returns:
-
getAdditionalPrefixes
Description copied from interface:HandleServiceGets the additional prefixes used for handles, mapped in configuration file.- Specified by:
getAdditionalPrefixesin interfaceHandleService- Returns:
- `String[]` array of prefixes
-