Search in sources :

Example 11 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider in project sling by apache.

the class OakSlingRepositoryManager method acquireRepository.

@Override
protected Repository acquireRepository() {
    final BundleContext bundleContext = componentContext.getBundleContext();
    final Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
    this.indexProvider.start(whiteboard);
    this.indexEditorProvider.start(whiteboard);
    this.oakExecutorServiceReference = bundleContext.registerService(Executor.class.getName(), new Executor() {

        @Override
        public void execute(Runnable command) {
            threadPool.execute(command);
        }
    }, new Hashtable<String, Object>());
    final Oak oak = new Oak(nodeStore).withAsyncIndexing("async", 5);
    final Jcr jcr = new Jcr(oak, false).with(new InitialContent()).with(new ExtraSlingContent()).with(JcrConflictHandler.createJcrConflictHandler()).with(new VersionHook()).with(securityProvider).with(new NameValidatorProvider()).with(new NamespaceEditorProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(indexProvider).with(indexEditorProvider).with(getDefaultWorkspace()).with(whiteboard).withFastQueryResultSize(true).withObservationQueueLength(configuration.oak_observation_queue_length());
    if (commitRateLimiter != null) {
        jcr.with(commitRateLimiter);
    }
    jcr.createContentRepository();
    return new TcclWrappingJackrabbitRepository((JackrabbitRepository) jcr.createRepository());
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) Hashtable(java.util.Hashtable) VersionHook(org.apache.jackrabbit.oak.plugins.version.VersionHook) NameValidatorProvider(org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) InitialContent(org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent) Executor(java.util.concurrent.Executor) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) Oak(org.apache.jackrabbit.oak.Oak) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) BundleContext(org.osgi.framework.BundleContext)

Example 12 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider in project jackrabbit-oak by apache.

the class LuceneIndexAggregationTest2 method createRepository.

@Override
protected ContentRepository createRepository() {
    LuceneIndexProvider provider = new LuceneIndexProvider();
    return new Oak().with(new InitialContent() {

        @Override
        public void initialize(@Nonnull NodeBuilder builder) {
            super.initialize(builder);
            // registering additional node types for wider testing
            InputStream stream = null;
            try {
                stream = LuceneIndexAggregationTest2.class.getResourceAsStream("test_nodetypes.cnd");
                NodeState base = builder.getNodeState();
                NodeStore store = new MemoryNodeStore(base);
                Root root = RootFactory.createSystemRoot(store, new EditorHook(new CompositeEditorProvider(new NamespaceEditorProvider(), new TypeEditorProvider())), null, null, null, null);
                NodeTypeRegistry.register(root, stream, "testing node types");
                NodeState target = store.getRoot();
                target.compareAgainstBaseState(base, new ApplyDiff(builder));
            } catch (Exception e) {
                LOG.error("Error while registering required node types. Failing here", e);
                fail("Error while registering required node types");
            } finally {
                printNodeTypes(builder);
                if (stream != null) {
                    try {
                        stream.close();
                    } catch (IOException e) {
                        LOG.debug("Ignoring exception on stream closing.", e);
                    }
                }
            }
        }
    }).with(new OpenSecurityProvider()).with(((QueryIndexProvider) provider.with(getNodeAggregator()))).with((Observer) provider).with(new LuceneIndexEditorProvider()).createContentRepository();
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) ApplyDiff(org.apache.jackrabbit.oak.spi.state.ApplyDiff) CompositeEditorProvider(org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Root(org.apache.jackrabbit.oak.api.Root) Nonnull(javax.annotation.Nonnull) InputStream(java.io.InputStream) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) IOException(java.io.IOException) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) IOException(java.io.IOException) InitialContent(org.apache.jackrabbit.oak.InitialContent) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Oak(org.apache.jackrabbit.oak.Oak)

Example 13 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider in project jackrabbit-oak by apache.

the class ExternalIdentityRepositoryInitializer method initialize.

