@Override public long getSize() { return iterator.getSize(); }
public long getSize() { return this.propertyIterator.getSize(); }
@Override public int size() { try { return (int) (content.getProperties().getSize() + specialProperties.size()); } catch (RepositoryException e) { // ignore ... no rights to read properties. } return specialProperties.size(); }
public long getSize() { return getDelegate().getSize(); }
/** * Returns a {@link SizedIterator} of the properties of <code>node</code> * which excludes the <code>jcr.primaryType</code> property. */ @SuppressWarnings("deprecation") protected SizedIterator<Property> getProperties(Node node) throws RepositoryException { final PropertyIterator properties = node.getProperties(); long size = properties.getSize(); for (Iterator<String> ignored = ignoredProperties.iterator(); size > 0 && ignored.hasNext(); ) { if (node.hasProperty(ignored.next())) { size--; } } return getSizedIterator(filterProperties(convert(properties)), size); }
private static boolean hasConfigurationProperties(final Session session) throws RepositoryException { final boolean oldConfigLocationExists = session.nodeExists(OLD_CODECS_CONFIGURATION_LOCATION); if (oldConfigLocationExists) { final Node node = session.getNode(OLD_CODECS_CONFIGURATION_LOCATION); return node.hasProperty(DISPLAY_CONFIGURATION_PARAMETER) || node.getProperties(NODE_CONFIGURATION_PARAMETER_PATTERN).getSize() > 0; } return false; }
Node child = cl.addNode("ONE"); child.setProperty("message", ("CL Child" + i)); session.save(); PropertyIterator iter = child.getProperties(); System.out.println("Size" + iter.getSize()); while (iter.hasNext()) { PropertyImpl key = (PropertyImpl) iter.next(); String value = key.getString(); System.out.println("------------->" + key); System.out.println("------------->" + value); }
public long size() { long result = 0; try { if (nodeModel.getObject() != null) { PropertyIterator it = nodeModel.getObject().getProperties(); result = it.getSize(); // result = result - 1; // For jcr:primaryType // result = nodeModel.getNode().hasProperty("jcr:mixinTypes") ? result -1 : result; } } catch (RepositoryException e) { log.error(e.getMessage()); } return result; }
public int size() { int result = 0; try { if (nodeModel.getObject() != null) { PropertyIterator it = nodeModel.getObject().getProperties(); result = (int) it.getSize(); // result = result - 1; // For jcr:primaryType // result = nodeModel.getNode().hasProperty("jcr:mixinTypes") ? result -1 : result; } } catch (RepositoryException e) { log.error(e.getMessage()); } return result; }
@Test public void shouldHaveSizeOfZero() { assertThat(iter.getSize(), is(0L)); }
@Override public void run(Node node) throws Exception { if (node.getPath().equals("/")) { return; } totalCount.incrementAndGet(); // the backup created 7 properties per node + the primary type PropertyIterator properties = node.getProperties(); assertEquals(8, properties.getSize()); while (properties.hasNext()) { assertNotNull(properties.nextProperty().getString()); } } });
@Test public void testGivesPropertyUniqueName() throws Exception { // GIVEN Node root = session.getRootNode(); Node node = root.addNode(NODE_NAME); node.setProperty(UNTITLED_PROPERTY_NAME, UNTITLED_PROPERTY_VALUE); long propertyCountBefore = node.getProperties().getSize(); AddPropertyAction action = new AddPropertyAction(definition, new JcrNodeAdapter(node), eventBus); // WHEN action.execute(); // THEN assertTrue(node.hasProperty(AbstractRepositoryAction.DEFAULT_NEW_ITEM_NAME)); assertAddedNewProperty(node, propertyCountBefore, AbstractRepositoryAction.DEFAULT_NEW_ITEM_NAME + "0"); }
@Test public void testCanAddPropertyOnNode() throws Exception { // GIVEN Node root = session.getRootNode(); Node node = root.addNode(NODE_NAME); long propertyCountBefore = node.getProperties().getSize(); AddPropertyAction action = new AddPropertyAction(definition, new JcrNodeAdapter(node), eventBus); // WHEN action.execute(); // THEN assertAddedNewProperty(node, propertyCountBefore, AbstractRepositoryAction.DEFAULT_NEW_ITEM_NAME); }
@Test public void testPropertiesCanBeOverriden() throws IOException, RepositoryException { // GIVEN session = SessionTestUtil.createSession("test", "/bla/bla.prop1=default\n" + "/impl/node.prop1=new\n" + "/impl/node.extends=../../bla/bla\n" ); Node plainNode = session.getNode("impl/node"); // WHEN Node extendedNode = new ExtendingNodeWrapper(plainNode); // THEN assertEquals("new", extendedNode.getProperty("prop1").getString()); assertEquals(1, extendedNode.getProperties().getSize()); }
@Test public void testCanAddPropertyToRootNode() throws Exception { // GIVEN Node root = session.getRootNode(); long propertyCountBefore = root.getProperties().getSize(); AddPropertyAction action = new AddPropertyAction(definition, new JcrNodeAdapter(root), eventBus); // WHEN action.execute(); // THEN assertAddedNewProperty(root, propertyCountBefore, AbstractRepositoryAction.DEFAULT_NEW_ITEM_NAME); }
public void testGetDeepProperty() throws RepositoryException { Node n2 = testRootNode.getNode(nodeName1).addNode(nodeName2); testRootNode.save(); // other session directly accesses n2. // consequently n1 is not yet resolved Node node2 = (Node) readOnly.getItem(n2.getPath()); // now try to access properties below n1 -> should be existing although // n1 has not yet been resolved. assertTrue(readOnly.itemExists(prop1Path)); Property p1 = (Property) readOnly.getItem(prop1Path); assertTrue(p1.isSame(node2.getProperty("../" + Text.getName(prop1Path)))); PropertyIterator it = node2.getParent().getProperties(); assertTrue(it.getSize() >= 3); }
private void assertAddedNewProperty(Node root, long propertyCountBefore, String newPropertyName) throws RepositoryException { // no LUD wrapping on test assertEquals(propertyCountBefore + 1, root.getProperties().getSize()); assertTrue(root.hasProperty(newPropertyName)); // assertTrue(root.hasProperty(NodeTypes.LastModified.LAST_MODIFIED)); // assertTrue(root.hasProperty(NodeTypes.LastModified.LAST_MODIFIED_BY)); assertFalse(eventBus.isEmpty()); JcrItemId itemId = (JcrItemId)((ContentChangedEvent) eventBus.getEvent()).getItemId(); assertTrue(itemId.getUuid().equals(root.getIdentifier())); } }
@Test public void testPropertyIteratorReturnsWrappedProperty() throws Exception { MockNode node = new MockNode(); node.setProperty("text", "<html/>"); HTMLEscapingNodeWrapper wrapper = new HTMLEscapingNodeWrapper(node, false); PropertyIterator properties = wrapper.getProperties(); assertEquals(1, properties.getSize()); Property property = properties.nextProperty(); assertTrue(property instanceof HTMLEscapingPropertyWrapper); assertEquals("<html/>", property.getString()); }
@Test public void testGetPropertiesByPattern() throws Exception { // GIVEN final MockNode node = new MockNode("test"); node.setProperty("prop", "val"); // WHEN PropertyIterator it = node.getProperties(new String[]{"p*"}); // THEN Property property = it.nextProperty(); assertEquals(1, it.getSize()); assertEquals("prop", property.getName()); assertEquals("val", property.getString()); }