@Override public long getPropertyCount() { return state.getPropertyCount(); }
@Override public long getPropertyCount() { return state.getPropertyCount(); }
@Override public long getPropertyCount() { return getWrappedNodeState().getPropertyCount(); }
static long getPropertyCount( NodeState base, Map<String, PropertyState> properties) { long count = 0; if (base.exists()) { count = base.getPropertyCount(); for (Entry<String, PropertyState> entry : properties.entrySet()) { if (base.hasProperty(entry.getKey())) { count--; } if (entry.getValue() != null) { count++; } } } return count; }
static long getPropertyCount( NodeState base, Map<String, PropertyState> properties) { long count = 0; if (base.exists()) { count = base.getPropertyCount(); for (Entry<String, PropertyState> entry : properties.entrySet()) { if (base.hasProperty(entry.getKey())) { count--; } if (entry.getValue() != null) { count++; } } } return count; }
public boolean equals(Object object) { if (object == EMPTY_NODE || object == MISSING_NODE) { return exists == (object == EMPTY_NODE); } else if (object instanceof NodeState) { NodeState that = (NodeState) object; return that.getPropertyCount() == 0 && that.getChildNodeCount(1) == 0 && (exists == that.exists()); } else { return false; } }
public boolean equals(Object object) { if (object == EMPTY_NODE || object == MISSING_NODE) { return exists == (object == EMPTY_NODE); } else if (object instanceof NodeState) { NodeState that = (NodeState) object; return that.getPropertyCount() == 0 && that.getChildNodeCount(1) == 0 && (exists == that.exists()); } else { return false; } }
@Override public long getPropertyCount() { return head().getCurrentNodeState().getPropertyCount(); }
@Override public long getPropertyCount() { return head().getCurrentNodeState().getPropertyCount(); }
protected final PropertyState chooseRandomProperty(NodeState node) { int count = (int) node.getPropertyCount(); if (count > 0) { return get(node.getProperties(), rnd.nextInt(count)); } else { return null; } } }
@Override public synchronized long getPropertyCount() { if (propertyCount == -1) { if (treePermission.canReadProperties()) { propertyCount = state.getPropertyCount(); } else { propertyCount = count(filter( state.getProperties(), new ReadablePropertyPredicate())); } } return propertyCount; }
@Test public void testGetPropertyCount() { assertEquals(3 + initialCount, state.getPropertyCount()); }
@Override public synchronized long getPropertyCount() { if (propertyCount == -1) { if (treePermission.canReadProperties()) { propertyCount = state.getPropertyCount(); } else { propertyCount = count(filter( state.getProperties(), new ReadablePropertyPredicate())); } } return propertyCount; }
@Override public synchronized long getPropertyCount() { if (propertyCount == -1) { if (treePermission.canReadProperties()) { propertyCount = state.getPropertyCount(); } else { propertyCount = count(filter( state.getProperties(), new ReadablePropertyPredicate())); } } return propertyCount; }
@Test public void shouldDelegatePropertyCount() { final NodeState decorated = wrap("/", rootNodeState, null, of("/content/foo/de"), null, null); assertEquals(1, getNodeState(decorated, "/content").getPropertyCount()); assertEquals(0, getNodeState(decorated, "/content/foo").getPropertyCount()); }
private static NodeState getBase(Context context) { RecordId id = getLastCompactedRootId(context); if (RecordId.NULL.equals(id)) { return null; } // Nodes are read lazily. In order to force a read operation for the requested // node, the property count is computed. Computing the property count requires // access to the node template, whose ID is stored in the content of the node. // Accessing the content of the node forces a read operation for the segment // containing the node. If the following code completes without throwing a // SNFE, we can be sure that *at least* the root node can be accessed. This // doesn't say anything about the health of the full closure of the head // state. try { NodeState node = getLastCompactedRootNode(context); node.getPropertyCount(); return node; } catch (SegmentNotFoundException e) { context.getGCListener().error("base state " + id + " is not accessible", e); return null; } }
@Test public void setChildNodeInRootStore() throws Exception { NodeBuilder builder = store.getRoot().builder(); builder.setChildNode("apps"); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertTrue("Node apps must still exist", store.getRoot().hasChildNode("apps")); assertThat("Node apps must not have any properties", store.getRoot().getChildNode("apps").getPropertyCount(), equalTo(0l)); }
@Test public void propertyCount() throws Exception{ DocumentNodeStore store = builderProvider.newBuilder().getNodeStore(); NodeBuilder builder = store.getRoot().builder(); builder.child("a").setProperty("x", 1); builder.child("a").setProperty("y", 1); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); NodeState ns = store.getRoot().getChildNode("a"); assertEquals(2, ns.getPropertyCount()); }
@Before public void setUp() throws CommitFailedException { NodeState root = store.getRoot(); initialCount = root.getPropertyCount(); NodeBuilder builder = store.getRoot().builder(); builder.setProperty("a", 1); builder.setProperty("b", 2); builder.setProperty("c", 3); builder.child("x"); builder.child("y"); builder.child("z"); state = store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); state = store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); }
@Test public void saveAndReadNtFile() throws Exception{ NodeBuilder builder = store.getRoot().builder(); NodeBuilder fileNode = newNode("nt:file"); fileNode.child("jcr:content").setProperty("jcr:data", "foo"); builder.child("test").setChildNode("book.jpg", fileNode.getNodeState()); merge(builder); NodeState root = store.getRoot(); NodeState fileNodeState = root.getChildNode("test"); assertTrue(fileNodeState.getChildNode("book.jpg").exists()); NodeState contentNode = fileNodeState.getChildNode("book.jpg").getChildNode("jcr:content"); assertTrue(contentNode.exists()); assertEquals("jcr:content", getBundlingPath(contentNode)); assertEquals(1, contentNode.getPropertyCount()); assertEquals(1, Iterables.size(contentNode.getProperties())); assertNull(getNodeDocument("/test/book.jpg/jcr:content")); assertNotNull(getNodeDocument("/test/book.jpg")); assertTrue(hasNodeProperty("/test/book.jpg", concat("jcr:content", DocumentBundlor.META_PROP_BUNDLING_PATH))); AssertingDiff.assertEquals(fileNode.getNodeState(), fileNodeState.getChildNode("book.jpg")); DocumentNodeState dns = asDocumentState(fileNodeState.getChildNode("book.jpg")); AssertingDiff.assertEquals(fileNode.getNodeState(), dns.withRootRevision(dns.getRootRevision(), true)); AssertingDiff.assertEquals(fileNode.getNodeState(), dns.fromExternalChange()); }