Search in sources :

Example 36 with InitialContent

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

the class DocumentBundlingTest method setUpBundlor.

@Before
public void setUpBundlor() throws CommitFailedException {
    store = builderProvider.newBuilder().setDocumentStore(ds).setAsyncDelay(0).memoryCacheSize(0).getNodeStore();
    NodeState registryState = BundledTypesRegistry.builder().forType("app:Asset").include("jcr:content").include("jcr:content/metadata").include("jcr:content/renditions").include("jcr:content/renditions/**").build();
    NodeBuilder builder = store.getRoot().builder();
    new InitialContent().initialize(builder);
    BundlingConfigInitializer.INSTANCE.initialize(builder);
    builder.getChildNode("jcr:system").getChildNode(DOCUMENT_NODE_STORE).getChildNode(BUNDLOR).setChildNode("app:Asset", registryState.getChildNode("app:Asset"));
    merge(builder);
    store.runBackgroundOperations();
    journalDisabledProp = System.getProperty(SYS_PROP_DISABLE_JOURNAL);
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) DocumentNodeState(org.apache.jackrabbit.oak.plugins.document.DocumentNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractNodeState(org.apache.jackrabbit.oak.spi.state.AbstractNodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Before(org.junit.Before)

Example 37 with InitialContent

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

the class UserInitializerTest method testAdminConfiguration.

/**
 * @since OAK 1.0 The configuration defines if the password of the
 * admin user is being set.
 */
@Test
public void testAdminConfiguration() throws Exception {
    Map<String, Object> userParams = new HashMap();
    userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
    userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);
    ConfigurationParameters params = ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams));
    SecurityProvider sp = SecurityProviderBuilder.newBuilder().with(params).build();
    final ContentRepository repo = new Oak().with(new InitialContent()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(sp).createContentRepository();
    ContentSession cs = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {

        @Override
        public ContentSession run() throws Exception {
            return repo.login(null, null);
        }
    });
    try {
        Root root = cs.getLatestRoot();
        UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
        UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
        Authorizable adminUser = umgr.getAuthorizable("admin");
        assertNotNull(adminUser);
        Tree adminTree = root.getTree(adminUser.getPath());
        assertTrue(adminTree.exists());
        assertNull(adminTree.getProperty(UserConstants.REP_PASSWORD));
    } finally {
        cs.close();
    }
    // login as admin should fail
    ContentSession adminSession = null;
    try {
        adminSession = repo.login(new SimpleCredentials("admin", new char[0]), null);
        fail();
    } catch (LoginException e) {
    // success
    } finally {
        if (adminSession != null) {
            adminSession.close();
        }
    }
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) HashMap(java.util.HashMap) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) LoginException(javax.security.auth.login.LoginException) InitialContent(org.apache.jackrabbit.oak.InitialContent) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) SimpleCredentials(javax.jcr.SimpleCredentials) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) UserManager(org.apache.jackrabbit.api.security.user.UserManager) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Tree(org.apache.jackrabbit.oak.api.Tree) LoginException(javax.security.auth.login.LoginException) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 38 with InitialContent

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

the class HybridIndexTest method createRepository.

@Override
protected ContentRepository createRepository() {
    IndexCopier copier;
    try {
        copier = new IndexCopier(executorService, temporaryFolder.getRoot());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    MountInfoProvider mip = defaultMountInfoProvider();
    nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
    nrtIndexFactory.setAssertAllResourcesClosed(true);
    LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
    IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
    luceneIndexProvider = new LuceneIndexProvider(tracker);
    queue = new DocumentQueue(100, tracker, sameThreadExecutor());
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
    editorProvider.setIndexingQueue(queue);
    LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
    nodeStore = new MemoryNodeStore();
    Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) luceneIndexProvider).with((Observer) luceneIndexProvider).with(localIndexObserver).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(optionalEditorProvider).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
    wb = oak.getWhiteboard();
    return oak.createContentRepository();
}
Also used : NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) IndexTracker(org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IOException(java.io.IOException) LuceneIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) InitialContent(org.apache.jackrabbit.oak.InitialContent) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) DefaultIndexReaderFactory(org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) Mounts.defaultMountInfoProvider(org.apache.jackrabbit.oak.spi.mount.Mounts.defaultMountInfoProvider) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 39 with InitialContent

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

the class LucenePropertyIndexTest method createRepository.

@Override
protected ContentRepository createRepository() {
    IndexCopier copier = createIndexCopier();
    editorProvider = new LuceneIndexEditorProvider(copier, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100));
    provider = new LuceneIndexProvider(copier);
    queryIndexProvider = new ResultCountingIndexProvider(provider);
    nodeStore = new MemoryNodeStore();
    return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with(queryIndexProvider).with((Observer) provider).with(editorProvider).with(optionalEditorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)

Example 40 with InitialContent

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

the class InitializerTest method testInitializerSegment.

@Test
public void testInitializerSegment() throws CommitFailedException, IOException {
    NodeStore store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    NodeBuilder builder = store.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();
    WorkspaceInitializer workspaceInitializer = provider.getConfiguration(UserConfiguration.class).getWorkspaceInitializer();
    if (workspaceInitializer instanceof QueryIndexProviderAware) {
        ((QueryIndexProviderAware) workspaceInitializer).setQueryIndexProvider(new CompositeQueryIndexProvider(new PropertyIndexProvider(), new NodeTypeIndexProvider()));
    }
    workspaceInitializer.initialize(builder, "default");
    builder.getNodeState();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) WorkspaceInitializer(org.apache.jackrabbit.oak.spi.lifecycle.WorkspaceInitializer) NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) CompositeQueryIndexProvider(org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) QueryIndexProviderAware(org.apache.jackrabbit.oak.spi.query.QueryIndexProviderAware) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) Test(org.junit.Test)

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