Class ProtectedUtils

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<java.lang.String> extractProtectedId​(java.lang.String znodeName)
      Extracts protectedId in case the provided name is protected
      static java.lang.String getProtectedPrefix​(java.lang.String protectedId)
      Provides a prefix to be prepended to a ZNode name when protected.
      static boolean isProtectedZNode​(java.lang.String znodeName)
      Utility method to determine if a given ZNode name starts with Curator's generated protected prefix.
      static java.lang.String normalize​(java.lang.String znodeName)
      Utility method to remove Curator's generated protected prefix if present
      static java.lang.String normalizePath​(java.lang.String path)
      Utility method to provide a path removing Curator's generated protected prefix if present in the ZNode name
      static java.lang.String toProtectedZNode​(java.lang.String znodeName, java.lang.String protectedId)
      Converts a given ZNode name to protected format
      static java.lang.String toProtectedZNodePath​(java.lang.String path, java.lang.String protectedId)
      Converts a given path to protected format
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getProtectedPrefix

        public static java.lang.String getProtectedPrefix​(java.lang.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 45
      • isProtectedZNode

        public static boolean isProtectedZNode​(java.lang.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 java.lang.String normalize​(java.lang.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 java.lang.String normalizePath​(java.lang.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 java.util.Optional<java.lang.String> extractProtectedId​(java.lang.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 java.lang.String toProtectedZNode​(java.lang.String znodeName,
                                                        java.lang.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 java.lang.String toProtectedZNodePath​(java.lang.String path,
                                                            java.lang.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