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");
}
}
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;
}
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();
}
}
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();
}
}
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();
}
}
Aggregations