Class FedoraId


  • public class FedoraId
    extends Object
    Class to store contextual information about a Fedora ID. Differentiates between the original ID of the request and the actual resource we are operating on. Resource Id : the shortened ID of the base resource, mostly needed to access the correct persistence object. fullId : the full ID from the request, used in most cases. So a fullId of info:fedora/object1/another/fcr:versions/20000101121212 has an id of info:fedora/object1/another
    Since:
    6.0.0
    Author:
    whikloj
    • Method Detail

      • create

        public static FedoraId create​(String... additions)
        Static create method
        Parameters:
        additions - One or more strings to build an ID.
        Returns:
        The FedoraId.
      • getRepositoryRootId

        public static FedoraId getRepositoryRootId()
        Get a FedoraId for repository root.
        Returns:
        The FedoraId for repository root.
      • isRepositoryRoot

        public boolean isRepositoryRoot()
        Is the identifier for the repository root.
        Returns:
        true of id is equal to info:fedora/
      • isMemento

        public boolean isMemento()
        Is the identifier for a Memento?
        Returns:
        true if the id is for the fcr:versions endpoint and has a memento datetime string after it.
      • isAcl

        public boolean isAcl()
        Is the identifier for an ACL?
        Returns:
        true if the id is for the fcr:acl endpoint.
      • isTimemap

        public boolean isTimemap()
        Is the identifier for a timemap?
        Returns:
        true if id for the fcr:versions endpoint and NOT a memento.
      • isDescription

        public boolean isDescription()
        Is the identifier for a nonRdfSourceDescription?
        Returns:
        true if id for the fcr:metadata endpoint
      • isTombstone

        public boolean isTombstone()
        Is the identifier for a tombstone
        Returns:
        true if id for the fcr:tombstone endpoint
      • isHashUri

        public boolean isHashUri()
        Is the identifier for a hash uri?
        Returns:
        true if full id referenced a hash uri.
      • getHashUri

        public String getHashUri()
        Get the hash uri.
        Returns:
        the hash uri from the id or null if none.
      • getResourceId

        public String getResourceId()
        Returns the ID string for the physical resource the Fedora ID describes. In most cases, this ID is the same as the full resource ID. However, if the resource is a memento, timemap, or tombstone, then the ID returned here will be for the resource that contains it. Here are some examples:
        • "info:fedora/object1/another/fcr:versions/20000101121212" => "info:fedora/object1/another"
        • "info:fedora/object1/another/fcr:metadata" => "info:fedora/object1/another/fcr:metadata"
        • "info:fedora/object1/another" => "info:fedora/object1/another"
        Returns:
        the ID of the associated physical resource
      • asResourceId

        public FedoraId asResourceId()
        Behaves the same as getResourceId() except it returns a FedoraId rather than a String.
        Returns:
        the ID of the associated physical resource
      • getBaseId

        public String getBaseId()
        Returns the ID string for the base ID the Fedora ID describes. This value is the equivalent of the full ID with all extensions removed.
        • "info:fedora/object1/another/fcr:versions/20000101121212" => "info:fedora/object1/another"
        • "info:fedora/object1/another/fcr:metadata" => "info:fedora/object1/another"
        • "info:fedora/object1/another" => "info:fedora/object1/another"
        Returns:
        the ID of the associated base resource
      • asBaseId

        public FedoraId asBaseId()
        Behaves the same as getBaseId() except it returns a FedoraId rather than a String.
        Returns:
        the ID of the associated base resource
      • getFullId

        public String getFullId()
        Return the original full ID.
        Returns:
        the id.
      • getFullIdPath

        public String getFullIdPath()
        Return the original full ID without the info:fedora prefix.
        Returns:
        the full id path part
      • getMementoInstant

        public Instant getMementoInstant()
        Return the Memento datetime as Instant.
        Returns:
        The datetime or null if not a memento.
      • getMementoString

        public String getMementoString()
        Return the Memento datetime string.
        Returns:
        The yyyymmddhhiiss memento datetime or null if not a Memento.
      • resolve

        public FedoraId resolve​(String child)
        Creates a new Fedora ID by joining the base ID of this Fedora ID with the specified string part. Any extensions that this Fedora ID contains are discarded. For example:

        Resolving "child" against "info:fedora/object1/another/fcr:versions/20000101121212" yields "info:fedora/object1/another/child".

        Parameters:
        child - the part to join
        Returns:
        new Fedora ID in the form baseId/child
      • asAcl

        public FedoraId asAcl()
        Creates a new Fedora ID based on this ID that points to an ACL resource. The base ID, full ID without extensions, is always used to construct an ACL ID. If this ID is already an ACL, then it returns itself.
        Returns:
        ACL resource ID
      • asDescription

        public FedoraId asDescription()
        Creates a new Fedora ID based on this ID that points to a binary description resource. There is no guarantee that the binary description resource exists. If this ID is already a description, then it returns itself. Otherwise, it uses the base ID, without extensions, to construct the new ID. If this Fedora ID is a timemap or memento or a hash uri, then these extensions are applied to new description ID as well.
        Returns:
        description resource ID
      • asTombstone

        public FedoraId asTombstone()
        Creates a new Fedora ID based on this ID that points to a tombstone resource. If this ID is already a tombstone, then it returns itself. Otherwise, it uses the base ID, without extensions, to construct the new ID.
        Returns:
        tombstone resource ID
      • asTimemap

        public FedoraId asTimemap()
        Creates a new Fedora ID based on this ID that points to a timemap resource. If this ID is already a timemap, then it returns itself. Otherwise, it uses the base ID, without extensions, to construct the new ID. Unless this ID is a binary description, in which case the new ID is constructed using the full ID.
        Returns:
        timemap resource ID
      • asMemento

        public FedoraId asMemento​(Instant mementoInstant)
        Creates a new Fedora ID based on this ID that points to a memento resource. If this ID is already a memento, then it returns itself. If this ID is an ACL, tombstone, or timemap, then the new ID is constructed using this ID's base ID. Otherwise, the full ID is used.
        Parameters:
        mementoInstant - memento representation
        Returns:
        memento resource ID
      • asMemento

        public FedoraId asMemento​(String mementoString)
        Creates a new Fedora ID based on this ID that points to a memento resource. If this ID is already a memento, then it returns itself. If this ID is an ACL, tombstone, or timemap, then the new ID is constructed using this ID's base ID. If this ID is a description, then the new ID is appended to the description ID.
        Parameters:
        mementoString - string memento representation
        Returns:
        memento resource ID