Search in sources :

Example 21 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class Main method backup.

private void backup(File sourceDir) throws Exception {
    RepositoryConfig source;
    if (command.hasOption("conf")) {
        source = RepositoryConfig.create(new File(command.getOptionValue("conf")), sourceDir);
    } else {
        source = RepositoryConfig.create(sourceDir);
    }
    File targetDir;
    if (command.hasOption("backup-repo")) {
        targetDir = new File(command.getOptionValue("backup-repo"));
    } else {
        int i = 1;
        do {
            targetDir = new File("jackrabbit-backup" + i++);
        } while (targetDir.exists());
    }
    RepositoryConfig target;
    if (command.hasOption("backup-conf")) {
        target = RepositoryConfig.install(new File(command.getOptionValue("backup-conf")), targetDir);
    } else {
        target = RepositoryConfig.install(targetDir);
    }
    message("Creating a repository copy in " + targetDir);
    RepositoryCopier.copy(source, target);
    message("The repository has been successfully copied.");
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) File(java.io.File)

Example 22 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class BackwardsCompatibilityIT method checkJackrabbitRepository.

private void checkJackrabbitRepository(File directory) throws Exception {
    File configuration = new File(directory, "repository.xml");
    try {
        RepositoryConfig config = RepositoryConfig.create(configuration.getPath(), directory.getPath());
        RepositoryImpl repository = RepositoryImpl.create(config);
        try {
            checkRepositoryContent(repository);
        } finally {
            repository.shutdown();
        }
    } catch (RepositoryException e) {
        String message = "Unable to access repository " + directory;
        log.error(message, e);
        fail(message);
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) RepositoryException(javax.jcr.RepositoryException) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 23 with RepositoryConfig

use of org.apache.jackrabbit.core.config.RepositoryConfig in project jackrabbit by apache.

the class AbstractRepositoryTest method doCreateRepository.

/**
     * Creates a named test repository with the given configuration file.
     *
     * @param name name of the repository
     * @param xml input stream for reading the repository configuration
     * @throws Exception if the repository could not be created
     */
protected void doCreateRepository(String name, InputStream xml) throws Exception {
    File directory = new File(new File("target", "repository"), name);
    File configuration = new File(directory, "repository.xml");
    // Copy the configuration file into the repository directory
    try {
        OutputStream output = FileUtils.openOutputStream(configuration);
        try {
            IOUtils.copy(xml, output);
        } finally {
            output.close();
        }
    } finally {
        xml.close();
    }
    // Create the repository
    try {
        RepositoryConfig config = RepositoryConfig.create(configuration.getPath(), directory.getPath());
        RepositoryImpl repository = RepositoryImpl.create(config);
        try {
            Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
            try {
                createTestData(session);
            } finally {
                session.logout();
            }
        } finally {
            repository.shutdown();
        }
    } catch (RepositoryException e) {
        e.printStackTrace();
        fail("Create repository " + name);
    }
}
Also used : RepositoryConfig(org.apache.jackrabbit.core.config.RepositoryConfig) SimpleCredentials(javax.jcr.SimpleCredentials) OutputStream(java.io.OutputStream) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) RepositoryException(javax.jcr.RepositoryException) File(java.io.File) Session(javax.jcr.Session)

Aggregations

RepositoryConfig (org.apache.jackrabbit.core.config.RepositoryConfig)23 File (java.io.File)10 RepositoryContext (org.apache.jackrabbit.core.RepositoryContext)7 RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)6 RepositoryException (javax.jcr.RepositoryException)5 InputStream (java.io.InputStream)4 Repository (javax.jcr.Repository)4 Session (javax.jcr.Session)4 OutputStream (java.io.OutputStream)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Group (org.apache.jackrabbit.api.security.user.Group)2 User (org.apache.jackrabbit.api.security.user.User)2 RepositoryInitializer (org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Stopwatch (com.google.common.base.Stopwatch)1 FileOutputStream (java.io.FileOutputStream)1 Method (java.lang.reflect.Method)1 Properties (java.util.Properties)1 ZipFile (java.util.zip.ZipFile)1