Examples of ItemVisitor


Examples of javax.jcr.ItemVisitor

     * ItemVisitor}.
     */
    public void testAccept() throws RepositoryException {
        final Property p = property;

        ItemVisitor itemVisitor = new ItemVisitor() {
            public void visit(Property property)
                    throws RepositoryException {
                assertTrue("Visited Property is not the same as the one returned by visit(Property).",
                        p.isSame(property));
            }
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

                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 (org.apache.jackrabbit.spi.commons.conversion.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 (org.apache.jackrabbit.spi.commons.conversion.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

     *
     */
    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

     * ItemVisitor}.
     */
    public void testAccept() throws RepositoryException {
        final Property p = property;

        ItemVisitor itemVisitor = new ItemVisitor() {
            public void visit(Property property)
                    throws RepositoryException {
                assertTrue("Visited Property is not the same as the one returned by visit(Property).",
                        p.isSame(property));
            }
View Full Code Here

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

     * 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

     * ItemVisitor}.
     */
    public void testAccept() throws RepositoryException {
        final Property p = property;

        ItemVisitor itemVisitor = new ItemVisitor() {
            public void visit(Property property)
                    throws RepositoryException {
                assertTrue("Visited Property is not the same as the one returned by visit(Property).",
                        p.isSame(property));
            }
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.