@Override
public void initialize(@Nonnull NodeBuilder builder) {
    NodeState base = builder.getNodeState();
    NodeStore store = new MemoryNodeStore(base);
    String errorMsg = "Failed to initialize external identity content.";
    try {
        Root root = RootFactory.createSystemRoot(store, new EditorHook(new CompositeEditorProvider(new NamespaceEditorProvider(), new TypeEditorProvider())), null, null, null, null);
        // create index definition for "rep:externalId" and "rep:externalPrincipalNames"
        Tree rootTree = root.getTree(PathUtils.ROOT_PATH);
        checkState(rootTree.exists());
        Tree index = TreeUtil.getOrAddChild(rootTree, IndexConstants.INDEX_DEFINITIONS_NAME, JcrConstants.NT_UNSTRUCTURED);
        if (enforceUniqueIds && !index.hasChild("externalId")) {
            Tree definition = IndexUtils.createIndexDefinition(index, "externalId", true, new String[] { ExternalIdentityConstants.REP_EXTERNAL_ID });
            definition.setProperty("info", "Oak index assuring uniqueness of rep:externalId properties.");
        }
        if (!index.hasChild("externalPrincipalNames")) {
            Tree definition = IndexUtils.createIndexDefinition(index, "externalPrincipalNames", false, new String[] { ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES });
            definition.setProperty("info", "Oak index used by the principal management provided by the external authentication module.");
        }
        if (root.hasPendingChanges()) {
            root.commit();
        }
    } catch (RepositoryException e) {
        log.error(errorMsg, e);
        throw new RuntimeException(e);
    } catch (CommitFailedException e) {
        log.error(errorMsg, e);
        throw new RuntimeException(e);
    }
    NodeState target = store.getRoot();
    target.compareAgainstBaseState(base, new ApplyDiff(builder));
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) ApplyDiff(org.apache.jackrabbit.oak.spi.state.ApplyDiff) CompositeEditorProvider(org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Root(org.apache.jackrabbit.oak.api.Root) RepositoryException(javax.jcr.RepositoryException) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Tree(org.apache.jackrabbit.oak.api.Tree) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 14 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider in project jackrabbit-oak by apache.

the class AbstractSecurityTest method before.

@Before
public void before() throws Exception {
    Oak oak = new Oak().with(new InitialContent()).with(new VersionHook()).with(JcrConflictHandler.createJcrConflictHandler()).with(new NamespaceEditorProvider()).with(new ReferenceEditorProvider()).with(new ReferenceIndexProvider()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(getQueryEngineSettings()).with(getSecurityProvider());
    withEditors(oak);
    contentRepository = oak.createContentRepository();
    adminSession = login(getAdminCredentials());
    root = adminSession.getLatestRoot();
    Configuration.setConfiguration(getConfiguration());
}
Also used : NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) ReferenceIndexProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceIndexProvider) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) VersionHook(org.apache.jackrabbit.oak.plugins.version.VersionHook) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider) Before(org.junit.Before)

Example 15 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider 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 = new SecurityProviderImpl(params);
    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) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

TypeEditorProvider (org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)15 Oak (org.apache.jackrabbit.oak.Oak)7 NamespaceEditorProvider (org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider)7 InitialContent (org.apache.jackrabbit.oak.InitialContent)6 Root (org.apache.jackrabbit.oak.api.Root)6 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)6 Tree (org.apache.jackrabbit.oak.api.Tree)5 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)5 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)5 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)5 Test (org.junit.Test)5 PropertyIndexProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider)4 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)4 SecurityProviderImpl (org.apache.jackrabbit.oak.security.SecurityProviderImpl)4 ApplyDiff (org.apache.jackrabbit.oak.spi.state.ApplyDiff)4 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)4 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)3 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)3 ReferenceEditorProvider (org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider)3 AbstractQueryTest (org.apache.jackrabbit.oak.query.AbstractQueryTest)3