Class HandleServiceImpl

  • All Implemented Interfaces:
    HandleService

    public class HandleServiceImpl
    extends Object
    implements 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 Detail

      • handleDAO

        @Autowired(required=true)
        protected HandleDAO handleDAO
      • configurationService

        @Autowired(required=true)
        protected ConfigurationService configurationService
      • siteService

        @Autowired
        protected SiteService siteService
    • Constructor Detail

      • HandleServiceImpl

        protected HandleServiceImpl()
        Public Constructor
    • Method Detail

      • resolveToURL

        public String resolveToURL​(Context context,
                                   String handle)
                            throws SQLException
        Description copied from interface: HandleService
        Return 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:
        resolveToURL in interface HandleService
        Parameters:
        context - DSpace context
        handle - The handle
        Returns:
        The local URL
        Throws:
        SQLException - If a database error occurs
      • resolveUrlToHandle

        public String resolveUrlToHandle​(Context context,
                                         String url)
                                  throws SQLException
        Description copied from interface: HandleService
        Try to detect a handle in a URL.
        Specified by:
        resolveUrlToHandle in interface HandleService
        Parameters:
        context - DSpace context
        url - 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

        public String getCanonicalPrefix()
        Description copied from interface: HandleService
        Provides 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:
        getCanonicalPrefix in interface HandleService
        Returns:
        The canonical form
      • getCanonicalForm

        public String getCanonicalForm​(String handle)
        Description copied from interface: HandleService
        Transforms 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:
        getCanonicalForm in interface HandleService
        Parameters:
        handle - The handle
        Returns:
        The canonical form
      • createHandle

        public String createHandle​(Context context,
                                   DSpaceObject dso,
                                   String suppliedHandle,
                                   boolean force)
                            throws SQLException,
                                   IllegalStateException
        Description copied from interface: HandleService
        Creates a handle entry, but with a handle supplied by the caller (new Handle not generated)
        Specified by:
        createHandle in interface HandleService
        Parameters:
        context - DSpace context
        dso - DSpaceObject
        suppliedHandle - existing handle value
        force - 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

        public void unbindHandle​(Context context,
                                 DSpaceObject dso)
                          throws SQLException
        Description copied from interface: HandleService
        Removes 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:
        unbindHandle in interface HandleService
        Parameters:
        context - DSpace context
        dso - DSpaceObject whose Handle to unbind.
        Throws:
        SQLException - An exception that provides information on a database access error or other errors.
      • findHandle

        public String findHandle​(Context context,
                                 DSpaceObject dso)
                          throws SQLException
        Description copied from interface: HandleService
        Return the handle for an Object, or null if the Object has no handle.
        Specified by:
        findHandle in interface HandleService
        Parameters:
        context - DSpace context
        dso - 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

        public List<String> getHandlesForPrefix​(Context context,
                                                String prefix)
                                         throws SQLException
        Description copied from interface: HandleService
        Return all the handles which start with prefix.
        Specified by:
        getHandlesForPrefix in interface HandleService
        Parameters:
        context - DSpace context
        prefix - 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

        public String getPrefix()
        Description copied from interface: HandleService
        Get the configured Handle prefix string, or a default
        Specified by:
        getPrefix in interface HandleService
        Returns:
        configured prefix or "123456789"
      • findHandleInternal

        protected Handle findHandleInternal​(Context context,
                                            String handle)
                                     throws SQLException
        Find the database row corresponding to handle.
        Parameters:
        context - DSpace context
        handle - The handle to resolve
        Returns:
        The database row corresponding to the handle
        Throws:
        SQLException - If a database error occurs
      • createId

        protected String createId​(Context context)
                           throws SQLException
        Create/mint a new handle id.
        Parameters:
        context - DSpace Context
        Returns:
        A new handle id
        Throws:
        SQLException - If a database error occurs
      • parseHandle

        public String parseHandle​(String identifier)
        Description copied from interface: HandleService
        Format a handle ~ - hdl:123456789/1 -> 123456789/1 - info:hdl/123456789/1 -> 123456789/1 - https://hdl.handle.net/123456789/1 -> 123456789/1
        Specified by:
        parseHandle in interface HandleService
        Returns:
      • getAdditionalPrefixes

        public String[] getAdditionalPrefixes()
        Description copied from interface: HandleService
        Gets the additional prefixes used for handles, mapped in configuration file.
        Specified by:
        getAdditionalPrefixes in interface HandleService
        Returns:
        `String[]` array of prefixes