Search in sources :

Example 1 with SegmentTarNodeStoreContainer

use of org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer in project jackrabbit-oak by apache.

the class UpgradeOldSegmentTest method upgradeFrom10.

@Test
public void upgradeFrom10() throws Exception {
    File testFolder = new File(new File("target"), UpgradeOldSegmentTest.class.getSimpleName());
    FileUtils.deleteDirectory(testFolder);
    File oldRepo = new File(testFolder, "test-repo-1.0");
    oldRepo.mkdirs();
    try (InputStream in = UpgradeOldSegmentTest.class.getResourceAsStream("/test-repo-1.0.zip")) {
        Util.unzip(in, oldRepo);
    }
    SegmentTarNodeStoreContainer newRepoContainer = new SegmentTarNodeStoreContainer();
    OakUpgrade.main("segment-old:" + oldRepo.getPath(), newRepoContainer.getDescription());
    Repository repo = new Jcr(newRepoContainer.open()).createRepository();
    Session s = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));
    Node myType = s.getNode("/jcr:system/jcr:nodeTypes/test:MyType");
    assertEquals(2, Iterators.size(myType.getNodes("jcr:propertyDefinition")));
    NodeTypeManager ntMgr = s.getWorkspace().getNodeTypeManager();
    assertTrue(ntMgr.hasNodeType("test:MyType"));
    NodeType nt = ntMgr.getNodeType("test:MyType");
    PropertyDefinition[] pDefs = nt.getDeclaredPropertyDefinitions();
    assertEquals(2, pDefs.length);
    for (PropertyDefinition pd : pDefs) {
        String name = pd.getName();
        if (name.equals("test:mandatory")) {
            assertTrue(pd.isMandatory());
        } else if (name.equals("test:optional")) {
            assertFalse(pd.isMandatory());
        } else {
            fail("Unexpected property definition: " + name);
        }
    }
    // flip mandatory flag for test:mandatory
    String cnd = "<'test'='http://www.apache.org/jackrabbit/test'>\n" + "[test:MyType] > nt:unstructured\n" + " - test:mandatory (string)\n" + " - test:optional (string)";
    CndImporter.registerNodeTypes(new StringReader(cnd), s, true);
    myType = s.getNode("/jcr:system/jcr:nodeTypes/test:MyType");
    assertEquals(2, Iterators.size(myType.getNodes("jcr:propertyDefinition")));
    nt = ntMgr.getNodeType("test:MyType");
    pDefs = nt.getDeclaredPropertyDefinitions();
    assertEquals(2, pDefs.length);
    for (PropertyDefinition pd : pDefs) {
        String name = pd.getName();
        if (name.equals("test:mandatory")) {
            assertFalse(pd.isMandatory());
        } else if (name.equals("test:optional")) {
            assertFalse(pd.isMandatory());
        } else {
            fail("Unexpected property definition: " + name);
        }
    }
    s.logout();
    if (repo instanceof JackrabbitRepository) {
        ((JackrabbitRepository) repo).shutdown();
    }
    newRepoContainer.close();
    newRepoContainer.clean();
    deleteRecursive(testFolder);
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) InputStream(java.io.InputStream) Node(javax.jcr.Node) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) SimpleCredentials(javax.jcr.SimpleCredentials) Repository(javax.jcr.Repository) JackrabbitRepository(org.apache.jackrabbit.api.JackrabbitRepository) SegmentTarNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer) NodeType(javax.jcr.nodetype.NodeType) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) StringReader(java.io.StringReader) JackrabbitRepository(org.apache.jackrabbit.api.JackrabbitRepository) File(java.io.File) Session(javax.jcr.Session) Test(org.junit.Test)

Example 2 with SegmentTarNodeStoreContainer

use of org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer in project jackrabbit-oak by apache.

the class SegmentToSegmentTarWithMissingDestinationDirectoryTest method getSegmentTarNodeStoreContainerWithMissingDirectory.

private SegmentTarNodeStoreContainer getSegmentTarNodeStoreContainerWithMissingDirectory() throws IOException {
    SegmentTarNodeStoreContainer segmentTarNodeStoreContainer = new SegmentTarNodeStoreContainer();
    segmentTarNodeStoreContainer.getDirectory().delete();
    return segmentTarNodeStoreContainer;
}
Also used : SegmentTarNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer)

Example 3 with SegmentTarNodeStoreContainer

use of org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer in project jackrabbit-oak by apache.

