private Iterable<? extends PropertyState> getFilteredProperties() { return Iterables.filter(tree.getProperties(), getPropertyFilters()); }
public static Map<String, String> getNamespaceMap(Tree root) { Map<String, String> map = collectNamespaces(getNamespaceTree(root).getProperties()); map.put("", ""); // default namespace, not included in tree return map; }
public static Map<String, String> getNamespaceMap(Tree root) { Map<String, String> map = collectNamespaces(getNamespaceTree(root).getProperties()); map.put("", ""); // default namespace, not included in tree return map; }
@NotNull public Iterable<String> getVersionLabels() throws RepositoryException { Tree versionLabels = getVersionLabelsTree(); List<String> labels = new ArrayList<String>(); for (PropertyState p : versionLabels.getProperties()) { if (p.getType() == Type.REFERENCE) { labels.add(p.getName()); } } return labels; }
@Nonnull public Iterable<String> getVersionLabels() throws RepositoryException { Tree versionLabels = getVersionLabelsTree(); List<String> labels = new ArrayList<String>(); for (PropertyState p : versionLabels.getProperties()) { if (p.getType() == Type.REFERENCE) { labels.add(p.getName()); } } return labels; }
@NotNull private Map<String, PropertyState> getRestrictionProperties(Tree aceTree) { Tree rTree = getRestrictionsTree(aceTree); Map<String, PropertyState> restrictionProperties = new HashMap<>(); for (PropertyState property : rTree.getProperties()) { String name = property.getName(); if (isRestrictionProperty(name)) { restrictionProperties.put(name, property); } } return restrictionProperties; }
private static void render(Tree tree, JsonGenerator generator) throws IOException { generator.writeStartObject(); for (PropertyState property : tree.getProperties()) { generator.writeFieldName(property.getName()); render(property, generator); } for (Tree child : tree.getChildren()) { generator.writeFieldName(child.getName()); generator.writeStartObject(); generator.writeEndObject(); } generator.writeEndObject(); }
@NotNull public Iterable<String> getVersionLabels() throws RepositoryException { Tree versionLabels = getVersionLabelsTree(); List<String> labels = new ArrayList<String>(); for (PropertyState p : versionLabels.getProperties()) { if (p.getType() == Type.REFERENCE) { labels.add(p.getName()); } } return labels; }
@Nonnull private Map<String, PropertyState> getRestrictionProperties(Tree aceTree) { Tree rTree = getRestrictionsTree(aceTree); Map<String, PropertyState> restrictionProperties = new HashMap<String, PropertyState>(); for (PropertyState property : rTree.getProperties()) { String name = property.getName(); if (isRestrictionProperty(name)) { restrictionProperties.put(name, property); } } return restrictionProperties; }
public static Map<String, String> getNamespaceMap(Tree root) { Map<String, String> map = newHashMap(); map.put("", ""); // default namespace, not included in tree Tree namespaces = getNamespaceTree(root); for (PropertyState property : namespaces.getProperties()) { String prefix = property.getName(); if (STRING.equals(property.getType()) && isValidPrefix(prefix)) { map.put(prefix, property.getValue(STRING)); } } return map; }
private void copy(Tree source, Tree targetParent, String targetName) { Tree target = targetParent.addChild(targetName); for (PropertyState property : source.getProperties()) { target.setProperty(property); } for (Tree child : source.getChildren()) { copy(child, target, child.getName()); } }
@Test public void testGetProperties() { Set<String> propertyNames = Sets.newHashSet(JcrConstants.JCR_PRIMARYTYPE, "aProp"); Tree a = root.getTree("/a"); for (PropertyState prop : a.getProperties()) { assertTrue(propertyNames.remove(prop.getName())); } assertTrue(propertyNames.isEmpty()); }
@Test public void testGetProperties() { Set<String> propertyNames = Sets.newHashSet(JcrConstants.JCR_PRIMARYTYPE, "aProp"); Tree a = root.getTree("/a"); for (PropertyState prop : a.getProperties()) { assertTrue(propertyNames.remove(prop.getName())); } assertTrue(propertyNames.isEmpty()); }
@Test public void testGetProperties() throws Exception { setupPermission("/a", testPrincipal, false, PrivilegeConstants.REP_READ_PROPERTIES); testRoot.refresh(); Tree a = testRoot.getTree("/a"); Iterable<? extends PropertyState> props = a.getProperties(); assertFalse(props.iterator().hasNext()); } }
@Override public boolean check(MountedNodeStore mountedStore, Tree tree, ErrorHolder errorHolder, Context context) { String name = tree.getName(); String path = tree.getPath(); validate(mountedStore, errorHolder, context, name, path); for ( PropertyState prop : tree.getProperties() ) { String propName = prop.getName(); validate(mountedStore, errorHolder, context, propName, PathUtils.concat(tree.getPath(), propName)); } return true; }
private String chooseProperty(String parentPath) { Tree state = root1.getTree(parentPath); int k = random.nextInt((int) (state.getPropertyCount() + 1)); int c = 0; for (PropertyState entry : state.getProperties()) { if (c++ == k) { return PathUtils.concat(parentPath, entry.getName()); } } return null; }
@SuppressWarnings("unused") private static void walktree(final Tree t) { System.out.println("+ " + t.getPath()); for (PropertyState p : t.getProperties()) { System.out.println(" -" + p.getName() + "=" + p.getValue(STRING)); } for (Tree t1 : t.getChildren()) { walktree(t1); } }
@Test public void testIsGranted() { for (String path : paths) { Tree tree = getRootProvider().createReadOnlyRoot(root).getTree(path); assertFalse(noPermissions.isGranted(tree, null, Permissions.NO_PERMISSION)); for (PropertyState prop : tree.getProperties()) { assertFalse(noPermissions.isGranted(tree, prop, Permissions.NO_PERMISSION)); } for (Tree child : tree.getChildren()) { assertFalse(noPermissions.isGranted(child, null, Permissions.NO_PERMISSION)); } } }
private static void checkEqual(Tree tree1, Tree tree2) { assertEquals(tree1.getChildrenCount(Long.MAX_VALUE), tree2.getChildrenCount(Long.MAX_VALUE)); assertEquals(tree1.getPropertyCount(), tree2.getPropertyCount()); for (PropertyState property1 : tree1.getProperties()) { assertEquals(property1, tree2.getProperty(property1.getName())); } for (Tree child1 : tree1.getChildren()) { checkEqual(child1, tree2.getChild(child1.getName())); } } }
@Test public void testIsGranted() { for (String path : paths) { Tree tree = getRootProvider().createReadOnlyRoot(root).getTree(path); assertTrue(tree.exists()); assertTrue(all.isGranted(tree, null, Permissions.ALL)); for (PropertyState prop : tree.getProperties()) { assertTrue(all.isGranted(tree, prop, Permissions.ALL)); } for (Tree child : tree.getChildren()) { assertTrue(all.isGranted(child, null, Permissions.ALL)); } } }