IdentifierManager { @NotNull public static String getIdentifier(Tree tree) { PropertyState property = tree.getProperty(JcrConstants.JCR_UUID); if (property != null) { return property.getValue(Type.STRING); } else if (tree.isRoot()) { return "/"; } else { String parentId = getIdentifier(tree.getParent()); return PathUtils.concat(parentId, tree.getName()); } } IdentifierManager(Root root); @NotNull static String generateUUID(); @NotNull static String generateUUID(String hint); static boolean isValidUUID(String uuid); @NotNull static String getIdentifier(Tree tree); @Nullable Tree getTree(String identifier); @Nullable String getPath(String identifier); @Nullable String getPath(PropertyState referenceValue); @Nullable String getPath(PropertyValue referenceValue); @NotNull Iterable<String> getReferences(boolean weak, @NotNull Tree tree, @Nullable final String propertyName); @NotNull Iterable<String> getReferences(@NotNull Tree tree, @NotNull final String propertyName,
                                          @NotNull String ntName, boolean weak); @Nullable String resolveUUID(String uuid);  }
@Test public void getIdentifierTest() { Tree rootTree = root.getTree("/"); assertEquals(ID_ROOT, getIdentifier(rootTree)); Tree xx1 = root.getTree(PATH_X1); assertEquals(ID_X1, getIdentifier(xx1)); Tree yy1 = root.getTree(PATH_Y1); assertEquals(ID_Y1, getIdentifier(yy1)); Tree zz1 = root.getTree(PATH_Z1); assertEquals(ID_Z1, getIdentifier(zz1)); }