the class CopyBinariesTest method data.

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
    List<Object[]> params = new ArrayList<Object[]>();
    BlobStoreContainer blob = new FileDataStoreContainer();
    BlobStoreContainer blob2 = new FileDataStoreContainer();
    params.add(new Object[] { "Copy references, no blobstores defined, segment -> segment", new SegmentNodeStoreContainer(blob), new SegmentNodeStoreContainer(blob), asList(), DatastoreArguments.BlobMigrationCase.COPY_REFERENCES });
    params.add(new Object[] { "Copy references, no blobstores defined, segment-tar -> segment-tar", new SegmentTarNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(blob), asList(), DatastoreArguments.BlobMigrationCase.COPY_REFERENCES });
    params.add(new Object[] { "Copy references, no blobstores defined, segment -> segment-tar", new SegmentNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(blob), asList(), DatastoreArguments.BlobMigrationCase.COPY_REFERENCES });
    params.add(new Object[] { "Copy references, no blobstores defined, document -> segment-tar", new JdbcNodeStoreContainer(blob), new SegmentNodeStoreContainer(blob), asList("--src-user=sa", "--src-password=sa"), DatastoreArguments.BlobMigrationCase.COPY_REFERENCES });
    params.add(new Object[] { "Copy references, no blobstores defined, segment-tar -> document", new SegmentTarNodeStoreContainer(blob), new JdbcNodeStoreContainer(blob), asList("--user=sa", "--password=sa"), DatastoreArguments.BlobMigrationCase.UNSUPPORTED });
    params.add(new Object[] { "Missing source, external destination", new SegmentTarNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(blob), asList("--datastore=" + blob.getDescription()), DatastoreArguments.BlobMigrationCase.UNSUPPORTED });
    params.add(new Object[] { "Copy embedded to embedded, no blobstores defined", new SegmentTarNodeStoreContainer(), new SegmentTarNodeStoreContainer(), asList(), DatastoreArguments.BlobMigrationCase.EMBEDDED_TO_EMBEDDED });
    params.add(new Object[] { "Copy embedded to external, no blobstores defined", new SegmentTarNodeStoreContainer(), new SegmentTarNodeStoreContainer(blob), asList("--datastore=" + blob.getDescription()), DatastoreArguments.BlobMigrationCase.EMBEDDED_TO_EXTERNAL });
    params.add(new Object[] { "Copy references, src blobstore defined", new SegmentTarNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(blob), asList("--src-datastore=" + blob.getDescription()), DatastoreArguments.BlobMigrationCase.COPY_REFERENCES });
    params.add(new Object[] { "Copy external to embedded, src blobstore defined", new SegmentTarNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(), asList("--copy-binaries", "--src-datastore=" + blob.getDescription()), DatastoreArguments.BlobMigrationCase.EXTERNAL_TO_EMBEDDED });
    params.add(new Object[] { "Copy external to external, src blobstore defined", new SegmentTarNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(blob2), asList("--copy-binaries", "--src-datastore=" + blob.getDescription(), "--datastore=" + blob2.getDescription()), DatastoreArguments.BlobMigrationCase.EXTERNAL_TO_EXTERNAL });
    return params;
}
Also used : JdbcNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.JdbcNodeStoreContainer) SegmentTarNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer) ArrayList(java.util.ArrayList) BlobStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer) FileDataStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer) SegmentNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer)

Example 4 with SegmentTarNodeStoreContainer

use of org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer in project jackrabbit-oak by apache.

the class CopyCheckpointsTest method data.

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
    List<Object[]> params = new ArrayList<Object[]>();
    BlobStoreContainer blob = new FileDataStoreContainer();
    params.add(new Object[] { "Fails on missing blobstore", new SegmentNodeStoreContainer(blob), new SegmentNodeStoreContainer(blob), asList(), Result.EXCEPTION });
    params.add(new Object[] { "Suppress the warning", new SegmentNodeStoreContainer(blob), new SegmentNodeStoreContainer(blob), asList("--skip-checkpoints"), Result.CHECKPOINTS_MISSING });
    params.add(new Object[] { "Source data store defined, checkpoints migrated", new SegmentTarNodeStoreContainer(blob), new SegmentTarNodeStoreContainer(blob), asList("--src-datastore=" + blob.getDescription()), Result.CHECKPOINTS_COPIED });
    return params;
}
Also used : SegmentTarNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer) ArrayList(java.util.ArrayList) BlobStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer) FileDataStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer) SegmentNodeStoreContainer(org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer)

Aggregations

SegmentTarNodeStoreContainer (org.apache.jackrabbit.oak.upgrade.cli.container.SegmentTarNodeStoreContainer)4 ArrayList (java.util.ArrayList)2 BlobStoreContainer (org.apache.jackrabbit.oak.upgrade.cli.container.BlobStoreContainer)2 FileDataStoreContainer (org.apache.jackrabbit.oak.upgrade.cli.container.FileDataStoreContainer)2 SegmentNodeStoreContainer (org.apache.jackrabbit.oak.upgrade.cli.container.SegmentNodeStoreContainer)2 File (java.io.File)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 Node (javax.jcr.Node)1 Repository (javax.jcr.Repository)1 Session (javax.jcr.Session)1 SimpleCredentials (javax.jcr.SimpleCredentials)1 NodeType (javax.jcr.nodetype.NodeType)1 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)1 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)1 JackrabbitRepository (org.apache.jackrabbit.api.JackrabbitRepository)1 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)1 JdbcNodeStoreContainer (org.apache.jackrabbit.oak.upgrade.cli.container.JdbcNodeStoreContainer)1 Test (org.junit.Test)1