Search in sources :

Example 41 with InitialContent

use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.

the class InitializerTest method testInitializerMongo.

@Test
public void testInitializerMongo() throws CommitFailedException {
    NodeBuilder builder = mk.getNodeStore().getRoot().builder();
    new InitialContent().initialize(builder);
    SecurityProvider provider = SecurityProviderBuilder.newBuilder().with(ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME, ConfigurationParameters.of(ImmutableMap.of("anonymousId", "anonymous", "adminId", "admin", "usersPath", "/home/users", "groupsPath", "/home/groups", "defaultDepth", "1"))))).build();
    provider.getConfiguration(UserConfiguration.class).getWorkspaceInitializer().initialize(builder, "default");
    builder.getNodeState();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 42 with InitialContent

use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.

the class MountsNodeCounterTest method createRepository.

protected ContentRepository createRepository() {
    Mounts.Builder builder = Mounts.newBuilder();
    builder.mount("libs", false, Arrays.asList("/var/fragments"), Arrays.asList("/apps", "/libs", "/nested/mount"));
    mip = builder.build();
    nodeStore = new MemoryNodeStore();
    Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with(new PropertyIndexEditorProvider().with(mip)).with(new NodeCounterEditorProvider().with(mip)).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) Mounts(org.apache.jackrabbit.oak.spi.mount.Mounts) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)

Example 43 with InitialContent

use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.

the class ChangeCollectorProviderTest method setup.

@Before
public void setup() throws PrivilegedActionException, CommitFailedException {
    collectorProvider = new ChangeCollectorProvider();
    recorder = new Recorder();
    Oak oak = new Oak().with(new InitialContent()).with(collectorProvider).with(recorder).with(getSecurityProvider());
    contentRepository = oak.createContentRepository();
    session = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {

        @Override
        public ContentSession run() throws LoginException, NoSuchWorkspaceException {
            return contentRepository.login(null, null);
        }
    });
    Root root = session.getLatestRoot();
    Tree rootTree = root.getTree("/").addChild("test");
    rootTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:parentType", Type.NAME);
    Tree child1 = rootTree.addChild("child1");
    child1.setProperty("child1Prop", 1);
    child1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:childType", Type.NAME);
    Tree grandChild1 = child1.addChild("grandChild1");
    grandChild1.setProperty("grandChild1Prop", 1);
    grandChild1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:grandChildType", Type.NAME);
    Tree greatGrandChild1 = grandChild1.addChild("greatGrandChild1");
    greatGrandChild1.setProperty("greatGrandChild1Prop", 1);
    greatGrandChild1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:greatGrandChildType", Type.NAME);
    Tree child2 = rootTree.addChild("child2");
    child2.setProperty("child2Prop", 1);
    child2.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:childType", Type.NAME);
    Tree grandChild2 = child2.addChild("grandChild2");
    grandChild2.setProperty("grandChild2Prop", 1);
    grandChild2.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:grandChildType", Type.NAME);
    recorder.changes.clear();
    root.commit();
    ChangeSet changeSet = getSingleChangeSet();
    assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child2", "/test/child1", "/test/child1/grandChild1/greatGrandChild1", "/", "/test", "/test/child1/grandChild1", "/test/child2/grandChild2");
    assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "child2", "child1", "greatGrandChild1", "test", "grandChild1", "grandChild2");
    assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
    assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
    assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "child1Prop", "child2Prop", "grandChild1Prop", "grandChild2Prop", "greatGrandChild1Prop");
    // clear the recorder so that we start off empty
    recorder.changes.clear();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) Root(org.apache.jackrabbit.oak.api.Root) Oak(org.apache.jackrabbit.oak.Oak) Tree(org.apache.jackrabbit.oak.api.Tree) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) ChangeSet(org.apache.jackrabbit.oak.spi.observation.ChangeSet) Before(org.junit.Before)

Aggregations

InitialContent (org.apache.jackrabbit.oak.InitialContent)43 Oak (org.apache.jackrabbit.oak.Oak)31 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)25 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)15 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)15 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)11 Before (org.junit.Before)11 Test (org.junit.Test)10 NodeTypeIndexProvider (org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider)9 IOException (java.io.IOException)8 Root (org.apache.jackrabbit.oak.api.Root)8 TypeEditorProvider (org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)7 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)7 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)6 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)5 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)5 QueryIndexProvider (org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)5 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)5 Tree (org.apache.jackrabbit.oak.api.Tree)4 IndexCopier (org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier)4