Search in sources :

Example 1 with Repository

use of javax.jcr.Repository in project jackrabbit-oak by apache.

the class RevisionGCTest method run.

@Override
public void run(Iterable<RepositoryFixture> fixtures) {
    for (RepositoryFixture fixture : fixtures) {
        if (fixture.isAvailable(1)) {
            System.out.format("%s: RevisionGC benchmark%n", fixture);
            try {
                final AtomicReference<Oak> whiteboardRef = new AtomicReference<Oak>();
                Repository[] cluster;
                if (fixture instanceof OakRepositoryFixture) {
                    cluster = ((OakRepositoryFixture) fixture).setUpCluster(1, new JcrCreator() {

                        @Override
                        public Jcr customize(Oak oak) {
                            whiteboardRef.set(oak);
                            return new Jcr(oak);
                        }
                    });
                } else {
                    System.err.format("%s: RevisionGC benchmark only runs on Oak%n", fixture);
                    return;
                }
                try {
                    run(cluster[0], getNodeStore(whiteboardRef.get()));
                } finally {
                    fixture.tearDownCluster();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Repository(javax.jcr.Repository) OakRepositoryFixture(org.apache.jackrabbit.oak.fixture.OakRepositoryFixture) OakRepositoryFixture(org.apache.jackrabbit.oak.fixture.OakRepositoryFixture) RepositoryFixture(org.apache.jackrabbit.oak.fixture.RepositoryFixture) Oak(org.apache.jackrabbit.oak.Oak) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) AtomicReference(java.util.concurrent.atomic.AtomicReference) JcrCreator(org.apache.jackrabbit.oak.fixture.JcrCreator) RepositoryException(javax.jcr.RepositoryException)

Example 2 with Repository

use of javax.jcr.Repository in project jackrabbit-oak by apache.

the class ObservationTest method run.

@Override
public void run(Iterable<RepositoryFixture> fixtures) {
    for (RepositoryFixture fixture : fixtures) {
        if (fixture.isAvailable(1)) {
            System.out.format("%s: Observation throughput benchmark%n", fixture);
            try {
                final AtomicReference<Whiteboard> whiteboardRef = new AtomicReference<Whiteboard>();
                Repository[] cluster;
                if (fixture instanceof OakRepositoryFixture) {
                    cluster = ((OakRepositoryFixture) fixture).setUpCluster(1, new JcrCreator() {

                        @Override
                        public Jcr customize(Oak oak) {
                            whiteboardRef.set(oak.getWhiteboard());
                            return new Jcr(oak);
                        }
                    });
                } else {
                    cluster = fixture.setUpCluster(1);
                }
                try {
                    run(cluster[0], whiteboardRef.get());
                } finally {
                    fixture.tearDownCluster();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Repository(javax.jcr.Repository) OakRepositoryFixture(org.apache.jackrabbit.oak.fixture.OakRepositoryFixture) OakRepositoryFixture(org.apache.jackrabbit.oak.fixture.OakRepositoryFixture) RepositoryFixture(org.apache.jackrabbit.oak.fixture.RepositoryFixture) Oak(org.apache.jackrabbit.oak.Oak) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) AtomicReference(java.util.concurrent.atomic.AtomicReference) JcrCreator(org.apache.jackrabbit.oak.fixture.JcrCreator) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) RepositoryException(javax.jcr.RepositoryException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with Repository

use of javax.jcr.Repository in project jackrabbit-oak by apache.

the class RepositoryTest method loginInvalidWorkspace.

@Test(expected = NoSuchWorkspaceException.class)
public void loginInvalidWorkspace() throws RepositoryException {
    Repository repository = getRepository();
    repository.login(new GuestCredentials(), "invalid");
}
Also used : Repository(javax.jcr.Repository) JackrabbitRepository(org.apache.jackrabbit.api.JackrabbitRepository) GuestCredentials(javax.jcr.GuestCredentials) Test(org.junit.Test)

Example 4 with Repository

use of javax.jcr.Repository in project jackrabbit-oak by apache.

the class ValidNamesTest method tearDown.

@After
public void tearDown() throws RepositoryException {
    Session s = testNode.getSession();
    s.removeItem(TEST_PATH);
    s.save();
    Repository r = s.getRepository();
    s.logout();
    dispose(r);
}
Also used : Repository(javax.jcr.Repository) Session(javax.jcr.Session) After(org.junit.After)

Example 5 with Repository

use of javax.jcr.Repository in project jackrabbit-oak by apache.

the class JsonIndexCommand method openSession.

public static Session openSession(NodeStore nodeStore) throws RepositoryException {
    if (nodeStore == null) {
        return null;
    }
    StatisticsProvider statisticsProvider = StatisticsProvider.NOOP;
    Oak oak = new Oak(nodeStore).with(ManagementFactory.getPlatformMBeanServer());
    oak.getWhiteboard().register(StatisticsProvider.class, statisticsProvider, Collections.emptyMap());
    LuceneIndexProvider provider = createLuceneIndexProvider();
    oak.with((QueryIndexProvider) provider).with((Observer) provider).with(createLuceneIndexEditorProvider());
    Jcr jcr = new Jcr(oak);
    Repository repository = jcr.createRepository();
    return repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) Repository(javax.jcr.Repository) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider)

Aggregations

Repository (javax.jcr.Repository)126 Session (javax.jcr.Session)39 RepositoryException (javax.jcr.RepositoryException)31 Node (javax.jcr.Node)20 SimpleCredentials (javax.jcr.SimpleCredentials)18 Test (org.junit.Test)17 JackrabbitRepository (org.apache.jackrabbit.api.JackrabbitRepository)14 HashMap (java.util.HashMap)12 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)11 SlingRepository (org.apache.sling.jcr.api.SlingRepository)10 Oak (org.apache.jackrabbit.oak.Oak)9 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)9 IOException (java.io.IOException)7 InitialContext (javax.naming.InitialContext)7 NamingException (javax.naming.NamingException)7 Map (java.util.Map)6 File (java.io.File)5 PrintWriter (java.io.PrintWriter)5 ServletContext (javax.servlet.ServletContext)5 MongoConnection (org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)5