Class ProtectedUtils
java.lang.Object
org.apache.curator.framework.imps.ProtectedUtils
Utility class to handle ZNode names when using
CreateBuilderMain.withProtection()
-
Method Summary
Modifier and TypeMethodDescriptionextractProtectedId
(String znodeName) Extracts protectedId in case the provided name is protectedstatic String
getProtectedPrefix
(String protectedId) Provides a prefix to be prepended to a ZNode name when protected.static boolean
isProtectedZNode
(String znodeName) Utility method to determine if a given ZNode name starts with Curator's generated protected prefix.static String
Utility method to remove Curator's generated protected prefix if presentstatic String
normalizePath
(String path) Utility method to provide a path removing Curator's generated protected prefix if present in the ZNode namestatic String
toProtectedZNode
(String znodeName, String protectedId) Converts a given ZNode name to protected formatstatic String
toProtectedZNodePath
(String path, String protectedId) Converts a given path to protected format
-
Method Details
-
getProtectedPrefix
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
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
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
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
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
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
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
-