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