edu.ucsb.nceas.metacat.accesscontrol

## Class AccessControlForSingleFile

- java.lang.Object
- - edu.ucsb.nceas.metacat.accesscontrol.AccessControlForSingleFile

- All Implemented Interfaces:
    edu.ucsb.nceas.utilities.access.AccessControlInterface

      public class AccessControlForSingleFile
      extends java.lang.Object
      implements edu.ucsb.nceas.utilities.access.AccessControlInterface

  A Class that loads eml-access.xml file containing ACL for a metadata document into relational DB. It extends DefaultHandler class to handle SAX parsing events when processing the XML stream.

- - ### Field Summary

    - ### Fields inherited from interface edu.ucsb.nceas.utilities.access.AccessControlInterface

      `ACCESS, ACLID, ALL, ALLOW, ALLOWFIRST, ALLSTRING, CHMOD, CHMODSTRING, DENY, DENYFIRST, ORDER, PERMISSION, PRINCIPAL, PUBLIC, READ, READSTRING, WRITE, WRITESTRING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AccessControlForSingleFile(java.lang.String accessionNumber)` Construct an instance of the AccessControlForSingleFile class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accessControlExists(edu.ucsb.nceas.utilities.access.XMLAccessDAO xmlAccessDAO)` Check if access control comination for docid/principal/permission/permorder/permtype already exists.
    `java.lang.String` | `getAccessString()` Get the access xml for all access on this docid
    `java.lang.String` | `getAccessString(java.util.Vector<edu.ucsb.nceas.utilities.access.XMLAccessDAO> xmlAccessDAOList)` Put together an xml representation of the objects in a given access dao list
    `java.lang.String` | `getACL(java.lang.String user, java.lang.String[] groups)` Get Access Control List information for document from db connetion.
    `void` | `insertPermissions(java.lang.String accessBlock)` Replace existing permissions with a given block of permissions for this document.
    `void` | `insertPermissions(java.lang.String principalName, java.lang.Long permission, java.lang.String permType, java.lang.String permOrder, java.lang.String accessFileId, java.lang.String subTreeId)` Insert a single access record into the database.
    `void` | `insertPermissions(edu.ucsb.nceas.utilities.access.XMLAccessDAO xmlAccessDAO)` Insert a single access record into the database based on access DAO object

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

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

- - ### Constructor Detail

    - #### AccessControlForSingleFile

          public AccessControlForSingleFile(java.lang.String accessionNumber)
                                     throws AccessControlException

      Construct an instance of the AccessControlForSingleFile class. This instance will represent one file only.
      Parameters:
        `myAccessNumber` - the docid or docid with dev will be controlled
      Throws:
        `AccessControlException`

  - ### Method Detail

    - #### insertPermissions

          public void insertPermissions(edu.ucsb.nceas.utilities.access.XMLAccessDAO xmlAccessDAO)
                                 throws AccessControlException,
                                        PermOrderException

      Insert a single access record into the database based on access DAO object
      Parameters:
        `xmlAccessDAO` - dao object holding info to insert
      Throws:
        `AccessControlException`
        `PermOrderException`

    - #### insertPermissions

          public void insertPermissions(java.lang.String principalName,
                                        java.lang.Long permission,
                                        java.lang.String permType,
                                        java.lang.String permOrder,
                                        java.lang.String accessFileId,
                                        java.lang.String subTreeId)
                                 throws AccessControlException,
                                        PermOrderException

      Insert a single access record into the database.
      Parameters:
        `principalName` - the principal credentials
        `permission` - the permission
        `permType` - the permission type
        `permOrder` - the permission order
      Throws:
        `AccessControlException`
        `PermOrderException`

    - #### insertPermissions

          public void insertPermissions(java.lang.String accessBlock)
                                 throws AccessControlException

      Replace existing permissions with a given block of permissions for this document.
      Parameters:
        `accessBlock` - the xml access block. This is the same structure as that returned by the getdocumentinfo action in metacat.
      Throws:
        `AccessControlException`

    - #### accessControlExists

          public boolean accessControlExists(edu.ucsb.nceas.utilities.access.XMLAccessDAO xmlAccessDAO)
                                      throws AccessControlException

      Check if access control comination for docid/principal/permission/permorder/permtype already exists.
      Parameters:
        `xmlAccessDAO` - the dao object holding the access we want to check for.
      Returns:
        true if the Access Control for this file already exists in the DB
      Throws:
        `AccessControlException`

    - #### getACL

          public java.lang.String getACL(java.lang.String user,
                                         java.lang.String[] groups)
                                  throws AccessControlException

      Get Access Control List information for document from db connetion. User or Group should have permissions for reading access control information for a document specified by
      Parameters:
        `user` - name of user connected to Metacat system
        `groups` - names of user's groups to which user belongs
      Throws:
        `AccessControlException`

    - #### getAccessString

          public java.lang.String getAccessString()
                                           throws AccessControlException

      Get the access xml for all access on this docid
      Returns:
        string representation of access
      Throws:
        `AccessControlException`

    - #### getAccessString

          public java.lang.String getAccessString(java.util.Vector<edu.ucsb.nceas.utilities.access.XMLAccessDAO> xmlAccessDAOList)
                                           throws AccessControlException

      Put together an xml representation of the objects in a given access dao list
      Parameters:
        `xmlAccessDAOList` - list of xml access DAO objects
      Returns:
        string representation of access
      Throws:
        `AccessControlException`

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