Class ProtectedUtils

java.lang.Object
org.apache.curator.framework.imps.ProtectedUtils

public final class ProtectedUtils extends Object
Utility class to handle ZNode names when using CreateBuilderMain.withProtection()
  • Method Details

    • getProtectedPrefix

      public static String getProtectedPrefix(String protectedId)
      Provides a prefix to be prepended to a ZNode name when protected. The method assumes that the provided string adjusts to the required format
      Parameters:
      protectedId - canonical text representation of a UUID
      Returns:
      string that concatenates "_c_", the given id and '-'
    • isProtectedZNode

      public static boolean isProtectedZNode(String znodeName)
      Utility method to determine if a given ZNode name starts with Curator's generated protected prefix.
      Parameters:
      znodeName - ZNode name
      Returns:
      true if the given ZNode name starts with Curator's generated protected prefix
    • normalize

      public static String normalize(String znodeName)
      Utility method to remove Curator's generated protected prefix if present
      Parameters:
      znodeName - ZNode name
      Returns:
      string without Curator's generated protected prefix if present; original string if prefix not present
    • normalizePath

      public static String normalizePath(String path)
      Utility method to provide a path removing Curator's generated protected prefix if present in the ZNode name
      Parameters:
      path - ZNode path
      Returns:
      string without Curator's generated protected prefix if present in ZNode name; original string if prefix not present
    • extractProtectedId

      public static Optional<String> extractProtectedId(String znodeName)
      Extracts protectedId in case the provided name is protected
      Parameters:
      znodeName - name of the ZNode
      Returns:
      Optional with protectedId if the name is protected or Optional#empty()
    • toProtectedZNode

      public static String toProtectedZNode(String znodeName, String protectedId)
      Converts a given ZNode name to protected format
      Parameters:
      znodeName - name to be converted (e.g. 'name1')
      protectedId - UUID canonical text representation used in protection mode (e.g. '53345f98-9423-4e0c-a7b5-9f819e3ec2e1')
      Returns:
      name with protected mode prefix (e.g. '_c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-name1') or the same name if protectedId is null
    • toProtectedZNodePath

      public static String toProtectedZNodePath(String path, String protectedId)
      Converts a given path to protected format
      Parameters:
      path - complete path to be converted (e.g. '/root/path1')
      protectedId - UUID canonical text representation used in protection mode (e.g. '53345f98-9423-4e0c-a7b5-9f819e3ec2e1')
      Returns:
      path with protected mode prefix (e.g. '/root/_c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-path1') or the same path if protectedId is null