Search in sources :

Example 6 with PropertyState

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

the class DocumentBundlorTest method asPropertyState.

@Test
public void asPropertyState() throws Exception {
    builder.setProperty(createProperty(PROP_PATTERN, asList("x", "x/y", "z"), STRINGS));
    DocumentBundlor bundlor = DocumentBundlor.from(builder.getNodeState());
    PropertyState ps = bundlor.asPropertyState();
    assertNotNull(ps);
    DocumentBundlor bundlor2 = DocumentBundlor.from(ps);
    assertTrue(bundlor2.isBundled("x"));
    assertTrue(bundlor2.isBundled("x/y"));
    assertFalse(bundlor2.isBundled("m"));
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 7 with PropertyState

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

the class DocumentBundlingTest method journalDiffAndBundling.

@Test
public void journalDiffAndBundling() throws Exception {
    NodeBuilder builder = store.getRoot().builder();
    NodeBuilder fileNode = newNode("nt:file");
    fileNode.child("jcr:content").setProperty("jcr:data", "foo");
    builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
    NodeState r1 = merge(builder);
    builder = store.getRoot().builder();
    childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("fooContent", "bar");
    childBuilder(builder, "/test/book.jpg").setProperty("fooBook", "bar");
    NodeState r2 = merge(builder);
    final List<String> addedPropertyNames = Lists.newArrayList();
    r2.compareAgainstBaseState(r1, new DefaultNodeStateDiff() {

        @Override
        public boolean propertyAdded(PropertyState after) {
            addedPropertyNames.add(after.getName());
            return super.propertyAdded(after);
        }

        @Override
        public boolean childNodeChanged(String name, NodeState before, NodeState after) {
            return after.compareAgainstBaseState(before, this);
        }
    });
    assertTrue("No change reported for /test/book.jpg", addedPropertyNames.contains("fooBook"));
    assertTrue("No change reported for /test/book.jpg/jcr:content", addedPropertyNames.contains("fooContent"));
}
Also used : DocumentNodeState(org.apache.jackrabbit.oak.plugins.document.DocumentNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractNodeState(org.apache.jackrabbit.oak.spi.state.AbstractNodeState) DefaultNodeStateDiff(org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 8 with PropertyState

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

the class AllPermissionsTest method testIsGranted.

@Test
public void testIsGranted() {
    for (String path : paths) {
        Tree tree = RootFactory.createReadOnlyRoot(root).getTree(path);
        assertTrue(tree.exists());
        assertTrue(all.isGranted(tree, null, Permissions.ALL));
        for (PropertyState prop : tree.getProperties()) {
            assertTrue(all.isGranted(tree, prop, Permissions.ALL));
        }
        for (Tree child : tree.getChildren()) {
            assertTrue(all.isGranted(child, null, Permissions.ALL));
        }
    }
}
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 9 with PropertyState

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

the class EmptyCugTreePermissionTest method testIsGrantedProperty.

@Test
public void testIsGrantedProperty() {
    PropertyState ps = PropertyStates.createProperty("prop", "val");
    assertFalse(tp.isGranted(Permissions.ALL, ps));
    assertFalse(tp.isGranted(Permissions.WRITE, ps));
    assertFalse(tp.isGranted(Permissions.READ, ps));
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 10 with PropertyState

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

the class DocumentPropertyState method size.

@Override
public long size(int index) {
    long size;
    PropertyState parsed = parsed();
    if (parsed.getType() == Type.BINARIES) {
        size = parsed.getValue(Type.BINARY, index).length();
    } else {
        size = parsed.size(index);
    }
    return size;
}
Also used : StringPropertyState(org.apache.jackrabbit.oak.plugins.memory.StringPropertyState) LongPropertyState(org.apache.jackrabbit.oak.plugins.memory.LongPropertyState) BooleanPropertyState(org.apache.jackrabbit.oak.plugins.memory.BooleanPropertyState) AbstractPropertyState(org.apache.jackrabbit.oak.plugins.memory.AbstractPropertyState) BinaryPropertyState(org.apache.jackrabbit.oak.plugins.memory.BinaryPropertyState) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) DoublePropertyState(org.apache.jackrabbit.oak.plugins.memory.DoublePropertyState)

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