Search in sources :

Example 66 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class TreeUtilTest method testJcrCreatedByNullUserId.

@Test
public void testJcrCreatedByNullUserId() throws Exception {
    Tree tree = TreeUtil.addChild(root.getTree("/"), "test", JcrConstants.NT_FOLDER, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), null);
    PropertyState ps = tree.getProperty(NodeTypeConstants.JCR_CREATEDBY);
    assertNotNull(ps);
    assertEquals("", ps.getValue(Type.STRING));
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 67 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class PropertyStatesTest method pathPropertyFromPathValue.

@Test
public void pathPropertyFromPathValue() throws RepositoryException {
    PropertyState pathProperty = PropertyStates.createProperty("path", "oak-prefix:a/oak-prefix:b", PropertyType.PATH);
    Value nameValue = ValueFactoryImpl.createValue(pathProperty, namePathMapper);
    PropertyState namePropertyFromValue = PropertyStates.createProperty("path", nameValue);
    assertEquals(pathProperty, namePropertyFromValue);
}
Also used : Value(javax.jcr.Value) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 68 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class CugContext method definesLocation.

@Override
public boolean definesLocation(@Nonnull TreeLocation location) {
    PropertyState p = location.getProperty();
    Tree tree = (p == null) ? location.getTree() : location.getParent().getTree();
    if (tree != null) {
        return (p == null) ? definesTree(tree) : definesProperty(tree, p);
    } else {
        String path = location.getPath();
        return REP_CUG_POLICY.equals(Text.getName(path)) || path.endsWith(REP_CUG_POLICY + '/' + REP_PRINCIPAL_NAMES);
    }
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 69 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class TopLevelPaths method contains.

boolean contains(@Nonnull String path) {
    if (!hasAny()) {
        return false;
    }
    if (PathUtils.denotesRoot(path)) {
        return true;
    }
    if (cnt == null) {
        Tree rootTree = root.getTree(PathUtils.ROOT_PATH);
        PropertyState hiddenTopCnt = rootTree.getProperty(HIDDEN_TOP_CUG_CNT);
        if (hiddenTopCnt != null) {
            cnt = hiddenTopCnt.getValue(Type.LONG);
            if (cnt <= MAX_CNT) {
                PropertyState hidden = root.getTree(PathUtils.ROOT_PATH).getProperty(HIDDEN_NESTED_CUGS);
                paths = (hidden == null) ? new String[0] : Iterables.toArray(hidden.getValue(Type.STRINGS), String.class);
            } else {
                paths = null;
            }
        } else {
            cnt = NONE;
        }
    }
    if (cnt == NONE) {
        return false;
    }
    if (cnt > MAX_CNT) {
        return true;
    } else if (paths != null) {
        for (String p : paths) {
            if (Text.isDescendantOrEqual(path, p)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 70 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class DynamicSyncContextTest method testSyncExternalUserDepth1.

@Test
public void testSyncExternalUserDepth1() throws Exception {
    syncConfig.user().setMembershipNestingDepth(1);
    ExternalUser externalUser = idp.getUser(USER_ID);
    sync(externalUser, SyncResult.Status.ADD);
    Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath());
    PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
    assertNotNull(extPrincipalNames);
    Set<String> pNames = Sets.newHashSet(extPrincipalNames.getValue(Type.STRINGS));
    for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
        assertTrue(pNames.remove(idp.getIdentity(ref).getPrincipalName()));
    }
    assertTrue(pNames.isEmpty());
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)404 Test (org.junit.Test)189 Tree (org.apache.jackrabbit.oak.api.Tree)138 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)49 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)45 Nonnull (javax.annotation.Nonnull)31 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)29 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)28 Blob (org.apache.jackrabbit.oak.api.Blob)21 ArrayList (java.util.ArrayList)20 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)17 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)16 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)13 CheckForNull (javax.annotation.CheckForNull)12 RepositoryException (javax.jcr.RepositoryException)10 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 Map (java.util.Map)9 Value (javax.jcr.Value)9