Search in sources :

Example 11 with EditorHook

use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.

the class TypeEditorTest method changeNamedPropertyToBadRequiredType.

@Test
public void changeNamedPropertyToBadRequiredType() {
    EditorHook hook = new EditorHook(new TypeEditorProvider());
    NodeState root = INITIAL_CONTENT;
    NodeBuilder builder = root.builder();
    NodeBuilder testNode = builder.child("testNode");
    testNode.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME);
    testNode.setProperty(JCR_MIXINTYPES, ImmutableList.of("mix:title"), Type.NAMES);
    testNode.setProperty("jcr:title", "title");
    NodeState before = builder.getNodeState();
    testNode.setProperty("jcr:title", true);
    try {
        hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
        fail();
    } catch (CommitFailedException e) {
        assertTrue(e.isConstraintViolation());
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Example 12 with EditorHook

use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.

the class TypeEditorTest method changeMandatoryPropertyToBadRequiredType.

@Test
public void changeMandatoryPropertyToBadRequiredType() {
    EditorHook hook = new EditorHook(new TypeEditorProvider());
    NodeState root = INITIAL_CONTENT;
    NodeBuilder builder = root.builder();
    NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
    acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
    NodeBuilder ace = acl.child("first");
    ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
    ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
    ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.NAMES);
    NodeState before = builder.getNodeState();
    // change to invalid type
    ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
    try {
        hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
        fail();
    } catch (CommitFailedException e) {
        assertTrue(e.isConstraintViolation());
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Example 13 with EditorHook

use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.

the class TypeEditorTest method addMandatoryPropertyWithBadRequiredType.

@Test
public void addMandatoryPropertyWithBadRequiredType() {
    EditorHook hook = new EditorHook(new TypeEditorProvider());
    NodeState root = INITIAL_CONTENT;
    NodeBuilder builder = root.builder();
    NodeState before = builder.getNodeState();
    NodeBuilder acl = builder.child(AccessControlConstants.REP_POLICY);
    acl.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_ACL, Type.NAME);
    NodeBuilder ace = acl.child("first");
    ace.setProperty(JCR_PRIMARYTYPE, AccessControlConstants.NT_REP_GRANT_ACE, Type.NAME);
    ace.setProperty(AccessControlConstants.REP_PRINCIPAL_NAME, EveryonePrincipal.NAME);
    ace.setProperty(AccessControlConstants.REP_PRIVILEGES, ImmutableList.of(PrivilegeConstants.JCR_READ), Type.STRINGS);
    try {
        hook.processCommit(before, builder.getNodeState(), CommitInfo.EMPTY);
        fail();
    } catch (CommitFailedException e) {
        assertTrue(e.isConstraintViolation());
        assertEquals(55, e.getCode());
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Example 14 with EditorHook

use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.

the class DocumentQueueTest method setUp.

@Before
public void setUp() throws IOException {
    IndexEditorProvider editorProvider = new LuceneIndexEditorProvider(null, null, null, defaultMountInfoProvider());
    syncHook = new EditorHook(new IndexUpdateProvider(editorProvider));
    asyncHook = new EditorHook(new IndexUpdateProvider(editorProvider, "async", false));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) Before(org.junit.Before)

Example 15 with EditorHook

use of org.apache.jackrabbit.oak.spi.commit.EditorHook in project jackrabbit-oak by apache.

the class LuceneIndexEditorTest method multiplexingWriter.

@Test
public void multiplexingWriter() throws Exception {
    newLucenePropertyIndex("lucene", "foo");
    MountInfoProvider mip = Mounts.newBuilder().mount("foo", "/libs", "/apps").build();
    EditorHook hook = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider(null, new ExtractedTextCache(0, 0), null, mip)));
    NodeState indexed = hook.processCommit(EMPTY_NODE, builder.getNodeState(), CommitInfo.EMPTY);
    builder = indexed.builder();
    NodeState before = indexed;
    builder.child("content").child("en").setProperty("foo", "bar");
    builder.child("libs").child("install").setProperty("foo", "bar");
    NodeState after = builder.getNodeState();
    indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    builder = indexed.builder();
    assertEquals(1, numDocs(mip.getMountByName("foo")));
    assertEquals(1, numDocs(mip.getDefaultMount()));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) Test(org.junit.Test)

Aggregations

EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)69 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)46 Test (org.junit.Test)44 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)43 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)24 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)14 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)12 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)11 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)11 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)11 CompositeHook (org.apache.jackrabbit.oak.spi.commit.CompositeHook)11 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)8 AnnotatingConflictHandler (org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler)7 ConflictHook (org.apache.jackrabbit.oak.plugins.commit.ConflictHook)7 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)7 EditorProvider (org.apache.jackrabbit.oak.spi.commit.EditorProvider)7 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)6 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)6 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)6 Before (org.junit.Before)6