edu.ucsb.nceas.metacat.restservice.v1

## Class CNResourceHandler

- java.lang.Object
- - edu.ucsb.nceas.metacat.restservice.D1ResourceHandler
  - - edu.ucsb.nceas.metacat.restservice.v1.CNResourceHandler

-     public class CNResourceHandler
      extends D1ResourceHandler

  CN REST service implementation handler ****************** CNCore -- DONE create() - POST /d1/cn/object/PID listFormats() - GET /d1/cn/formats getFormat() - GET /d1/cn/formats/FMTID getLogRecords - GET /d1/cn/log reserveIdentifier() - POST /d1/cn/reserve listNodes() - Not implemented registerSystemMetadata() - POST /d1/meta/PID CNRead -- DONE get() - GET /d1/cn/object/PID getSystemMetadata() - GET /d1/cn/meta/PID resolve() - GET /d1/cn/resolve/PID assertRelation() - GET /d1/cn/assertRelation/PID getChecksum() - GET /d1/cn/checksum search() - Not implemented in Metacat CNAuthorization setOwner() - PUT /d1/cn/owner/PID isAuthorized() - GET /d1/cn/isAuthorized/PID setAccessPolicy() - POST /d1/cn/accessRules CNIdentity - not implemented at all on Metacat CNReplication setReplicationStatus() - PUT /replicaNotifications/PID updateReplicationMetadata() - PUT /replicaMetadata/PID setReplicationPolicy() - PUT /replicaPolicies/PID isNodeAuthorized() - GET /replicaAuthorizations/PID CNRegister -- not implemented at all in Metacat ******************
  Author:
    leinfelder

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `RESOURCE_FORMATS`
    `protected static java.lang.String` | `RESOURCE_OWNER`
    `protected static java.lang.String` | `RESOURCE_REPLICATION_AUTHORIZED`
    `protected static java.lang.String` | `RESOURCE_REPLICATION_META`
    `protected static java.lang.String` | `RESOURCE_REPLICATION_NOTIFY`
    `protected static java.lang.String` | `RESOURCE_REPLICATION_POLICY`
    `protected static java.lang.String` | `RESOURCE_RESERVE` CN-specific operations
    `protected static java.lang.String` | `RESOURCE_RESOLVE`

    - ### Fields inherited from class edu.ucsb.nceas.metacat.restservice.D1ResourceHandler

      `auth, authCacheSzie, DELETE, enableAppendLdapGroups, enableSessionFromHeader, FUNCTION_NAME_INSERT, FUNCTION_NAME_UPDATE, GET, HEAD, logMetacat, MAX_UPLOAD_SIZE, multipartparams, params, POST, proxyKey, PUT, request, RESOURCE_ACCESS_RULES, RESOURCE_BASE_URL, RESOURCE_IS_AUTHORIZED, RESOURCE_LOG, RESOURCE_META, RESOURCE_OBJECTS, RESOURCE_QUERY, RESOURCE_VIEWS, response, servletContext, session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CNResourceHandler(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `deleteReplica(java.lang.String pid)` Delete the replica entry with the given nodeId for the given pid
    `protected void` | `getObject(java.lang.String guid)` Implements REST version of DataONE CRUD API --> get
    `protected void` | `getSystemMetadataObject(java.lang.String guid)` Implements REST version of DataONE CRUD API --> getSystemMetadata
    `void` | `handle(byte httpVerb)` This function is called from REST API servlet and handles each request to the servlet
    `boolean` | `isNodeAuthorized(java.lang.String pid)` Pass the request to get node replication authorization to CNodeService
    `protected void` | `putObject(java.lang.String action)` Earthgrid API > Put Service >Put Function : calls MetacatHandler > handleInsertOrUpdateAction
    `protected void` | `registerSystemMetadata()` Register System Metadata without data or metadata object
    `protected void` | `setAccess(java.lang.String pid)` set the access perms on a document
    `boolean` | `setObsoletedBy(java.lang.String pid)` Update the system metadata for a given pid, setting it to be obsoleted by the obsoletedByPid
    `boolean` | `setReplicationPolicy(java.lang.String pid)` Pass the request to set the replication policy to CNodeService
    `boolean` | `setReplicationStatus(java.lang.String pid)` Pass the request to set the replication status to CNodeService
    `boolean` | `updateReplicationMetadata(java.lang.String pid)` Pass the request to update the replication metadata to CNodeService

    - ### Methods inherited from class edu.ucsb.nceas.metacat.restservice.D1ResourceHandler

      `collectMultipartFiles, collectMultipartParams, collectObjectFiles, decode, findBoundaryString, getSessionFromHeader, getTempDirectory, initMultipartParams, initParams, isD1Enabled, parseTrailing, printError, serializeException`

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

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

- - ### Field Detail

    - #### RESOURCE_RESERVE

          protected static final java.lang.String RESOURCE_RESERVE

      CN-specific operations
      See Also:
        Constant Field Values

    - #### RESOURCE_FORMATS

          protected static final java.lang.String RESOURCE_FORMATS

      See Also:
        Constant Field Values

    - #### RESOURCE_RESOLVE

          protected static final java.lang.String RESOURCE_RESOLVE

      See Also:
        Constant Field Values

    - #### RESOURCE_OWNER

          protected static final java.lang.String RESOURCE_OWNER

      See Also:
        Constant Field Values

    - #### RESOURCE_REPLICATION_POLICY

          protected static final java.lang.String RESOURCE_REPLICATION_POLICY

      See Also:
        Constant Field Values

    - #### RESOURCE_REPLICATION_META

          protected static final java.lang.String RESOURCE_REPLICATION_META

      See Also:
        Constant Field Values

    - #### RESOURCE_REPLICATION_AUTHORIZED

          protected static final java.lang.String RESOURCE_REPLICATION_AUTHORIZED

      See Also:
        Constant Field Values

    - #### RESOURCE_REPLICATION_NOTIFY

          protected static final java.lang.String RESOURCE_REPLICATION_NOTIFY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CNResourceHandler

          public CNResourceHandler(javax.servlet.ServletContext servletContext,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)

  - ### Method Detail

    - #### handle

          public void handle(byte httpVerb)

      This function is called from REST API servlet and handles each request to the servlet
      Overrides:
        `handle` in class `D1ResourceHandler`
      Parameters:
        `httpVerb` - (GET, POST, PUT or DELETE)

    - #### getObject

          protected void getObject(java.lang.String guid)
                            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,
                                   java.io.IOException

      Implements REST version of DataONE CRUD API --> get
      Parameters:
        `guid` - ID of data object to be read
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidToken`
        `java.io.IOException`

    - #### getSystemMetadataObject

          protected void getSystemMetadataObject(java.lang.String guid)
                                          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,
                                                 java.io.IOException,
                                                 org.dataone.exceptions.MarshallingException

      Implements REST version of DataONE CRUD API --> getSystemMetadata
      Parameters:
        `guid` - ID of data object to be read
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidToken`
        `java.io.IOException`
        `org.dataone.exceptions.MarshallingException`

    - #### putObject

          protected void putObject(java.lang.String action)
                            throws org.dataone.service.exceptions.ServiceFailure,
                                   org.dataone.service.exceptions.InvalidRequest,
                                   org.dataone.service.exceptions.IdentifierNotUnique,
                                   org.dataone.exceptions.MarshallingException,
                                   org.dataone.service.exceptions.InvalidToken,
                                   org.dataone.service.exceptions.NotAuthorized,
                                   org.dataone.service.exceptions.UnsupportedType,
                                   org.dataone.service.exceptions.InsufficientResources,
                                   org.dataone.service.exceptions.InvalidSystemMetadata,
                                   org.dataone.service.exceptions.NotImplemented,
                                   java.io.IOException,
                                   java.lang.InstantiationException,
                                   java.lang.IllegalAccessException,
                                   java.security.NoSuchAlgorithmException,
                                   org.apache.commons.fileupload.FileUploadException

      Earthgrid API > Put Service >Put Function : calls MetacatHandler > handleInsertOrUpdateAction
      Parameters:
        `guid` - - ID of data object to be inserted or updated. If action is update, the pid is the existing pid. If insert, the pid is the new one
      Throws:
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.IdentifierNotUnique`
        `org.dataone.exceptions.MarshallingException`
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.InvalidSystemMetadata`
        `org.dataone.service.exceptions.InsufficientResources`
        `org.dataone.service.exceptions.UnsupportedType`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.InvalidToken`
        `java.io.IOException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`
        `org.apache.commons.fileupload.FileUploadException`
        `java.security.NoSuchAlgorithmException`

    - #### registerSystemMetadata

          protected void registerSystemMetadata()
                                         throws org.dataone.service.exceptions.ServiceFailure,
                                                org.dataone.service.exceptions.InvalidRequest,
                                                java.io.IOException,
                                                org.apache.commons.fileupload.FileUploadException,
                                                org.dataone.exceptions.MarshallingException,
                                                org.dataone.service.exceptions.NotImplemented,
                                                org.dataone.service.exceptions.NotAuthorized,
                                                org.dataone.service.exceptions.InvalidSystemMetadata,
                                                java.lang.InstantiationException,
                                                java.lang.IllegalAccessException,
                                                org.dataone.service.exceptions.InvalidToken

      Register System Metadata without data or metadata object
      Parameters:
        `pid` - identifier for System Metadata entry
      Throws:
        `org.dataone.exceptions.MarshallingException`
        `org.apache.commons.fileupload.FileUploadException`
        `java.io.IOException`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidSystemMetadata`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.NotImplemented`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`
        `org.dataone.service.exceptions.InvalidToken`

    - #### setAccess

          protected void setAccess(java.lang.String pid)
                            throws org.dataone.exceptions.MarshallingException,
                                   org.dataone.service.exceptions.InvalidToken,
                                   org.dataone.service.exceptions.ServiceFailure,
                                   org.dataone.service.exceptions.NotFound,
                                   org.dataone.service.exceptions.NotAuthorized,
                                   org.dataone.service.exceptions.NotImplemented,
                                   org.dataone.service.exceptions.InvalidRequest,
                                   java.io.IOException,
                                   java.lang.InstantiationException,
                                   java.lang.IllegalAccessException,
                                   javax.xml.parsers.ParserConfigurationException,
                                   org.xml.sax.SAXException,
                                   org.dataone.service.exceptions.VersionMismatch

      set the access perms on a document
      Throws:
        `org.dataone.exceptions.MarshallingException`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidToken`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`
        `java.io.IOException`
        `org.xml.sax.SAXException`
        `javax.xml.parsers.ParserConfigurationException`
        `org.dataone.service.exceptions.VersionMismatch`

    - #### isNodeAuthorized

          public boolean isNodeAuthorized(java.lang.String pid)
                                   throws org.dataone.service.exceptions.NotImplemented,
                                          org.dataone.service.exceptions.NotAuthorized,
                                          org.dataone.service.exceptions.InvalidToken,
                                          org.dataone.service.exceptions.ServiceFailure,
                                          org.dataone.service.exceptions.NotFound,
                                          org.dataone.service.exceptions.InvalidRequest

      Pass the request to get node replication authorization to CNodeService
      Parameters:
        `pid` - the identifier of the object to get authorization to replicate
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.InvalidToken`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.InvalidRequest`

    - #### setReplicationPolicy

          public boolean setReplicationPolicy(java.lang.String pid)
                                       throws org.dataone.service.exceptions.NotImplemented,
                                              org.dataone.service.exceptions.NotFound,
                                              org.dataone.service.exceptions.NotAuthorized,
                                              org.dataone.service.exceptions.ServiceFailure,
                                              org.dataone.service.exceptions.InvalidRequest,
                                              org.dataone.service.exceptions.InvalidToken,
                                              java.io.IOException,
                                              java.lang.InstantiationException,
                                              java.lang.IllegalAccessException,
                                              org.dataone.exceptions.MarshallingException,
                                              org.dataone.service.exceptions.VersionMismatch

      Pass the request to set the replication policy to CNodeService
      Parameters:
        `pid` - the identifier of the object to set the replication policy on
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.InvalidToken`
        `java.io.IOException`
        `java.lang.InstantiationException`
        `java.lang.IllegalAccessException`
        `org.dataone.exceptions.MarshallingException`
        `org.dataone.service.exceptions.VersionMismatch`

    - #### setObsoletedBy

          public boolean setObsoletedBy(java.lang.String pid)
                                 throws org.dataone.service.exceptions.NotImplemented,
                                        org.dataone.service.exceptions.NotFound,
                                        org.dataone.service.exceptions.NotAuthorized,
                                        org.dataone.service.exceptions.ServiceFailure,
                                        org.dataone.service.exceptions.InvalidRequest,
                                        org.dataone.service.exceptions.InvalidToken,
                                        java.lang.InstantiationException,
                                        java.lang.IllegalAccessException,
                                        org.dataone.service.exceptions.VersionMismatch

      Update the system metadata for a given pid, setting it to be obsoleted by the obsoletedByPid
      Parameters:
        `pid` -
      Returns:
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.InvalidToken`
        `java.lang.InstantiationException`
        `java.lang.IllegalAccessException`
        `org.dataone.service.exceptions.VersionMismatch`

    - #### deleteReplica

          public boolean deleteReplica(java.lang.String pid)
                                throws org.dataone.service.exceptions.NotImplemented,
                                       org.dataone.service.exceptions.NotFound,
                                       org.dataone.service.exceptions.NotAuthorized,
                                       org.dataone.service.exceptions.ServiceFailure,
                                       org.dataone.service.exceptions.InvalidRequest,
                                       org.dataone.service.exceptions.InvalidToken,
                                       java.lang.InstantiationException,
                                       java.lang.IllegalAccessException,
                                       org.dataone.service.exceptions.VersionMismatch

      Delete the replica entry with the given nodeId for the given pid
      Parameters:
        `pid` -
      Returns:
      Throws:
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.InvalidToken`
        `java.lang.InstantiationException`
        `java.lang.IllegalAccessException`
        `org.dataone.service.exceptions.VersionMismatch`

    - #### setReplicationStatus

          public boolean setReplicationStatus(java.lang.String pid)
                                       throws org.dataone.service.exceptions.ServiceFailure,
                                              org.dataone.service.exceptions.NotImplemented,
                                              org.dataone.service.exceptions.InvalidToken,
                                              org.dataone.service.exceptions.NotAuthorized,
                                              org.dataone.service.exceptions.InvalidRequest,
                                              org.dataone.service.exceptions.NotFound

      Pass the request to set the replication status to CNodeService
      Parameters:
        `pid` - the identifier of the object to set the replication status on
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.InvalidToken`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.exceptions.MarshallingException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`
        `java.io.IOException`

    - #### updateReplicationMetadata

          public boolean updateReplicationMetadata(java.lang.String pid)
                                            throws org.dataone.service.exceptions.ServiceFailure,
                                                   org.dataone.service.exceptions.NotImplemented,
                                                   org.dataone.service.exceptions.InvalidToken,
                                                   org.dataone.service.exceptions.NotAuthorized,
                                                   org.dataone.service.exceptions.InvalidRequest,
                                                   org.dataone.service.exceptions.NotFound,
                                                   org.dataone.service.exceptions.VersionMismatch,
                                                   java.lang.InstantiationException,
                                                   java.lang.IllegalAccessException,
                                                   java.io.IOException,
                                                   org.dataone.exceptions.MarshallingException

      Pass the request to update the replication metadata to CNodeService
      Parameters:
        `pid` - the identifier of the object to update the replication metadata on
      Throws:
        `org.dataone.service.exceptions.ServiceFailure`
        `org.dataone.service.exceptions.NotImplemented`
        `org.dataone.service.exceptions.InvalidToken`
        `org.dataone.service.exceptions.NotAuthorized`
        `org.dataone.service.exceptions.InvalidRequest`
        `org.dataone.service.exceptions.NotFound`
        `org.dataone.service.exceptions.VersionMismatch`
        `org.dataone.exceptions.MarshallingException`
        `java.io.IOException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`

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