Record Class Acl

java.lang.Object
java.lang.Record
com.norconex.committer.core.acl.Acl
Record Components:
version - the version of this shape, 1 for now; a committer rejects a version it does not know
status - how much of the permissions this holds
scope - which of the source's permissions were asked for
unread - what could not be read, in a few words each, when the status is AclStatus.PARTIAL or AclStatus.NONE (for example "share permissions: access denied")
levels - the checks to pass, in order; empty when the status is AclStatus.NONE
owners - who owns the document (entries without access), for the destinations that keep owners; not part of the access decision
nativeData - the source's own permission entries, untouched, for audit or custom use; may be null

public record Acl(int version, @NonNull AclStatus status, @NonNull AclScope scope, List<String> unread, List<AclLevel> levels, List<AclEntry> owners, Map<String,Object> nativeData) extends Record

Who may read a document, in one shape whatever the source: a fetcher that reads a source's permissions writes it on the document (see AclCodec, and the "crawler.acl" field), and a committer translates it for its destination, or sends it as is.

A person may read the document only if every one of its levels() allows them. Most documents have one level; some sources check several, such as a file share's permissions and then the file's own.

  • Field Details

    • FIELD

      public static final String FIELD
      The document field holding a document's ACL as JSON.
      See Also:
    • VERSION

      public static final int VERSION
      The version of this shape that this code writes and reads.
      See Also:
  • Constructor Details

    • Acl

      public Acl(int version, @NonNull @NonNull AclStatus status, @NonNull @NonNull AclScope scope, List<String> unread, List<AclLevel> levels, List<AclEntry> owners, Map<String,Object> nativeData)
      Copies the levels, the owners and what was not read (none when null: an empty list is not written), the owners without duplicates and in their canonical order, what was not read without duplicates and sorted.
      Parameters:
      version - the version of this shape
      status - how much of the permissions this holds
      scope - which permissions were asked for
      unread - what could not be read
      levels - the checks to pass, in order
      owners - who owns the document
      nativeData - the source's own entries
  • Method Details

    • complete

      public static Acl complete(List<AclLevel> levels, List<AclEntry> owners, Map<String,Object> nativeData)
      A complete ACL of everything the source has.
      Parameters:
      levels - the checks to pass, in order
      owners - who owns the document
      nativeData - the source's own entries, or null
      Returns:
      the ACL
    • none

      public static Acl none(AclScope scope, String why)
      An ACL for a document whose permissions were asked for and could not be read at all.
      Parameters:
      scope - which permissions were asked for
      why - why they could not be read, in a few words
      Returns:
      the ACL
    • withStatus

      public Acl withStatus(AclStatus status)
      Parameters:
      status - the status to give
      Returns:
      a copy of this ACL with another status
    • withUnread

      public Acl withUnread(List<String> what)
      A copy of this ACL marked AclStatus.PARTIAL, saying what could not be read. Does nothing when what is empty.
      Parameters:
      what - what could not be read, in a few words each
      Returns:
      the partial ACL, or this one when nothing is given
    • withScope

      public Acl withScope(AclScope scope)
      Parameters:
      scope - the scope to give
      Returns:
      a copy of this ACL with another scope
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • version

      public int version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • status

      @NonNull public @NonNull AclStatus status()
      Returns the value of the status record component.
      Returns:
      the value of the status record component
    • scope

      @NonNull public @NonNull AclScope scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component
    • unread

      public List<String> unread()
      Returns the value of the unread record component.
      Returns:
      the value of the unread record component
    • levels

      public List<AclLevel> levels()
      Returns the value of the levels record component.
      Returns:
      the value of the levels record component
    • owners

      public List<AclEntry> owners()
      Returns the value of the owners record component.
      Returns:
      the value of the owners record component
    • nativeData

      public Map<String,Object> nativeData()
      Returns the value of the nativeData record component.
      Returns:
      the value of the nativeData record component