Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.ContentRepository


        public void stop() throws Exception {
            server.stop();
        }

        private void addServlets(MicroKernel kernel, String path) {
            ContentRepository repository =
                    new ContentRepositoryImpl(kernel, null, null);

            ServletHolder oak =
                    new ServletHolder(new OakServlet(repository));
            context.addServlet(oak, path + "/*");
 
View Full Code Here


        private void addServlets(Oak oak, String path) {
            Jcr jcr = new Jcr(oak);

            // 1 - OakServer
            ContentRepository repository = oak.createContentRepository();
            ServletHolder holder = new ServletHolder(new OakServlet(repository));
            context.addServlet(holder, path + "/*");

            // 2 - Webdav Server on JCR repository
            final Repository jcrRepository = jcr.createRepository();
View Full Code Here

        userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
        userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);

        ConfigurationParameters params = ConfigurationParameters.of(ImmutableMap.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 RegistrationEditorProvider())
                .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) {
View Full Code Here

        Map<String,Object> userParams = new HashMap();
        userParams.put(UserConstants.PARAM_ANONYMOUS_ID, "");

        ConfigurationParameters params = ConfigurationParameters.of(ImmutableMap.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 RegistrationEditorProvider())
                .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 anonymous = umgr.getAuthorizable(UserConstants.DEFAULT_ANONYMOUS_ID);
            assertNull(anonymous);
        } finally {
            cs.close();
        }

        // login as admin should fail
        ContentSession anonymousSession = null;
        try {
            anonymousSession = repo.login(new GuestCredentials(), null);
            fail();
        } catch (LoginException e) {
            //success
        } finally {
            if (anonymousSession != null) {
View Full Code Here

     */
    public OakRepositoryStub(Properties settings) throws RepositoryException, IOException {
        super(settings);

        MicroKernel microkernel = new MicroKernelImpl("target/mk-tck-" + System.currentTimeMillis());
        ContentRepository contentRepository = new ContentRepositoryImpl(microkernel, null, buildDefaultCommitEditor());
        repository = new RepositoryImpl(contentRepository, Executors.newScheduledThreadPool(1));

        Session session = repository.login(superuser);
        try {
            TestContentLoader loader = new TestContentLoader();
View Full Code Here

public class NamespaceRegistryImplTest {

    @Test
    public void testMappings() throws Exception {
        ContentRepository repository = new ContentRepositoryImpl();
        ContentSession session = repository.login(new GuestCredentials(), null);
        NamespaceRegistry r = new NamespaceRegistryImpl(session);

        assertEquals("", r.getURI(""));
        assertEquals("http://www.jcp.org/jcr/1.0", r.getURI("jcr"));
        assertEquals("http://www.jcp.org/jcr/nt/1.0", r.getURI("nt"));
View Full Code Here

        public void stop() throws Exception {
            server.stop();
        }

        private void addServlets(MicroKernel kernel, String path) {
            ContentRepository repository =
                    new ContentRepositoryImpl(kernel, null, buildDefaultCommitEditor());

            ServletHolder oak =
                    new ServletHolder(new OakServlet(repository));
            context.addServlet(oak, path + "/*");
 
View Full Code Here

    @Override
    public Object addingService(ServiceReference reference) {
        Object service = context.getService(reference);
        if (service instanceof ContentRepository) {
            ContentRepository repository = (ContentRepository) service;
            services.put(reference, context.registerService(
                    Repository.class.getName(),
                    new RepositoryImpl(repository, executor),
                    new Properties()));
            return service;
View Full Code Here

    @Override
    public Object addingService(ServiceReference reference) {
        Object service = context.getService(reference);
        if (service instanceof ContentRepository) {
            ContentRepository repository = (ContentRepository) service;
            services.put(reference, context.registerService(
                    Repository.class.getName(),
                    new OsgiRepository(repository, executor),
                    new Properties()));
            return service;
View Full Code Here

        public void stop() throws Exception {
            server.stop();
        }

        private void addServlets(MicroKernel kernel, String path) {
            ContentRepository repository =
                    new ContentRepositoryImpl(kernel, null, buildDefaultCommitHook());

            ServletHolder oak =
                    new ServletHolder(new OakServlet(repository));
            context.addServlet(oak, path + "/*");
 
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.ContentRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.