Class AclCodec

java.lang.Object
com.norconex.committer.core.acl.AclCodec

public final class AclCodec extends Object
Writes an Acl as the JSON text documents carry, and reads it back. The text is canonical: the same permissions always give the same text (entries sorted, map keys sorted), so a crawler can tell whether a document's permissions changed by comparing it.
  • Method Details

    • toJson

      public static String toJson(Acl acl)
      Parameters:
      acl - the ACL
      Returns:
      its canonical JSON text
    • fromJson

      public static Acl fromJson(String json)
      Parameters:
      json - JSON text written by toJson(Acl)
      Returns:
      the ACL
      Throws:
      IllegalArgumentException - if the text is not a readable ACL
    • read

      public static Optional<Acl> read(Properties metadata)
      Reads a document's ACL.
      Parameters:
      metadata - the document's metadata
      Returns:
      the ACL, or empty if the document has none
      Throws:
      IllegalArgumentException - if the document's ACL is not readable, or it has more than one
    • write

      public static void write(Properties metadata, Acl acl)
      Sets a document's ACL, replacing any it had.
      Parameters:
      metadata - the document's metadata
      acl - the ACL