Interface HandleService

  • All Known Implementing Classes:
    HandleServiceImpl

    public interface 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
    • Method Detail

      • resolveToURL

        String resolveToURL​(Context context,
                            String handle)
                     throws SQLException
        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.
        Parameters:
        context - DSpace context
        handle - The handle
        Returns:
        The local URL
        Throws:
        SQLException - If a database error occurs
      • resolveUrlToHandle

        String resolveUrlToHandle​(Context context,
                                  String url)
                           throws SQLException
        Try to detect a handle in a URL.
        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

        String getCanonicalPrefix()
        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.
        Returns:
        The canonical form
      • getCanonicalForm

        String getCanonicalForm​(String handle)
        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.
        Parameters:
        handle - The handle
        Returns:
        The canonical form
      • createHandle

        String createHandle​(Context context,
                            DSpaceObject dso)
                     throws SQLException
        Creates a new handle in the database.
        Parameters:
        context - DSpace context
        dso - The DSpaceObject to create a handle for
        Returns:
        The newly created handle
        Throws:
        SQLException - If a database error occurs
      • createHandle

        String createHandle​(Context context,
                            DSpaceObject dso,
                            String suppliedHandle)
                     throws SQLException,
                            IllegalStateException
        Creates a handle entry, but with a handle supplied by the caller (new Handle not generated)
        Parameters:
        context - DSpace context
        dso - DSpaceObject
        suppliedHandle - 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

        String createHandle​(Context context,
                            DSpaceObject dso,
                            String suppliedHandle,
                            boolean force)
                     throws SQLException,
                            IllegalStateException
        Creates a handle entry, but with a handle supplied by the caller (new Handle not generated)
        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

        void unbindHandle​(Context context,
                          DSpaceObject dso)
                   throws SQLException
        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.
        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.
      • resolveToObject

        DSpaceObject resolveToObject​(Context context,
                                     String handle)
                              throws IllegalStateException,
                                     SQLException
        Return the object which handle maps to, or null. This is the object itself, not a URL which points to it.
        Parameters:
        context - DSpace context
        handle - 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 object
        SQLException - If a database error occurs
      • findHandle

        String findHandle​(Context context,
                          DSpaceObject dso)
                   throws SQLException
        Return the handle for an Object, or null if the Object has no handle.
        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

        List<String> getHandlesForPrefix​(Context context,
                                         String prefix)
                                  throws SQLException
        Return all the handles which start with prefix.
        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

        String getPrefix()
        Get the configured Handle prefix string, or a default
        Returns:
        configured prefix or "123456789"
      • parseHandle

        String parseHandle​(String identifier)
        Format a handle ~ - hdl:123456789/1 -> 123456789/1 - info:hdl/123456789/1 -> 123456789/1 - https://hdl.handle.net/123456789/1 -> 123456789/1
        Parameters:
        identifier -
        Returns:
      • getAdditionalPrefixes

        String[] getAdditionalPrefixes()
        Gets the additional prefixes used for handles, mapped in configuration file.
        Returns:
        `String[]` array of prefixes