Class KeyStrategyDigest

java.lang.Object
org.nuxeo.ecm.core.blob.KeyStrategyDigest
All Implemented Interfaces:
KeyStrategy

public class KeyStrategyDigest extends Object implements KeyStrategy
Represents computation of blob keys based on a message digest.

When a maxSize threshold is configured, blobs strictly larger than the threshold get a UUIDv7 key instead of a content-based digest key. This avoids unbounded digest computation for very large files (which can exceed Kafka poll intervals when computed asynchronously).

Since:
11.1
  • Field Details

    • UUID_V7_PATTERN

      protected static final Pattern UUID_V7_PATTERN
      UUIDv7 pattern: version digit 7, variant bits 10xx (hex digit in 8|9|a|b).
      Since:
      2025.19
    • digestAlgorithm

      public final String digestAlgorithm
    • digestPattern

      public final Pattern digestPattern
    • maxSize

      public final ByteSize maxSize
      Size threshold. Blobs strictly larger than this size get a UUIDv7 key instead of a digest key. ByteSize.unlimited() disables the threshold (always use digest keys).
      Since:
      2025.19
  • Constructor Details

    • KeyStrategyDigest

      public KeyStrategyDigest(String digestAlgorithm)
    • KeyStrategyDigest

      public KeyStrategyDigest(String digestAlgorithm, ByteSize maxSize)
      Parameters:
      digestAlgorithm - the digest algorithm (e.g. MD5)
      maxSize - the size threshold; blobs strictly larger than this get a UUIDv7 key. ByteSize.unlimited() disables the threshold (always use digest keys).
      Since:
      2025.19
  • Method Details

    • useDeDuplication

      public boolean useDeDuplication()
      Description copied from interface: KeyStrategy
      Checks whether this key strategy uses de-duplication. When de-duplication is used, two blobs with identical contents have identical keys.
      Specified by:
      useDeDuplication in interface KeyStrategy
    • getDigestFromKey

      public String getDigestFromKey(String key)
      Description copied from interface: KeyStrategy
      Gets, if possible, a digest from the key. This is not possible if the key is not derived from a digest.
      Specified by:
      getDigestFromKey in interface KeyStrategy
      Parameters:
      key - the key
      Returns:
      a digest, or null
    • isValidDigest

      public boolean isValidDigest(String key)
    • getDigestPattern

      protected static Pattern getDigestPattern(String digestAlgorithm)
    • getBlobWriteContext

      public BlobWriteContext getBlobWriteContext(BlobContext blobContext)
      Description copied from interface: KeyStrategy
      Gets the write context for the given blob.
      Specified by:
      getBlobWriteContext in interface KeyStrategy
    • isAboveThreshold

      protected boolean isAboveThreshold(BlobContext blobContext)
      Returns:
      true if a threshold is configured and the blob is strictly larger than it
      Since:
      2025.19
    • hasThreshold

      public boolean hasThreshold()
      Returns:
      true if a finite size threshold is configured
      Since:
      2025.19
    • generateUUIDv7Key

      public String generateUUIDv7Key()
      Since:
      2025.19
    • isUUIDv7

      public static boolean isUUIDv7(String key)
      Returns:
      true if the given key matches the UUIDv7 format
      Since:
      2025.19
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isValidKey

      public boolean isValidKey(String key)
      Description copied from interface: KeyStrategy
      Does the given key have the expected pattern for this strategy.
      Specified by:
      isValidKey in interface KeyStrategy