Class D1NodeService

java.lang.Object
edu.ucsb.nceas.metacat.dataone.D1NodeService
Direct Known Subclasses:
CNodeService, MNodeService

public abstract class D1NodeService extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    protected static MetacatHandler
     
    protected String
     
    protected static int
    limit paged results sets to a configured maximum
    static final String
     
    protected javax.servlet.http.HttpServletRequest
    For logging the operations
    protected org.dataone.service.types.v1.Session
    out-of-band session object to be used when not passed in as a method parameter
    protected String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    D1NodeService(javax.servlet.http.HttpServletRequest request)
    Constructor - used to set the metacatUrl from a subclass extending D1NodeService
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    archiveCNObject(boolean log, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v2.SystemMetadata sysMeta, boolean needModifyDate, SystemMetadataManager.SysMetaVersion sysMetaCheck)
    Archive a object on cn and notify the replica.
    protected org.dataone.service.types.v1.Identifier
    archiveObject(boolean log, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v2.SystemMetadata sysMeta, boolean changeDateModified, SystemMetadataManager.SysMetaVersion sysMetaCheck)
    Archive an object, which is either a data object or a science metadata object.
    protected boolean
    checkSidInModifyingSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta, String invalidSystemMetadataCode, String serviceFailureCode)
     
    void
    checkV1SystemMetaPidExist(org.dataone.service.types.v1.Identifier identifier, String serviceFailureCode, String serviceFailureMessage, String noFoundCode, String notFoundMessage)
    A utility method for v1 api to check the specified identifier exists as a pid Uses the IdentifierManager to call the Identifier table directly - this detects Identifiers for deleted objects (where the SystemMetadata doesn't exist, but the Identifier remains)
    org.dataone.service.types.v1.Identifier
    create(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, InputStream object, org.dataone.service.types.v2.SystemMetadata sysmeta, boolean changeModificationDate)
    Adds a new object to the Node, where the object is either a data object or a science metadata object.
    org.dataone.service.types.v1.Identifier
    delete(String username, org.dataone.service.types.v1.Identifier pid)
    Deletes an object from the Member Node, where the object is either a data object or a science metadata object.
    org.dataone.service.types.v1.DescribeResponse
    describe(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier id)
    This method provides a lighter weight mechanism than getSystemMetadata() for a client to determine basic properties of the referenced object.
    static boolean
    equals(org.dataone.service.types.v1.AccessPolicy ap1, org.dataone.service.types.v1.AccessPolicy ap2)
    Compare two AccessPolicy objects
    protected String
    existsInObsoletedBy(org.dataone.service.types.v1.Identifier id)
     
    protected String
    existsInObsoletes(org.dataone.service.types.v1.Identifier id)
     
    protected static List<org.dataone.service.types.v1.Permission>
    expandPermissions(org.dataone.service.types.v1.Permission permission)
    Given a Permission, returns a list of all permissions that it encompasses Permissions are hierarchical so that WRITE also allows READ.
    get(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid)
    Return the object identified by the given object identifier
    protected org.dataone.service.types.v2.NodeList
    A centralized point for accessing the CN Nodelist, to make it easier to cache the nodelist in the future, if it's seen as helpful performance-wise
    Get the ip address from the service
    org.dataone.service.types.v2.Log
    getLogRecords(org.dataone.service.types.v1.Session session, Date fromDate, Date toDate, String event, String pidFilter, Integer start, Integer count)
    Return the log records associated with a given event between the start and end dates listed given a particular Subject listed in the Session
    protected org.dataone.service.types.v1.Identifier
    getPIDForSID(org.dataone.service.types.v1.Identifier sid, String serviceFailureCode)
    Utility method to get the PID for an SID.
    org.dataone.service.types.v1.Session
    retrieve the out-of-band session
    org.dataone.service.types.v2.SystemMetadata
    getSystemMetadata(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier id)
    Return the system metadata for a given object
    protected org.dataone.service.types.v2.SystemMetadata
    getSystemMetadataForPID(org.dataone.service.types.v1.Identifier pid, String serviceFailureCode, String invalidRequestCode, String notFoundCode, boolean needDeleteInfo)
    Get the system metadata for the given PID (not a sid).
    Get the user agent from the service
    static boolean
    isAccessControlDirty(org.dataone.service.types.v2.SystemMetadata originalSysmeta, org.dataone.service.types.v2.SystemMetadata newSysmeta)
    Check if the access control was modified between two system metadata objects.
    boolean
    isAuthorized(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier id, org.dataone.service.types.v1.Permission permission)
    Test if the user identified by the provided token has authorization for the operation on the specified object.
    protected void
    isInAllowList(org.dataone.service.types.v1.Session session)
    Check if the session is in the allow list which can upload objects to this Metacat instance.
    static boolean
    isScienceMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta)
    Determine if a given object should be treated as an XML science metadata object.
    static boolean
    isValidIdentifier(org.dataone.service.types.v1.Identifier pid)
    Check for whitespace in the given pid.
    protected List<org.dataone.service.types.v2.Node>
    listNodesBySubject(org.dataone.service.types.v1.Subject subject, org.dataone.service.types.v2.NodeList nodelist)
    Calls CN.listNodes() to assemble a list of nodes that have been registered with the DataONE infrastructure that match the given session subject
    org.dataone.service.types.v1.ObjectList
    listObjects(org.dataone.service.types.v1.Session session, Date startTime, Date endTime, org.dataone.service.types.v1.ObjectFormatIdentifier objectFormatId, org.dataone.service.types.v1.Identifier identifier, org.dataone.service.types.v1.NodeReference nodeId, Integer start, Integer count)
    Retrieve the list of objects present on the MN that match the calling parameters
    org.dataone.service.types.v2.OptionList
     
    org.dataone.service.types.v2.OptionList
    listViews(org.dataone.service.types.v1.Session arg0)
     
    protected static void
    objectExists(org.dataone.service.types.v1.Identifier id)
    Determine if an object with the given identifier already exists or not.
    Low level, "are you alive" operation.
    protected void
    removeSolrIndex(org.dataone.service.types.v2.SystemMetadata sysMeta)
     
    protected void
    removeSystemMetaAndIdentifier(org.dataone.service.types.v1.Identifier id)
     
    void
    setIpAddress(String ipAddress)
    Set the ip address for the service
    void
    setSession(org.dataone.service.types.v1.Session session)
    Set the out-of-band session
    void
    setUserAgent(String userAgent)
    Set the user agent for the service
    protected boolean
    updateSystemMetadata(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v2.SystemMetadata sysmeta, boolean needUpdateModificationDate, org.dataone.service.types.v2.SystemMetadata currentSysmeta, boolean fromCN, SystemMetadataManager.SysMetaVersion sysMetaCheck)
    Update the system metadata of the specified pid.
    protected void
    updateSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta, boolean needUpdateModificationDate, SystemMetadataManager.SysMetaVersion sysMetaCheck)
    Update system metadata.
    view(org.dataone.service.types.v1.Session session, String format, org.dataone.service.types.v1.Identifier id)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DELETEDMESSAGE

      public static final String DELETEDMESSAGE
      See Also:
    • METADATA

      public static final String METADATA
      See Also:
    • request

      protected javax.servlet.http.HttpServletRequest request
      For logging the operations
    • ipAddress

      protected String ipAddress
    • userAgent

      protected String userAgent
    • handler

      protected static MetacatHandler handler
    • MAXIMUM_DB_RECORD_COUNT

      protected static int MAXIMUM_DB_RECORD_COUNT
      limit paged results sets to a configured maximum
    • session2

      protected org.dataone.service.types.v1.Session session2
      out-of-band session object to be used when not passed in as a method parameter
  • Constructor Details

    • D1NodeService

      public D1NodeService(javax.servlet.http.HttpServletRequest request)
      Constructor - used to set the metacatUrl from a subclass extending D1NodeService
      Parameters:
      metacatUrl - - the URL of the metacat service, including the ending /d1
  • Method Details

    • getSession

      public org.dataone.service.types.v1.Session getSession()
      retrieve the out-of-band session
      Returns:
    • setSession

      public void setSession(org.dataone.service.types.v1.Session session)
      Set the out-of-band session
      Parameters:
      session -
    • getCNNodeList

      protected org.dataone.service.types.v2.NodeList getCNNodeList() throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotImplemented
      A centralized point for accessing the CN Nodelist, to make it easier to cache the nodelist in the future, if it's seen as helpful performance-wise
      Returns:
      Throws:
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotImplemented
    • describe

      public org.dataone.service.types.v1.DescribeResponse describe(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier id) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotImplemented
      This method provides a lighter weight mechanism than getSystemMetadata() for a client to determine basic properties of the referenced object.
      Parameters:
      session - - the Session object containing the credentials for the Subject
      pid - - the identifier of the object to be described
      Returns:
      describeResponse - A set of values providing a basic description of the object.
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.InvalidRequest
    • delete

      public org.dataone.service.types.v1.Identifier delete(String username, org.dataone.service.types.v1.Identifier pid) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotImplemented
      Deletes an object from the Member Node, where the object is either a data object or a science metadata object. No access checking.
      Parameters:
      username - - the name of the user who calls the method. This is only for logging.
      pid - - The object identifier to be deleted
      Returns:
      pid - the identifier of the object used for the deletion
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.InvalidRequest
    • ping

      public Date ping() throws org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InsufficientResources
      Low level, "are you alive" operation. A valid ping response is indicated by a HTTP status of 200.
      Returns:
      true if the service is alive
      Throws:
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.InsufficientResources
    • create

      public org.dataone.service.types.v1.Identifier create(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, InputStream object, org.dataone.service.types.v2.SystemMetadata sysmeta, boolean changeModificationDate) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.IdentifierNotUnique, org.dataone.service.exceptions.UnsupportedType, org.dataone.service.exceptions.InsufficientResources, org.dataone.service.exceptions.InvalidSystemMetadata, org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.InvalidRequest
      Adds a new object to the Node, where the object is either a data object or a science metadata object. This method is called by clients to create new data objects on Member Nodes or internally for Coordinating Nodes
      Parameters:
      session - - the Session object containing the credentials for the Subject
      pid - - The object identifier to be created
      object - - the object bytes
      sysmeta - - the system metadata that describes the object
      Returns:
      pid - the object identifier created
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.IdentifierNotUnique
      org.dataone.service.exceptions.UnsupportedType
      org.dataone.service.exceptions.InsufficientResources
      org.dataone.service.exceptions.InvalidSystemMetadata
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.InvalidRequest
    • objectExists

      protected static void objectExists(org.dataone.service.types.v1.Identifier id) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.IdentifierNotUnique
      Determine if an object with the given identifier already exists or not. (Using IdentityManager. Works for SID or PID)
      Parameters:
      id - - the ID to be checked.
      Throws:
      org.dataone.service.exceptions.ServiceFailure - if the system can't fulfill the check process
      org.dataone.service.exceptions.IdentifierNotUnique - if the object with the identifier does exist
    • removeSystemMetaAndIdentifier

      protected void removeSystemMetaAndIdentifier(org.dataone.service.types.v1.Identifier id)
    • removeSolrIndex

      protected void removeSolrIndex(org.dataone.service.types.v2.SystemMetadata sysMeta)
    • getLogRecords

      public org.dataone.service.types.v2.Log getLogRecords(org.dataone.service.types.v1.Session session, Date fromDate, Date toDate, String event, String pidFilter, Integer start, Integer count) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.NotImplemented
      Return the log records associated with a given event between the start and end dates listed given a particular Subject listed in the Session
      Parameters:
      session - - the Session object containing the credentials for the Subject
      fromDate - - the start date of the desired log records
      toDate - - the end date of the desired log records
      event - - restrict log records of a specific event type
      start - - zero based offset from the first record in the set of matching log records. Used to assist with paging the response.
      count - - maximum number of log records to return in the response. Used to assist with paging the response.
      Returns:
      the desired log records
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
    • get

      public InputStream get(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotImplemented
      Return the object identified by the given object identifier
      Parameters:
      session - - the Session object containing the credentials for the Subject
      id - - the identifier for the given object TODO: The D1 Authorization API doesn't provide information on which authentication system the Subject belongs to, and so it's not possible to discern which Person or Group is a valid KNB LDAP DN. Fix this.
      Returns:
      inputStream - the input stream of the given object
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.NotFound
    • getSystemMetadata

      public org.dataone.service.types.v2.SystemMetadata getSystemMetadata(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier id) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotImplemented
      Return the system metadata for a given object
      Parameters:
      session - - the Session object containing the credentials for the Subject
      pid - - the object identifier for the given object
      Returns:
      inputStream - the input stream of the given system metadata object
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
    • isAuthorized

      public boolean isAuthorized(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier id, org.dataone.service.types.v1.Permission permission) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.InvalidRequest
      Test if the user identified by the provided token has authorization for the operation on the specified object. Allowed subjects include: 1. CNs 2. Authoritative node 3. Owner of the object 4. Users with the specified permission in the access rules.
      Parameters:
      session - - the Session object containing the credentials for the Subject
      pid - - The identifer of the resource for which access is being checked
      operation - - The type of operation which is being requested for the given pid
      Returns:
      true if the operation is allowed
      Throws:
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.InvalidRequest
    • isScienceMetadata

      public static boolean isScienceMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta)
      Determine if a given object should be treated as an XML science metadata object.
      Parameters:
      sysmeta - - the SystemMetadata describing the object
      Returns:
      true if the object should be treated as science metadata
    • isValidIdentifier

      public static boolean isValidIdentifier(org.dataone.service.types.v1.Identifier pid)
      Check for whitespace in the given pid. null pids are also invalid by default
      Parameters:
      pid -
      Returns:
    • isInAllowList

      protected void isInAllowList(org.dataone.service.types.v1.Session session) throws org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.ServiceFailure
      Check if the session is in the allow list which can upload objects to this Metacat instance.
      Parameters:
      session - the identity of the user
      Throws:
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.ServiceFailure
    • listObjects

      public org.dataone.service.types.v1.ObjectList listObjects(org.dataone.service.types.v1.Session session, Date startTime, Date endTime, org.dataone.service.types.v1.ObjectFormatIdentifier objectFormatId, org.dataone.service.types.v1.Identifier identifier, org.dataone.service.types.v1.NodeReference nodeId, Integer start, Integer count) throws org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InvalidToken
      Retrieve the list of objects present on the MN that match the calling parameters
      Parameters:
      session - - the Session object containing the credentials for the Subject
      startTime - - Specifies the beginning of the time range from which to return object (>=)
      endTime - - Specifies the beginning of the time range from which to return object (>=)
      objectFormat - - Restrict results to the specified object format
      replicaStatus - - Indicates if replicated objects should be returned in the list
      start - - The zero-based index of the first value, relative to the first record of the resultset that matches the parameters.
      count - - The maximum number of entries that should be returned in the response. The Member Node may return less entries than specified in this value.
      Returns:
      objectList - the list of objects matching the criteria
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
    • updateSystemMetadata

      protected void updateSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta, boolean needUpdateModificationDate, SystemMetadataManager.SysMetaVersion sysMetaCheck) throws org.dataone.service.exceptions.ServiceFailure
      Update system metadata. And the index task is submitted as well. This method only apply to the cases involving the only change of the system metadata.
      Parameters:
      sysMeta - the new system metadata
      needUpdateModificationDate - if Metacat need to change the modification date
      sysMetaCheck - - check whether the version of the provided '@param sysMeta' matches the version of the existing system metadata
      Throws:
      org.dataone.service.exceptions.ServiceFailure
    • updateSystemMetadata

      protected boolean updateSystemMetadata(org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v2.SystemMetadata sysmeta, boolean needUpdateModificationDate, org.dataone.service.types.v2.SystemMetadata currentSysmeta, boolean fromCN, SystemMetadataManager.SysMetaVersion sysMetaCheck) throws org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.InvalidSystemMetadata, org.dataone.service.exceptions.InvalidToken
      Update the system metadata of the specified pid.
      Parameters:
      session - - the identity of the client which calls the method
      pid - - the identifier of the object which will be updated
      sysmeta - - the new system metadata
      needUpdateModificationDate - - if Metacat needs to change dateSysMetadataModified
      currentSysmeta - - the current system metadata in Metcat
      fromCN - - if the call from a CN method
      sysMetaCheck - - sysMetaCheck - check whether the version of the provided '@param sysmeta' matches the version of the existing system metadata
      Returns:
      Throws:
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.InvalidSystemMetadata
      org.dataone.service.exceptions.InvalidToken
    • expandPermissions

      protected static List<org.dataone.service.types.v1.Permission> expandPermissions(org.dataone.service.types.v1.Permission permission)
      Given a Permission, returns a list of all permissions that it encompasses Permissions are hierarchical so that WRITE also allows READ.
      Parameters:
      permission -
      Returns:
      list of included Permissions for the given permission
    • listNodesBySubject

      protected List<org.dataone.service.types.v2.Node> listNodesBySubject(org.dataone.service.types.v1.Subject subject, org.dataone.service.types.v2.NodeList nodelist) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotImplemented
      Calls CN.listNodes() to assemble a list of nodes that have been registered with the DataONE infrastructure that match the given session subject
      Parameters:
      subject - - the subject serving as the filter.
      Returns:
      nodes - List of nodes from the registry with a matching session subject
      Throws:
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotImplemented
    • archiveObject

      protected org.dataone.service.types.v1.Identifier archiveObject(boolean log, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v2.SystemMetadata sysMeta, boolean changeDateModified, SystemMetadataManager.SysMetaVersion sysMetaCheck) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotImplemented
      Archive an object, which is either a data object or a science metadata object. Note: it doesn't check the authorization; it only accepts a pid.
      Parameters:
      log - indicator if we want to log the event
      session - - the Session object containing the credentials for the Subject
      pid - - The object identifier to be archived
      sysMeta - - the system metadata associated with the pid
      changeDateModified - - if we need to modify the dateModified field in the system metadata
      sysMetaCheck - sysMetaCheck - check whether the version of the provided '@param sysMeta' matches the version of the existing system metadata
      Returns:
      pid - the identifier of the object used for the archiving
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.NotImplemented
    • archiveCNObject

      protected void archiveCNObject(boolean log, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v2.SystemMetadata sysMeta, boolean needModifyDate, SystemMetadataManager.SysMetaVersion sysMetaCheck) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.NotFound, org.dataone.service.exceptions.NotImplemented
      Archive a object on cn and notify the replica. This method doesn't lock the system metadata map. The caller should lock it. This method doesn't check the authorization; this method only accept a pid. It wouldn't notify the replca that the system metadata has been changed.
      Parameters:
      log - if we need to log the event into db
      session - the session who made the request
      pid - the pid of the object which needs to be archived
      sysMeta - the system metadata associated with the pid
      sysMetaCheck - sysMetaCheck - check whether the version of the provided '@param sysMeta' matches the version of the existing system metadata
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.NotImplemented
    • checkV1SystemMetaPidExist

      public void checkV1SystemMetaPidExist(org.dataone.service.types.v1.Identifier identifier, String serviceFailureCode, String serviceFailureMessage, String noFoundCode, String notFoundMessage) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotFound
      A utility method for v1 api to check the specified identifier exists as a pid Uses the IdentifierManager to call the Identifier table directly - this detects Identifiers for deleted objects (where the SystemMetadata doesn't exist, but the Identifier remains)
      Parameters:
      identifier - the specified identifier
      serviceFailureCode - the detail error code for the service failure exception
      noFoundCode - the detail error code for the not found exception
      Throws:
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotFound
    • getPIDForSID

      protected org.dataone.service.types.v1.Identifier getPIDForSID(org.dataone.service.types.v1.Identifier sid, String serviceFailureCode) throws org.dataone.service.exceptions.ServiceFailure
      Utility method to get the PID for an SID. If the specified identifier is not an SID , null will be returned.
      Parameters:
      sid - the specified sid
      serviceFailureCode - the detail error code for the service failure exception
      Returns:
      the pid for the sid. If the specified identifier is not an SID, null will be returned.
      Throws:
      org.dataone.service.exceptions.ServiceFailure
    • getSystemMetadataForPID

      protected org.dataone.service.types.v2.SystemMetadata getSystemMetadataForPID(org.dataone.service.types.v1.Identifier pid, String serviceFailureCode, String invalidRequestCode, String notFoundCode, boolean needDeleteInfo) throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.NotFound
      Get the system metadata for the given PID (not a sid).
      Parameters:
      pid -
      serviceFailureCode -
      invalidRequestCode -
      Returns:
      the system metadata associated with the pid
      Throws:
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotFound
      org.dataone.service.exceptions.InvalidRequest
    • checkSidInModifyingSystemMetadata

      protected boolean checkSidInModifyingSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta, String invalidSystemMetadataCode, String serviceFailureCode) throws org.dataone.service.exceptions.InvalidSystemMetadata, org.dataone.service.exceptions.ServiceFailure
      Throws:
      org.dataone.service.exceptions.InvalidSystemMetadata
      org.dataone.service.exceptions.ServiceFailure
    • listViews

      public org.dataone.service.types.v2.OptionList listViews(org.dataone.service.types.v1.Session arg0) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.NotImplemented
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
    • listViews

      public org.dataone.service.types.v2.OptionList listViews() throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.NotImplemented
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
    • view

      public InputStream view(org.dataone.service.types.v1.Session session, String format, org.dataone.service.types.v1.Identifier id) throws org.dataone.service.exceptions.InvalidToken, org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.NotAuthorized, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.NotImplemented, org.dataone.service.exceptions.NotFound
      Throws:
      org.dataone.service.exceptions.InvalidToken
      org.dataone.service.exceptions.ServiceFailure
      org.dataone.service.exceptions.NotAuthorized
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.NotImplemented
      org.dataone.service.exceptions.NotFound
    • existsInObsoletes

      protected String existsInObsoletes(org.dataone.service.types.v1.Identifier id) throws org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure
      Throws:
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.ServiceFailure
    • existsInObsoletedBy

      protected String existsInObsoletedBy(org.dataone.service.types.v1.Identifier id) throws org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure
      Throws:
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.ServiceFailure
    • getIpAddress

      public String getIpAddress()
      Get the ip address from the service
      Returns:
      the ip address
    • setIpAddress

      public void setIpAddress(String ipAddress)
      Set the ip address for the service
      Parameters:
      ipAddress - the address will be set
    • getUserAgent

      public String getUserAgent()
      Get the user agent from the service
      Returns:
    • setUserAgent

      public void setUserAgent(String userAgent)
      Set the user agent for the service
      Parameters:
      userAgent - the user agent will be set
    • isAccessControlDirty

      public static boolean isAccessControlDirty(org.dataone.service.types.v2.SystemMetadata originalSysmeta, org.dataone.service.types.v2.SystemMetadata newSysmeta)
      Check if the access control was modified between two system metadata objects. It compares two parts: RightsHolder and AccessPolicy
      Parameters:
      originalSysmeta - the original system metadata object
      newSysmeta - the new system metadata object
      Returns:
      true if the access control was modified; false otherwise.
    • equals

      public static boolean equals(org.dataone.service.types.v1.AccessPolicy ap1, org.dataone.service.types.v1.AccessPolicy ap2)
      Compare two AccessPolicy objects
      Parameters:
      ap1 -
      ap2 -
      Returns:
      true if they are same; false otherwise