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

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

            }
        } else {
            // 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 pImpl = (PropertyImpl) property;
                    NodeImpl n = (NodeImpl) pImpl.getParent();
                    if (P_MEMBERS.equals(pImpl.getQName()) && n.isNodeType(NT_REP_GROUP)) {
                        for (Value value : property.getValues()) {
                            if (value.getString().equals(node.getIdentifier())) {
                                Group gr = (Group) userManager.getAuthorizable(n);
                                groups.add(gr);
                            }
                        }
                    }
                }
            };
            Node groupsNode = getSession().getNode(userManager.getGroupsPath());
            visitor.visit(groupsNode);
        }
    }
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

     * 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<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
                ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
                    @Override
                    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);
                        }
                    }
                    @Override
                    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);
                        }
                    }
                    @Override
                    protected void leaving(Property property, int i) {
                        // nothing to do
                    }
                    @Override
                    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

    @Override
    protected void beforeSuite() throws Exception {
        super.beforeSuite();

        ItemVisitor visitor = new TraversingItemVisitor.Default() {
            int counter = 0;
            @Override
            protected void entering(Node node, int level) throws RepositoryException {
                if (++counter == 10) {
                    addPolicy(node);
                    counter = 0;
                }
                super.entering(node, level);
            }

            private void addPolicy(Node node) throws RepositoryException {
                AccessControlManager acMgr = node.getSession().getAccessControlManager();
                String path = node.getPath();
                AccessControlPolicyIterator acIterator = acMgr.getApplicablePolicies(path);
                if (acIterator.hasNext()) {
                    AccessControlPolicy policy = acIterator.nextAccessControlPolicy();
                    if (policy instanceof AccessControlList) {
                        AccessControlList acl = (AccessControlList) policy;
                        Privilege[] privileges = new Privilege[] {
                                acMgr.privilegeFromName(Privilege.JCR_READ),
                                acMgr.privilegeFromName(Privilege.JCR_READ_ACCESS_CONTROL)
                        };
                        if (acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privileges)) {
                            acMgr.setPolicy(path, acl);
                            node.getSession().save();
                        }
                    }
                }
            }
        };

        visitor.visit(testRoot);

        for (int i = 0; i < bgReaders; i++) {
            addBackgroundJob(new RandomRead(loginReader(), false));
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

        } else {
            testRoot = rn.getNode(name);
        }

        final List<String> paths = new ArrayList<String>();
        ItemVisitor v = new TraversingItemVisitor.Default() {
            @Override
            protected void entering(Node node, int i) throws RepositoryException {
                paths.add(node.getPath());
                super.entering(node, i);
            }
            @Override
            protected void entering(Property prop, int i) throws RepositoryException {
                paths.add(prop.getPath());
                super.entering(prop, i);
            }
        };
        v.visit(testRoot);
        allPaths = paths;

        System.out.println("All paths: " + allPaths.size());
    }
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
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.