edu.ucsb.nceas.metacat.dataone

## Class D1NodeService

- java.lang.Object
- - edu.ucsb.nceas.metacat.dataone.D1NodeService

- Direct Known Subclasses:
    CNodeService, MNodeService

      public abstract class D1NodeService
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DELETEDMESSAGE`
    `protected static MetacatHandler` | `handler`
    `protected java.lang.String` | `ipAddress`
    `protected static int` | `MAXIMUM_DB_RECORD_COUNT` limit paged results sets to a configured maximum
    `static java.lang.String` | `METADATA`
    `protected javax.servlet.http.HttpServletRequest` | `request` For logging the operations
    `protected org.dataone.service.types.v1.Session` | `session2` out-of-band session object to be used when not passed in as a method parameter
    `protected java.lang.String` | `userAgent`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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)` 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 needModifyDate)` Archives an object, where the object is either a data object or a science metadata object.
    `protected boolean` | `checkSidInModifyingSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta, java.lang.String invalidSystemMetadataCode, java.lang.String serviceFailureCode)`
    `void` | `checkV1SystemMetaPidExist(org.dataone.service.types.v1.Identifier identifier, java.lang.String serviceFailureCode, java.lang.String serviceFailureMessage, java.lang.String noFoundCode, java.lang.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, java.io.InputStream object, org.dataone.service.types.v2.SystemMetadata sysmeta)` 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(java.lang.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 java.lang.String` | `existsInObsoletedBy(org.dataone.service.types.v1.Identifier id)`
    `protected java.lang.String` | `existsInObsoletes(org.dataone.service.types.v1.Identifier id)`
    `protected static java.util.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.
    `java.io.InputStream` | `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` | `getCNNodeList()` 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
    `java.lang.String` | `getIpAddress()` Get the ip address from the service
    `org.dataone.service.types.v2.Log` | `getLogRecords(org.dataone.service.types.v1.Session session, java.util.Date fromDate, java.util.Date toDate, java.lang.String event, java.lang.String pidFilter, java.lang.Integer start, java.lang.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, java.lang.String serviceFailureCode)` Utility method to get the PID for an SID.
    `org.dataone.service.types.v1.Session` | `getSession()` 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, java.lang.String serviceFailureCode, java.lang.String invalidRequestCode, java.lang.String notFoundCode, boolean needDeleteInfo)` Get the system metadata for the given PID (not a sid).
    `java.lang.String` | `getUserAgent()` Get the user agent from the service
    `protected java.lang.String` | `insertDataObject(java.io.InputStream object, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Checksum checksum)` Insert a data object into Metacat
    `protected java.lang.String` | `insertDataObject(java.io.InputStream object, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Checksum checksum, EventLogData event)` Insert a data object into Metacat
    `static java.lang.String` | `insertObject(java.io.InputStream object, java.lang.String docType, org.dataone.service.types.v1.Identifier pid, java.lang.String fileDirectory, org.dataone.service.types.v1.Session session, org.dataone.service.types.v1.Checksum checksum, EventLogData event)` Insert an object into the given directory
    `java.lang.String` | `insertOrUpdateDocument(java.io.InputStream xmlStream, java.lang.String encoding, org.dataone.service.types.v1.Identifier pid, org.dataone.service.types.v1.Session session, java.lang.String insertOrUpdate, java.lang.String formatId, org.dataone.service.types.v1.Checksum checksum)` Insert or update an XML document into Metacat
    `void` | `insertSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta)` Insert a systemMetadata document and return its localId
    `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.
    `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 java.util.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, java.util.Date startTime, java.util.Date endTime, org.dataone.service.types.v1.ObjectFormatIdentifier objectFormatId, org.dataone.service.types.v1.Identifier identifier, org.dataone.service.types.v1.NodeReference nodeId, java.lang.Integer start, java.lang.Integer count)` Retrieve the list of objects present on the MN that match the calling parameters
    `org.dataone.service.types.v2.OptionList` | `listViews()`
    `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.
    `java.util.Date` | `ping()` Low level, "are you alive" operation.
    `protected static void` | `removeIdFromIdentifierTable(org.dataone.service.types.v1.Identifier id)`
    `protected void` | `removeSolrIndex(org.dataone.service.types.v2.SystemMetadata sysMeta)`
    `protected void` | `removeSystemMetaAndIdentifier(org.dataone.service.types.v1.Identifier id)`
    `void` | `setIpAddress(java.lang.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(java.lang.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)` Update the system metadata of the specified pid.
    `protected void` | `updateSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysMeta)` Update a systemMetadata document
    `java.io.InputStream` | `view(org.dataone.service.types.v1.Session session, java.lang.String format, org.dataone.service.types.v1.Identifier id)`
    `static java.io.File` | `writeStreamToFile(java.io.File dir, java.lang.String localId, java.io.InputStream dataStream, org.dataone.service.types.v1.Checksum checksum, org.dataone.service.types.v1.Identifier pid)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DELETEDMESSAGE

          public static final java.lang.String DELETEDMESSAGE

      See Also:
        Constant Field Values

    - #### METADATA

          public static final java.lang.String METADATA

      See Also:
        Constant Field Values

    - #### request

          protected javax.servlet.http.HttpServletRequest request

      For logging the operations

    - #### ipAddress

          protected java.lang.String ipAddress

    - #### userAgent

          protected java.lang.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 Detail

    - #### 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 Detail

    - #### 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(java.lang.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 java.util.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,
                                                                java.io.InputStream object,
                                                                org.dataone.service.types.v2.SystemMetadata sysmeta)
                                                         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)

    - #### removeIdFromIdentifierTable

          protected static void removeIdFromIdentifierTable(org.dataone.service.types.v1.Identifier id)

    - #### getLogRecords

          public org.dataone.service.types.v2.Log getLogRecords(org.dataone.service.types.v1.Session session,
                                                                java.util.Date fromDate,
                                                                java.util.Date toDate,
                                                                java.lang.String event,
                                                                java.lang.String pidFilter,
                                                                java.lang.Integer start,
                                                                java.lang.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 java.io.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:

    - #### insertOrUpdateDocument

          public java.lang.String insertOrUpdateDocument(java.io.InputStream xmlStream,
                                                         java.lang.String encoding,
                                                         org.dataone.service.types.v1.Identifier pid,
                                                         org.dataone.service.types.v1.Session session,
                                                         java.lang.String insertOrUpdate,
                                                         java.lang.String formatId,
                                                         org.dataone.service.types.v1.Checksum checksum)
                                                  throws org.dataone.service.exceptions.ServiceFailure,
                                                         java.io.IOException,
                                                         edu.ucsb.nceas.utilities.PropertyNotFoundException,
                                                         org.dataone.service.exceptions.InvalidSystemMetadata

      Insert or update an XML document into Metacat
      Parameters:
        `xml` - - the XML document to insert or update
        `pid` - - the identifier to be used for the resulting object
      Returns:
        localId - the resulting docid of the document created or updated
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `java.io.IOException`
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`
        `org.dataone.service.exceptions.InvalidSystemMetadata`

    - #### insertDataObject

          protected java.lang.String insertDataObject(java.io.InputStream object,
                                                      org.dataone.service.types.v1.Identifier pid,
                                                      org.dataone.service.types.v1.Session session,
                                                      org.dataone.service.types.v1.Checksum checksum)
                                               throws org.dataone.service.exceptions.ServiceFailure,
                                                      org.dataone.service.exceptions.InvalidSystemMetadata,
                                                      org.dataone.service.exceptions.NotAuthorized

      Insert a data object into Metacat
      Parameters:
        `object` - the input stream of the object will be inserted
        `pid` - the pid associated with the object
        `session` - the actor of this action
        `checksum` - the expected checksum for this data object
      Returns:
        the local id of the inserted object
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidSystemMetadata`
        `org.dataone.service.exceptions.NotAuthorized`

    - #### insertDataObject

          protected java.lang.String insertDataObject(java.io.InputStream object,
                                                      org.dataone.service.types.v1.Identifier pid,
                                                      org.dataone.service.types.v1.Session session,
                                                      org.dataone.service.types.v1.Checksum checksum,
                                                      EventLogData event)
                                               throws org.dataone.service.exceptions.ServiceFailure,
                                                      org.dataone.service.exceptions.InvalidSystemMetadata,
                                                      org.dataone.service.exceptions.NotAuthorized

      Insert a data object into Metacat
      Parameters:
        `object` - the input stream of the object will be inserted
        `pid` - the pid associated with the object
        `session` - the actor of this action
        `checksum` - the expected checksum for this data object
        `event` - the event log information associated with this action
      Returns:
        the local id of the inserted object
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidSystemMetadata`
        `org.dataone.service.exceptions.NotAuthorized`

    - #### insertObject

          public static java.lang.String insertObject(java.io.InputStream object,
                                                      java.lang.String docType,
                                                      org.dataone.service.types.v1.Identifier pid,
                                                      java.lang.String fileDirectory,
                                                      org.dataone.service.types.v1.Session session,
                                                      org.dataone.service.types.v1.Checksum checksum,
                                                      EventLogData event)
                                               throws org.dataone.service.exceptions.ServiceFailure,
                                                      org.dataone.service.exceptions.InvalidSystemMetadata,
                                                      org.dataone.service.exceptions.NotAuthorized

      Insert an object into the given directory
      Parameters:
        `object` - the input stream of the object will be inserted
        `docType` - the doc type in the xml_document table
        `pid` - the pid associated with the object
        `fileDirectory` - the directory where the object will be inserted
        `session` - the actor of this action
        `checksum` - the expected checksum for this data object
        `event` - the event log information associated with this action
      Returns:
        the local id of the inserted object
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidSystemMetadata`
        `org.dataone.service.exceptions.NotAuthorized`

    - #### insertSystemMetadata

          public void insertSystemMetadata(org.dataone.service.types.v2.SystemMetadata sysmeta)
                                    throws org.dataone.service.exceptions.ServiceFailure

      Insert a systemMetadata document and return its localId
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`

    - #### listObjects

          public org.dataone.service.types.v1.ObjectList listObjects(org.dataone.service.types.v1.Session session,
                                                                     java.util.Date startTime,
                                                                     java.util.Date endTime,
                                                                     org.dataone.service.types.v1.ObjectFormatIdentifier objectFormatId,
                                                                     org.dataone.service.types.v1.Identifier identifier,
                                                                     org.dataone.service.types.v1.NodeReference nodeId,
                                                                     java.lang.Integer start,
                                                                     java.lang.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)
                                       throws org.dataone.service.exceptions.ServiceFailure

      Update a systemMetadata document
      Parameters:
        `sysMeta` - - the system metadata object in the system to update
      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)
                                          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. The caller of this method should lock the system metadata in hazelcast server.
      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
      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 java.util.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

    - #### writeStreamToFile

          public static java.io.File writeStreamToFile(java.io.File dir,
                                                       java.lang.String localId,
                                                       java.io.InputStream dataStream,
                                                       org.dataone.service.types.v1.Checksum checksum,
                                                       org.dataone.service.types.v1.Identifier pid)
                                                throws org.dataone.service.exceptions.ServiceFailure,
                                                       org.dataone.service.exceptions.InvalidSystemMetadata

      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidSystemMetadata`

    - #### listNodesBySubject

          protected java.util.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 needModifyDate)
                                                                   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

      Archives an object, where the object is either a data object or a science metadata object. Note: it doesn't check the authorization; it doesn't lock the system metadata;it only accept pid.
      Parameters:
        `session` - - the Session object containing the credentials for the Subject
        `pid` - - The object identifier to be archived
      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`
        `org.dataone.service.exceptions.InvalidRequest`

    - #### 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)
                                  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:
        `session` -
        `pid` -
        `sysMeta` -
        `notifyReplica` -
      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,
                                                java.lang.String serviceFailureCode,
                                                java.lang.String serviceFailureMessage,
                                                java.lang.String noFoundCode,
                                                java.lang.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,
                                                                         java.lang.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`
      See Also:
        `as well for situations where you need the SystemMetadata. The advantage of this method is that it doesn't unmarshall systemmetadata, and doesn't throw NotFound exceptions.`

    - #### getSystemMetadataForPID

          protected org.dataone.service.types.v2.SystemMetadata getSystemMetadataForPID(org.dataone.service.types.v1.Identifier pid,
                                                                                        java.lang.String serviceFailureCode,
                                                                                        java.lang.String invalidRequestCode,
                                                                                        java.lang.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,
                                                              java.lang.String invalidSystemMetadataCode,
                                                              java.lang.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 java.io.InputStream view(org.dataone.service.types.v1.Session session,
                                          java.lang.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 java.lang.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 java.lang.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 java.lang.String getIpAddress()

      Get the ip address from the service
      Returns:
        the ip address

    - #### setIpAddress

          public void setIpAddress(java.lang.String ipAddress)

      Set the ip address for the service
      Parameters:
        `ipAddress` - the address will be set

    - #### getUserAgent

          public java.lang.String getUserAgent()

      Get the user agent from the service
      Returns:

    - #### setUserAgent

          public void setUserAgent(java.lang.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

Copyright © 2023 Regents of the University of California. All Rights Reserved.