Search in sources :

Example 1 with RepositoryImpl

use of org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl in project jackrabbit-oak by apache.

the class CopyVersionHistorySidegradeTest method upgradeRepository.

@Before
@Override
public void upgradeRepository() throws Exception {
    if (sourceNodeStore == null) {
        sourceNodeStore = new MemoryNodeStore();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(sourceNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.logout();
            repository.shutdown();
        }
    }
}
Also used : MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) Session(javax.jcr.Session) Before(org.junit.Before)

Example 2 with RepositoryImpl

use of org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl in project jackrabbit-oak by apache.

the class BrokenVersionableTest method createSourceContent.

private NodeStore createSourceContent() throws Exception {
    SegmentNodeStore source = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(source)).createRepository();
    Session session = repository.login(CREDENTIALS);
    List<String> versionHistoryPaths = new ArrayList<String>();
    try {
        CndImporter.registerNodeTypes(new StringReader("<test = 'http://jackrabbit.apache.org/ns/test'>\n" + "[test:Versionable] > nt:unstructured, mix:versionable"), session);
        Node root = session.getRootNode();
        Node versionable1 = root.addNode("versionable1", NT_UNSTRUCTURED);
        versionable1.addMixin(MIX_VERSIONABLE);
        versionable1.addNode("child", NT_UNSTRUCTURED);
        Node versionable2 = root.addNode("versionable2", "test:Versionable");
        versionable2.addNode("child", NT_UNSTRUCTURED);
        session.save();
        VersionManager vMgr = session.getWorkspace().getVersionManager();
        vMgr.checkin("/versionable1");
        vMgr.checkin("/versionable2");
        versionHistoryPaths.add(vMgr.getVersionHistory("/versionable1").getPath());
        versionHistoryPaths.add(vMgr.getVersionHistory("/versionable2").getPath());
    } finally {
        session.logout();
        repository.shutdown();
    }
    // remove version history to corrupt the JCR repository structure
    NodeBuilder rootBuilder = source.getRoot().builder();
    for (String versionHistoryPath : versionHistoryPaths) {
        NodeStateTestUtils.createOrGetBuilder(rootBuilder, versionHistoryPath).remove();
    }
    source.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    return source;
}
Also used : Node(javax.jcr.Node) ArrayList(java.util.ArrayList) VersionManager(javax.jcr.version.VersionManager) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) StringReader(java.io.StringReader) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 3 with RepositoryImpl

use of org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl in project sling by apache.

the class RepositoryTestHelper method createOakRepository.

public static Repository createOakRepository(NodeStore nodeStore) {
    DefaultWhiteboard whiteboard = new DefaultWhiteboard();
    final Oak oak = new Oak(nodeStore).with(new InitialContent()).with(JcrConflictHandler.createJcrConflictHandler()).with(new EditorHook(new VersionEditorProvider())).with(new OpenSecurityProvider()).with(new NamespaceEditorProvider()).with(new TypeEditorProvider()).with(new ConflictValidatorProvider()).with(//getDefaultWorkspace())
    "default").with(whiteboard);
    //        if (commitRateLimiter != null) {
    //            oak.with(commitRateLimiter);
    //        }
    final ContentRepository contentRepository = oak.createContentRepository();
    return new RepositoryImpl(contentRepository, whiteboard, new OpenSecurityProvider(), 1000, null);
}
Also used : InitialContent(org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent) NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Oak(org.apache.jackrabbit.oak.Oak) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) VersionEditorProvider(org.apache.jackrabbit.oak.plugins.version.VersionEditorProvider) ConflictValidatorProvider(org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)

Example 4 with RepositoryImpl

use of org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl in project jackrabbit-oak by apache.

the class RepeatedRepositorySidegradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (!upgradeComplete) {
        final File sourceDir = new File(getTestDirectory(), "jackrabbit2");
        sourceDir.mkdirs();
        FileStore fileStore = fileStoreBuilder(sourceDir).build();
        SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(sourceDir, target, false);
        fileStore = fileStoreBuilder(sourceDir).build();
        segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        session = repository.login(CREDENTIALS);
        try {
            modifySourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        doUpgradeRepository(sourceDir, target, true);
        upgradeComplete = true;
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File) Session(javax.jcr.Session) Before(org.junit.Before)

Example 5 with RepositoryImpl

use of org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl in project jackrabbit-oak by apache.

the class IncludeExcludeSidegradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (targetNodeStore == null) {
        File directory = getTestDirectory();
        File source = new File(directory, "source");
        source.mkdirs();
        FileStore fileStore = fileStoreBuilder(source).build();
        SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(source, target);
        targetNodeStore = target;
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File) Session(javax.jcr.Session) Before(org.junit.Before)

Aggregations

Oak (org.apache.jackrabbit.oak.Oak)5 RepositoryImpl (org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl)5 Session (javax.jcr.Session)4 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)4 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)3 Before (org.junit.Before)3 File (java.io.File)2 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)2 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Node (javax.jcr.Node)1 VersionManager (javax.jcr.version.VersionManager)1 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)1 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)1 ConflictValidatorProvider (org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider)1 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)1 NamespaceEditorProvider (org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider)1 TypeEditorProvider (org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)1 InitialContent (org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent)1