private static long addNestedCugPath(@NotNull NodeBuilder parentBuilder, @NotNull NodeBuilder builder, @NotNull String pathWithNewCug) { PropertyState ps = parentBuilder.getProperty(HIDDEN_NESTED_CUGS); PropertyBuilder<String> pb = getHiddenPropertyBuilder(ps); if (ps != null) { List<String> moveToNestedCug = Lists.newArrayList(); for (String p : ps.getValue(Type.STRINGS)) { if (Text.isDescendant(pathWithNewCug, p)) { pb.removeValue(p); moveToNestedCug.add(p); } else if (p.equals(pathWithNewCug)) { // already present with parent -> remove to avoid duplicate entries log.debug("Path of node holding a new nested CUG is already listed with the parent CUG."); pb.removeValue(p); } } if (!moveToNestedCug.isEmpty()) { PropertyBuilder<String> pb2 = getHiddenPropertyBuilder(builder.getProperty(HIDDEN_NESTED_CUGS)); pb2.addValues(moveToNestedCug); builder.setProperty(pb2.getPropertyState()); } } // update the nested-cug property of the parent pb.addValue(pathWithNewCug); parentBuilder.setProperty(pb.getPropertyState()); return pb.count(); }
private static void addChild(NodeBuilder target, String name, NodeState state) { target.setChildNode(name, state); PropertyState childOrder = target.getProperty(TreeConstants.OAK_CHILD_ORDER); if (childOrder != null) { PropertyBuilder<String> builder = PropertyBuilder.copy(NAME, childOrder); builder.addValue(name); target.setProperty(builder.getPropertyState()); } }
/** * @param oakPath the Oak path as specified with the ac mgr call. * @param tree the access controlled node. * @return the new acl tree. * @throws AccessDeniedException In case the new acl tree is not accessible. */ @NotNull private Tree createAclTree(@Nullable String oakPath, @NotNull Tree tree) throws AccessDeniedException { if (!Util.isAccessControlled(oakPath, tree, ntMgr)) { PropertyState mixins = tree.getProperty(JcrConstants.JCR_MIXINTYPES); String mixinName = Util.getMixinName(oakPath); if (mixins == null) { tree.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton(mixinName), Type.NAMES); } else { PropertyBuilder<String> pb = PropertyBuilder.copy(Type.NAME, mixins); pb.addValue(mixinName); tree.setProperty(pb.getPropertyState()); } } String aclName = Util.getAclName(oakPath); return TreeUtil.addChild(tree, aclName, NT_REP_ACL); }
private static long addNestedCugPath(@NotNull NodeBuilder parentBuilder, @NotNull NodeBuilder builder, @NotNull String pathWithNewCug) { PropertyState ps = parentBuilder.getProperty(HIDDEN_NESTED_CUGS); PropertyBuilder<String> pb = getHiddenPropertyBuilder(ps); if (ps != null) { List<String> moveToNestedCug = Lists.newArrayList(); for (String p : ps.getValue(Type.STRINGS)) { if (Text.isDescendant(pathWithNewCug, p)) { pb.removeValue(p); moveToNestedCug.add(p); } else if (p.equals(pathWithNewCug)) { // already present with parent -> remove to avoid duplicate entries log.debug("Path of node holding a new nested CUG is already listed with the parent CUG."); pb.removeValue(p); } } if (!moveToNestedCug.isEmpty()) { PropertyBuilder<String> pb2 = getHiddenPropertyBuilder(builder.getProperty(HIDDEN_NESTED_CUGS)); pb2.addValues(moveToNestedCug); builder.setProperty(pb2.getPropertyState()); } } // update the nested-cug property of the parent pb.addValue(pathWithNewCug); parentBuilder.setProperty(pb.getPropertyState()); return pb.count(); }
/** * @param oakPath the Oak path as specified with the ac mgr call. * @param tree the access controlled node. * @return the new acl tree. * @throws AccessDeniedException In case the new acl tree is not accessible. */ @NotNull private Tree createAclTree(@Nullable String oakPath, @NotNull Tree tree) throws AccessDeniedException { if (!Util.isAccessControlled(oakPath, tree, ntMgr)) { PropertyState mixins = tree.getProperty(JcrConstants.JCR_MIXINTYPES); String mixinName = Util.getMixinName(oakPath); if (mixins == null) { tree.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton(mixinName), Type.NAMES); } else { PropertyBuilder<String> pb = PropertyBuilder.copy(Type.NAME, mixins); pb.addValue(mixinName); tree.setProperty(pb.getPropertyState()); } } String aclName = Util.getAclName(oakPath); return TreeUtil.addChild(tree, aclName, NT_REP_ACL); }
private static void addChild(NodeBuilder target, String name, NodeState state) { target.setChildNode(name, state); PropertyState childOrder = target.getProperty(TreeConstants.OAK_CHILD_ORDER); if (childOrder != null) { PropertyBuilder<String> builder = PropertyBuilder.copy(NAME, childOrder); builder.addValue(name); target.setProperty(builder.getPropertyState()); } }
private static void addChild(NodeBuilder target, String name, NodeState state) { target.setChildNode(name, state); PropertyState childOrder = target.getProperty(TreeConstants.OAK_CHILD_ORDER); if (childOrder != null) { PropertyBuilder<String> builder = PropertyBuilder.copy(NAME, childOrder); builder.addValue(name); target.setProperty(builder.getPropertyState()); } }
/** * @param oakPath the Oak path as specified with the ac mgr call. * @param tree the access controlled node. * @return the new acl tree. * @throws AccessDeniedException In case the new acl tree is not accessible. */ @Nonnull private Tree createAclTree(@Nullable String oakPath, @Nonnull Tree tree) throws AccessDeniedException { if (!Util.isAccessControlled(oakPath, tree, ntMgr)) { PropertyState mixins = tree.getProperty(JcrConstants.JCR_MIXINTYPES); String mixinName = Util.getMixinName(oakPath); if (mixins == null) { tree.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton(mixinName), Type.NAMES); } else { PropertyBuilder pb = PropertyBuilder.copy(Type.NAME, mixins); pb.addValue(mixinName); tree.setProperty(pb.getPropertyState()); } } String aclName = Util.getAclName(oakPath); return TreeUtil.addChild(tree, aclName, NT_REP_ACL); }
private static void merge(NodeBuilder parent, PropertyState ours, PropertyState theirs) { Set<String> theirOrder = Sets.newHashSet(theirs.getValue(Type.NAMES)); PropertyBuilder<String> merged = PropertyBuilder.array(Type.NAME).assignFrom(theirs); // Append child node names from ours that are not in theirs for (String ourChild : ours.getValue(Type.NAMES)) { if (!theirOrder.contains(ourChild)) { merged.addValue(ourChild); } } // Remove child node names of nodes that have been removed for (String child : merged.getValues()) { if (!parent.hasChildNode(child)) { merged.removeValue(child); } } parent.setProperty(merged.getPropertyState()); }
private static void merge(NodeBuilder parent, PropertyState ours, PropertyState theirs) { Set<String> theirOrder = Sets.newHashSet(theirs.getValue(Type.NAMES)); PropertyBuilder<String> merged = PropertyBuilder.array(Type.NAME).assignFrom(theirs); // Append child node names from ours that are not in theirs for (String ourChild : ours.getValue(Type.NAMES)) { if (!theirOrder.contains(ourChild)) { merged.addValue(ourChild); } } // Remove child node names of nodes that have been removed for (String child : merged.getValues()) { if (!parent.hasChildNode(child)) { merged.removeValue(child); } } parent.setProperty(merged.getPropertyState()); }
private static void merge(NodeBuilder parent, PropertyState ours, PropertyState theirs) { Set<String> theirOrder = Sets.newHashSet(theirs.getValue(Type.NAMES)); PropertyBuilder<String> merged = PropertyBuilder.array(Type.NAME).assignFrom(theirs); // Append child node names from ours that are not in theirs for (String ourChild : ours.getValue(Type.NAMES)) { if (!theirOrder.contains(ourChild)) { merged.addValue(ourChild); } } // Remove child node names of nodes that have been removed for (String child : merged.getValues()) { if (!parent.hasChildNode(child)) { merged.removeValue(child); } } parent.setProperty(merged.getPropertyState()); }
prop = PropertyBuilder.array(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS); prop.addValue(ref); count++; if (count > MembershipWriter.DEFAULT_MEMBERSHIP_THRESHOLD) {
prop = PropertyBuilder.array(Type.WEAKREFERENCE, UserConstants.REP_MEMBERS); prop.addValue(ref); count++; if (count > MembershipWriter.DEFAULT_MEMBERSHIP_THRESHOLD) {
private static void createContent(NodeStore nodeStore) throws IOException, CommitFailedException { NodeBuilder rootBuilder = nodeStore.getRoot().builder(); rootBuilder.child("node1").setProperty("prop", createBlob(nodeStore)); rootBuilder.child("node2").setProperty("prop", createBlob(nodeStore)); PropertyBuilder<Blob> builder = PropertyBuilder.array(Type.BINARY, "prop"); builder.addValue(createBlob(nodeStore)); builder.addValue(createBlob(nodeStore)); builder.addValue(createBlob(nodeStore)); rootBuilder.child("node3").setProperty(builder.getPropertyState()); nodeStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Test public void testStringsProperty() { PropertyBuilder builder = PropertyBuilder.array(Type.STRING); builder.setName("foo") .addValue("one") .addValue("two"); assertEquals(MultiStringPropertyState.stringProperty("foo", Arrays.asList("one", "two")), builder.getPropertyState()); builder.setScalar(); try { builder.getPropertyState(); } catch (IllegalStateException expected) { // success } builder.removeValue("one"); assertEquals(StringPropertyState.stringProperty("foo", "two"), builder.getPropertyState()); }
@Test public void testDateProperty() { PropertyBuilder builder = PropertyBuilder.array(Type.DATE); String date1 = "1970-01-01T00:00:00.000Z"; String date2 = "1971-01-01T00:00:00.000Z"; builder.setName("foo") .addValue(date1) .addValue(date2); Assert.assertEquals(MultiGenericPropertyState.dateProperty("foo", Arrays.asList(date1, date2)), builder.getPropertyState()); builder.setScalar(); try { builder.getPropertyState(); } catch (IllegalStateException expected) { } builder.removeValue(date1); Assert.assertEquals(GenericPropertyState.dateProperty("foo", date2), builder.getPropertyState()); }
propertyBuilder.addValue(name); jcrAll.setProperty(propertyBuilder.getPropertyState());
propertyBuilder.addValue(name); jcrAll.setProperty(propertyBuilder.getPropertyState());
propertyBuilder.addValue(name); jcrAll.setProperty(propertyBuilder.getPropertyState());
for(int i = 0; i < 2; i++){ Blob b = store.createBlob(randomStream(i, 4096)); p1.addValue(b); blobs.add(new ReferencedBlob(b, "/x/y"));