Examples of ItemVisitor


Examples of javax.jcr.ItemVisitor

     *
     */
    public void testAccept() throws RepositoryException {
        final Node n = testRootNode;

        ItemVisitor itemVisitor = new ItemVisitor() {
            public void visit(Property property) {
                fail("Wrong accept method executed.");
            }

            public void visit(Node node) throws RepositoryException {
View Full Code Here

Examples of javax.jcr.ItemVisitor

                throw new RepositoryException(e);
            }
            return Collections.singletonList(info).iterator();
        } else {
            final List itemInfos = new ArrayList();
            ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
                protected void entering(Property property, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                protected void entering(Node node, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                protected void leaving(Property property, int i) {
                    // nothing to do
                }
                protected void leaving(Node node, int i) {
                    // nothing to do
                }
            };
            visitor.visit(node);
            return itemInfos.iterator();
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

                throw new RepositoryException(e);
            }
            return Collections.singletonList(info).iterator();
        } else {
            final List itemInfos = new ArrayList();
            ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
                protected void entering(Property property, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                protected void entering(Node node, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                protected void leaving(Property property, int i) {
                    // nothing to do
                }
                protected void leaving(Node node, int i) {
                    // nothing to do
                }
            };
            visitor.visit(node);
            return itemInfos.iterator();
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

        acl.addEntry(EveryonePrincipal.getInstance(), privileges, false);
        acMgr.setPolicy(root.getPath(), acl);
        session.save();

        final int[] numACEs = new int[1];
        ItemVisitor v = new TraversingItemVisitor.Default() {
            @Override
            protected void entering(Node node, int i) throws RepositoryException {
                if (node.isNodeType(AccessControlConstants.NT_REP_ACE)) {
                    numACEs[0]++;
                }
                super.entering(node, i);
            }
            @Override
            protected void entering(Property prop, int i) throws RepositoryException {
                super.entering(prop, i);
            }
        };
        v.visit(root);
        System.out.println("Num ACEs: " + numACEs[0]);

        session.logout();
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

        final Set<String> nIds = new HashSet<String>();

        // workaround for failure of Node#getWeakReferences
        // traverse the tree below groups-path and collect membership manually.
        log.info("Traversing groups tree to collect membership.");
        ItemVisitor visitor = new TraversingItemVisitor.Default() {
            @Override
            protected void entering(Property property, int level) throws RepositoryException {
                PropertyImpl pMember = (PropertyImpl) property;
                NodeImpl nGroup = (NodeImpl) pMember.getParent();
                if (P_MEMBERS.equals(pMember.getQName()) && nGroup.isNodeType(NT_REP_GROUP)) {
                    // Found membership information in members property
                    for (Value value : property.getValues()) {
                        String v = value.getString();
                        if (v.equals(authorizableNodeIdentifier)) {
                            pIds.add(nGroup.getIdentifier());
                        }
                    }
                } else {
                    // Found membership information in members node
                    while (nGroup.isNodeType(NT_REP_MEMBERS)) {
                        nGroup = (NodeImpl) nGroup.getParent();
                    }

                    if (nGroup.isNodeType(NT_REP_GROUP) && !NameConstants.JCR_UUID.equals(pMember.getQName())) {
                        String v = pMember.getString();
                        if (v.equals(authorizableNodeIdentifier)) {
                            nIds.add(nGroup.getIdentifier());
                        }
                    }
                }
            }
        };

        if (session.nodeExists(groupsPath)) {
            Node groupsNode = session.getNode(groupsPath);
            visitor.visit(groupsNode);
        } // else: no groups exist -> nothing to do.

        // Based on the user's setting return either of the found membership information
        return select(pIds, nIds);
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

     * Test for <a href="https://issues.apache.org/jira/browse/JCR-1964">JCR-1964</a>
     *
     * @throws javax.jcr.RepositoryException If an exception occurs.
     */
    public void testDefaultValues() throws RepositoryException {
        ItemVisitor visitor = new TraversingItemVisitor.Default() {

            public void visit(Property property) throws RepositoryException {
                if (JcrConstants.JCR_DEFAULTVALUES.equals(property.getName())) {
                    int type = property.getType();
                    Value[] vs = property.getValues();
                    for (int i = 0; i < vs.length; i++) {
                        assertEquals("Property type must match the value(s) type", type, vs[i].getType());
                    }
                }
            }
        };

        Node start = (Node) superuser.getItem("/jcr:system/jcr:nodeTypes");
        visitor.visit(start);
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

                throw new RepositoryException(e);
            }
            return Collections.singletonList(info).iterator();
        } else {
            final List itemInfos = new ArrayList();
            ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
                protected void entering(Property property, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                protected void entering(Node node, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                protected void leaving(Property property, int i) {
                    // nothing to do
                }
                protected void leaving(Node node, int i) {
                    // nothing to do
                }
            };
            visitor.visit(node);
            return itemInfos.iterator();
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

      contentNode.setProperty("jcr:mimeType", session.getValueFactory().createValue("text/html"));
      contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));

      session.save();

      ItemVisitor visitor = new MockVisitor();
      contentNode.accept(visitor);
      contentNode.getProperty("jcr:data").accept(visitor);

      visitor = new MockVisitor2();
      root.getNode("childNode").accept(visitor);
View Full Code Here

Examples of javax.jcr.ItemVisitor

        assertThat(prius2, is(notNullValue()));
    }

    @Test
    public void shouldAllowVisitation() throws Exception {
        ItemVisitor visitor = Mockito.mock(ItemVisitor.class);
        altimaModel.accept(visitor);
        Mockito.verify(visitor).visit(altimaModel);
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

     * Visitors
     */

    @Test
    public void shouldAllowVisitation() throws Exception {
        ItemVisitor visitor = Mockito.mock(ItemVisitor.class);
        hybrid.accept(visitor);
        Mockito.verify(visitor).visit(hybrid);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.