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