Class ProtectedUtils
- java.lang.Object
-
- org.apache.curator.framework.imps.ProtectedUtils
-
public final class ProtectedUtils extends java.lang.ObjectUtility class to handle ZNode names when usingCreateBuilderMain.withProtection()
-
-
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 protectedstatic java.lang.StringgetProtectedPrefix(java.lang.String protectedId)Provides a prefix to be prepended to a ZNode name when protected.static booleanisProtectedZNode(java.lang.String znodeName)Utility method to determine if a given ZNode name starts with Curator's generated protected prefix.static java.lang.Stringnormalize(java.lang.String znodeName)Utility method to remove Curator's generated protected prefix if presentstatic java.lang.StringnormalizePath(java.lang.String path)Utility method to provide a path removing Curator's generated protected prefix if present in the ZNode namestatic java.lang.StringtoProtectedZNode(java.lang.String znodeName, java.lang.String protectedId)Converts a given ZNode name to protected formatstatic java.lang.StringtoProtectedZNodePath(java.lang.String path, java.lang.String protectedId)Converts a given path to protected format
-
-
-
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
-
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:
trueif 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
-
-