Search in sources :

Example 1 with RepositoryContext

use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit by apache.

the class StatisticsServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String klass = RepositoryContext.class.getName();
    String name = getServletConfig().getInitParameter(klass);
    if (name == null) {
        name = klass;
    }
    RepositoryContext context = (RepositoryContext) getServletContext().getAttribute(name);
    if (context != null) {
        RepositoryStatistics statistics = context.getRepositoryStatistics();
        response.setContentType("application/json");
        Writer writer = response.getWriter();
        writer.write('{');
        write(writer, "read", statistics.getTimeSeries(RepositoryStatistics.Type.SESSION_READ_COUNTER));
        writer.write(',');
        write(writer, "write", statistics.getTimeSeries(RepositoryStatistics.Type.SESSION_WRITE_COUNTER));
        writer.write(',');
        write(writer, "login", statistics.getTimeSeries(RepositoryStatistics.Type.SESSION_LOGIN_COUNTER));
        writer.write('}');
    } else {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Jackrabbit repository internals are not available");
    }
}
Also used : RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) RepositoryStatistics(org.apache.jackrabbit.api.stats.RepositoryStatistics) Writer(java.io.Writer)

Example 2 with RepositoryContext

use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.

the class SameNodeSiblingsTest method migrate.

private DocumentNodeStore migrate(SourceDataCreator sourceDataCreator) throws RepositoryException, IOException {
    RepositoryConfig config = RepositoryConfig.install(crx2RepoDir);
    RepositoryImpl repository = RepositoryImpl.create(config);
    try {
        Session session = repository.login(CREDENTIALS);
        sourceDataCreator.create(session);
        session.logout();
    } finally {
        repository.shutdown();
    }
    // re-create the config
    config = RepositoryConfig.install(crx2RepoDir);
    RepositoryContext context = RepositoryContext.create(config);
    DocumentNodeStore target = new DocumentMK.Builder().getNodeStore();
    try {
        RepositoryUpgrade upgrade = new RepositoryUpgrade(context, target);
        upgrade.copy(null);
    } finally {
        context.getRepository().shutdown();
    }
    return target;
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) Session(javax.jcr.Session)

Example 3 with RepositoryContext

use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.

the class IncludeExcludeUpgradeTest method doUpgradeRepository.

@Override
protected void doUpgradeRepository(File source, NodeStore target) throws RepositoryException, IOException {
    final RepositoryConfig config = RepositoryConfig.create(source);
    final RepositoryContext context = RepositoryContext.create(config);
    try {
        final RepositoryUpgrade upgrade = new RepositoryUpgrade(context, target);
        upgrade.setIncludes("/content/foo/en", "/content/assets/foo", "/content/other");
        upgrade.setExcludes("/content/assets/foo/2013", "/content/assets/foo/2012", "/content/assets/foo/2011", "/content/assets/foo/2010");
        upgrade.setExcludeFragments("oak-mount-libs-xyz");
        upgrade.setFragmentPaths("/content/other/path");
        upgrade.copy(null);
    } finally {
        context.getRepository().shutdown();
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext)

Example 4 with RepositoryContext

use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.

the class UpgradeFromTwoSourcesTest method doUpgradeRepository.

private void doUpgradeRepository(File source, NodeStore target, String... includes) throws RepositoryException {
    final RepositoryConfig config = RepositoryConfig.create(source);
    final RepositoryContext context = RepositoryContext.create(config);
    try {
        final RepositoryUpgrade upgrade = new RepositoryUpgrade(context, target);
        upgrade.setIncludes(includes);
        upgrade.copy(null);
    } finally {
        context.getRepository().shutdown();
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext)

Example 5 with RepositoryContext

use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.

the class RepeatedRepositoryUpgradeTest method doUpgradeRepository.

protected void doUpgradeRepository(File source, NodeStore target, boolean skipInit) throws RepositoryException, IOException {
    final RepositoryConfig config = RepositoryConfig.create(source);
    final RepositoryContext context = RepositoryContext.create(config);
    try {
        final RepositoryUpgrade repositoryUpgrade = new RepositoryUpgrade(context, target);
        repositoryUpgrade.setSkipInitialization(skipInit);
        repositoryUpgrade.copy(new RepositoryInitializer() {

            @Override
            public void initialize(@Nonnull NodeBuilder builder) {
                builder.child("foo").child("bar");
            }
        });
    } finally {
        context.getRepository().shutdown();
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Aggregations

RepositoryContext (org.apache.jackrabbit.core.RepositoryContext)11 RepositoryConfig (org.apache.jackrabbit.core.config.RepositoryConfig)7 Session (javax.jcr.Session)3 RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)2 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)2 File (java.io.File)1 Writer (java.io.Writer)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 RepositoryStatistics (org.apache.jackrabbit.api.stats.RepositoryStatistics)1 Oak (org.apache.jackrabbit.oak.Oak)1 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)1 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)1 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)1 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)1 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)1 MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)1 BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)1 RepositoryInitializer (org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1