Search in sources :

Example 6 with RepositoryContext

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

the class LongNameTest method assertNoLongNamesTest.

@Test
public void assertNoLongNamesTest() throws IOException, RepositoryException {
    RepositoryConfig config = createCrx2Config(crx2RepoDir);
    RepositoryContext context = RepositoryContext.create(config);
    try {
        RepositoryUpgrade upgrade = new RepositoryUpgrade(context, new MemoryNodeStore());
        try {
            upgrade.assertNoLongNames();
            fail("Exception should be thrown");
        } catch (RepositoryException e) {
        // that's fine
        }
    } finally {
        context.getRepository().shutdown();
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) RepositoryException(javax.jcr.RepositoryException) Test(org.junit.Test)

Example 7 with RepositoryContext

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

the class LongNameTest method upgrade.

private static void upgrade(NodeStore target, boolean skipNameCheck, boolean filterLongNames) throws RepositoryException, IOException {
    RepositoryConfig config = createCrx2Config(crx2RepoDir);
    RepositoryContext context = RepositoryContext.create(config);
    try {
        RepositoryUpgrade upgrade = new RepositoryUpgrade(context, target);
        upgrade.setCheckLongNames(skipNameCheck);
        upgrade.setFilterLongNames(filterLongNames);
        upgrade.copy(null);
    } finally {
        context.getRepository().shutdown();
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext)

Example 8 with RepositoryContext

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

the class LongNameTest method prepareSourceRepository.

@BeforeClass
public static void prepareSourceRepository() throws RepositoryException, IOException, InterruptedException {
    crx2RepoDir = new File("target", "upgrade-" + Clock.SIMPLE.getTimeIncreasing());
    FileUtils.deleteQuietly(crx2RepoDir);
    sourceRepositoryConfig = createCrx2Config(crx2RepoDir);
    RepositoryContext ctx = RepositoryContext.create(sourceRepositoryConfig);
    RepositoryImpl sourceRepository = ctx.getRepository();
    Session session = sourceRepository.login(CREDENTIALS);
    try {
        Assert.assertTrue(TOO_LONG_NAME.getBytes().length > 150);
        Assert.assertTrue(NOT_TOO_LONG_NAME.getBytes().length < 150);
        Node longNameParent = createParent(session.getRootNode());
        Assert.assertTrue(longNameParent.getPath().length() >= 350);
        longNameParent.addNode(TOO_LONG_NAME);
        longNameParent.addNode(NOT_TOO_LONG_NAME);
        session.save();
        Assert.assertTrue(longNameParent.hasNode(TOO_LONG_NAME));
        Assert.assertTrue(longNameParent.hasNode(NOT_TOO_LONG_NAME));
    } finally {
        session.logout();
    }
    sourceRepository.shutdown();
}
Also used : RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) Node(javax.jcr.Node) File(java.io.File) Session(javax.jcr.Session) BeforeClass(org.junit.BeforeClass)

Example 9 with RepositoryContext

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

the class CopyVersionHistoryTest method performCopy.

protected Session performCopy(VersionCopySetup setup) throws RepositoryException, IOException {
    final RepositoryConfig sourceConfig = RepositoryConfig.create(source);
    final RepositoryContext sourceContext = RepositoryContext.create(sourceConfig);
    final NodeStore targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    try {
        final RepositoryUpgrade upgrade = new RepositoryUpgrade(sourceContext, targetNodeStore);
        setup.setup(upgrade.versionCopyConfiguration);
        upgrade.setEarlyShutdown(true);
        upgrade.copy(null);
    } finally {
        sourceContext.getRepository().shutdown();
    }
    repository = (RepositoryImpl) new Jcr(new Oak(targetNodeStore)).createRepository();
    Session s = repository.login(AbstractRepositoryUpgradeTest.CREDENTIALS);
    sessions.add(s);
    return s;
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) RepositoryContext(org.apache.jackrabbit.core.RepositoryContext) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) Session(javax.jcr.Session)

Example 10 with RepositoryContext

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

the class Jackrabbit2Factory method create.

public RepositoryContext create(Closer closer) throws RepositoryException {
    RepositoryContext source = RepositoryContext.create(RepositoryConfig.create(repositoryFile, repositoryDir));
    closer.register(asCloseable(source));
    return source;
}
Also used : RepositoryContext(org.apache.jackrabbit.core.RepositoryContext)

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