Package org.apache.jackrabbit.oak.api

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


    public Object addingService(ServiceReference reference) {
        Object service = context.getService(reference);
        if (service instanceof NodeStore) {
            Whiteboard whiteboard = new OsgiWhiteboard(context);

            ContentRepository cr = new Oak((NodeStore) service)
                .with(new InitialContent())
                .with(JcrConflictHandler.JCR_CONFLICT_HANDLER)
                .with(whiteboard)
                .with(securityProvider)
                .with(editorProvider)
View Full Code Here


        private void addServlets(NodeStore store, String path) {
            Oak oak = new Oak(store);
            Jcr jcr = new Jcr(oak).with(executor);

            ContentRepository repository = oak.createContentRepository();

            ServletHolder holder =
                    new ServletHolder(new OakServlet(repository));
            context.addServlet(holder, 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 OsgiRepository(repository, executor, securityProvider),
                    new Properties()));
            return service;
View Full Code Here

public class NamespaceMappingsTest {

    @Test
    public void testMappings() throws Exception {
        ContentRepository repository = new ContentRepositoryImpl();
        ContentSession session = repository.login(null, "default");
        NamespaceMappings r = new NamespaceMappings(session);

        r.registerNamespace("p", "n");
        assertEquals(r.getURI("p"), "n");
        assertEquals(r.getPrefix("n"), "p");
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

    @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),
                    new Properties()));
            return service;
View Full Code Here

     * @see javax.jcr.Repository#login(javax.jcr.Credentials, String)
     */
    @Override
    public Session login(Credentials credentials, String workspaceName) throws RepositoryException {
        // TODO: needs complete refactoring
        ContentRepository contentRepository = context.getInstance(ContentRepository.class);
        try {
            ContentSession contentSession = contentRepository.login(credentials, workspaceName);
            return new SessionImpl(context, contentSession);
        } catch (LoginException e) {
            throw new javax.jcr.LoginException(e.getMessage());
        }

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_ADMIN_PW, null);

        ConfigurationParameters params = new ConfigurationParameters(ImmutableMap.of(UserConfiguration.PARAM_USER_OPTIONS, new ConfigurationParameters(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

        if (root == null && callbackHandler != null) {
            try {
                final RepositoryCallback rcb = new RepositoryCallback();
                callbackHandler.handle(new Callback[]{rcb});

                final ContentRepository repository = rcb.getContentRepository();
                systemSession = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
                    @Override
                    public ContentSession run() throws LoginException, NoSuchWorkspaceException {
                        return repository.login(null, rcb.getWorkspaceName());
                    }
                });
                root = systemSession.getLatestRoot();
            } catch (UnsupportedCallbackException e) {
                log.debug(e.getMessage());
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.