Package org.apache.jackrabbit.oak.util

Examples of org.apache.jackrabbit.oak.util.NodeUtil


        }
    }

    @Test
    public void testInvalidRestriction() throws Exception {
        NodeUtil restriction = createAcl().getChild(aceName).getChild(REP_RESTRICTIONS);
        restriction.setString("invalid", "value");
        try {
            root.commit();
            fail("Creating an unsupported restriction should fail.");
        } catch (CommitFailedException e) {
            // success
View Full Code Here


        }
    }

    @Test
    public void testRestrictionWithInvalidType() throws Exception {
        NodeUtil restriction = createAcl().getChild(aceName).getChild(REP_RESTRICTIONS);
        restriction.setName(REP_GLOB, "rep:glob");
        try {
            root.commit();
            fail("Creating restriction with invalid type should fail.");
        } catch (CommitFailedException e) {
            // success
View Full Code Here

        JackrabbitAccessControlList acl = org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils.getAccessControlList(acMgr, testPath);
        acl.addAccessControlEntry(testPrincipal, privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES));
        acMgr.setPolicy(testPath, acl);

        // add duplicate ac-entry on OAK-API
        NodeUtil policy = new NodeUtil(root.getTree(testPath + "/rep:policy"));
        NodeUtil ace = policy.addChild("duplicateAce", NT_REP_GRANT_ACE);
        ace.setString(REP_PRINCIPAL_NAME, testPrincipal.getName());
        ace.setStrings(AccessControlConstants.REP_PRIVILEGES, PrivilegeConstants.JCR_ADD_CHILD_NODES);

        try {
            root.commit();
            fail("Creating duplicate ACE must be detected");
        } catch (CommitFailedException e) {
View Full Code Here

        Map<PropertyState, RestrictionPattern> map = newHashMap();
        map.put(PropertyStates.createProperty(REP_GLOB, "/*/jcr:content"), GlobPattern.create("/testPath", "/*/jcr:content"));
        List<String> ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE);
        map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames));

        NodeUtil tree = new NodeUtil(root.getTree("/")).getOrAddTree("testPath", JcrConstants.NT_UNSTRUCTURED);
        Tree restrictions = tree.addChild("restrictions", NT_REP_RESTRICTIONS).getTree();

        // test restrictions individually
        for (Map.Entry<PropertyState, RestrictionPattern> entry : map.entrySet()) {
            restrictions.setProperty(entry.getKey());

View Full Code Here

            super.after();
        }
    }

    private Tree getAceTree(Restriction... restrictions) throws Exception {
        NodeUtil rootNode = new NodeUtil(root.getTree("/"));
        NodeUtil tmp = rootNode.addChild("testRoot", JcrConstants.NT_UNSTRUCTURED);
        Tree ace = tmp.addChild("rep:policy", NT_REP_ACL).addChild("ace0", NT_REP_GRANT_ACE).getTree();
        restrictionProvider.writeRestrictions(tmp.getTree().getPath(), ace, ImmutableSet.copyOf(restrictions));
        return ace;
    }
View Full Code Here

    @Test
    public void testValidateRestrictionsWrongType() throws Exception {
        Restriction mand = restrictionProvider.createRestriction(testPath, "mandatory", valueFactory.createValue(true));
        try {
            Tree ace = getAceTree(mand);
            new NodeUtil(ace).getChild(REP_RESTRICTIONS).setBoolean(REP_GLOB, true);

            restrictionProvider.validateRestrictions(testPath, ace);
            fail("wrong type with restriction 'rep:glob");
        } catch (AccessControlException e) {
            // success
View Full Code Here

    @Test
    public void testValidateRestrictionsUnsupportedRestriction() throws Exception {
        Restriction mand = restrictionProvider.createRestriction(testPath, "mandatory", valueFactory.createValue(true));
        try {
            Tree ace = getAceTree(mand);
            new NodeUtil(ace).getChild(REP_RESTRICTIONS).setString("Unsupported", "value");

            restrictionProvider.validateRestrictions(testPath, ace);
            fail("wrong type with restriction 'rep:glob");
        } catch (AccessControlException e) {
            // success
View Full Code Here

        return addMember(groupTree, newMemberTree.getName(), getContentID(newMemberTree));
    }

    boolean addMember(Tree groupTree, String treeName, String memberContentId) throws RepositoryException {
        if (useMemberNode(groupTree)) {
            NodeUtil groupNode = new NodeUtil(groupTree);
            NodeUtil membersNode = groupNode.getOrAddChild(REP_MEMBERS, NT_REP_MEMBERS);
            // TODO OAK-482: add implementation that allows to index group members
            throw new UnsupportedOperationException("not implemented: addMember with member-node hierarchy");
        } else {
            PropertyBuilder<String> propertyBuilder = getMembersPropertyBuilder(groupTree);
            if (propertyBuilder.hasValue(memberContentId)) {
View Full Code Here

    public void before() throws Exception {
        super.before();

        testPrincipal = getTestUser().getPrincipal();

        NodeUtil rootNode = new NodeUtil(root.getTree("/"));
        NodeUtil a = rootNode.addChild("a", NT_UNSTRUCTURED);
        a.setString("aProp", "aValue");

        NodeUtil b = a.addChild("b", NT_UNSTRUCTURED);
        b.setString("bProp", "bValue");
        // sibling
        NodeUtil bb = a.addChild("bb", NT_UNSTRUCTURED);
        bb.setString("bbProp", "bbValue");

        NodeUtil c = b.addChild("c", NT_UNSTRUCTURED);
        c.setString("cProp", "cValue");
        root.commit();
    }
View Full Code Here

        UserConfiguration userConfiguration = securityProvider.getConfiguration(UserConfiguration.class);
        UserManager userManager = userConfiguration.getUserManager(root, NamePathMapper.DEFAULT);

        String errorMsg = "Failed to initialize user content.";
        try {
            NodeUtil rootTree = checkNotNull(new NodeUtil(root.getTree("/")));
            NodeUtil index = rootTree.getOrAddChild(IndexConstants.INDEX_DEFINITIONS_NAME, JcrConstants.NT_UNSTRUCTURED);

            if (!index.hasChild("authorizableId")) {
                IndexUtils.createIndexDefinition(index, "authorizableId", true, new String[]{REP_AUTHORIZABLE_ID}, null);
            }
            if (!index.hasChild("principalName")) {
                IndexUtils.createIndexDefinition(index, "principalName", true,
                        new String[]{REP_PRINCIPAL_NAME},
                        new String[]{NT_REP_AUTHORIZABLE});
            }
            if (!index.hasChild("members")) {
                IndexUtils.createIndexDefinition(index, "members", false, new String[]{UserConstants.REP_MEMBERS}, null);
            }

            ConfigurationParameters params = userConfiguration.getParameters();
            String adminId = params.getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.util.NodeUtil

Copyright © 2018 www.massapicom. 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.