in vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExportCli.java [57:123]
protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
boolean verbose = cl.hasOption(OPT_VERBOSE);
String type = (String) cl.getValue(optType, "platform");
String jcrPath = (String) cl.getValue(argJcrPath);
String localPath = (String) cl.getValue(argLocalPath);
String root = (String) cl.getValue(argMountpoint);
RepositoryAddress addr = new RepositoryAddress(root);
// shift arguments
if (localPath == null) {
localPath = jcrPath;
jcrPath = null;
}
if (jcrPath == null) {
jcrPath = "/";
}
if (localPath == null) {
if (jcrPath .equals("/")) {
localPath = Text.getName(addr.toString());
} else {
localPath = Text.getName(jcrPath);
}
if (type.equals("jar")) {
localPath += "-" + FMT.format(Instant.now()) + ".jar";
} else {
}
}
File localFile = app.getPlatformFile(localPath, false);
AbstractExporter exporter = null;
try {
VltContext vCtx;
if (type.equals("platform")) {
if (!localFile.exists()) {
localFile.mkdirs();
}
exporter = new PlatformExporter(localFile);
((PlatformExporter) exporter).setPruneMissing(cl.hasOption(optPrune));
vCtx = app.createVaultContext(localFile);
} else if (type.equals("jar")) {
exporter = new JarExporter(localFile);
vCtx = app.createVaultContext(localFile.getParentFile());
} else {
throw new Exception("Type " + type + " not supported");
}
vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
VaultFile vaultFile = vCtx.getFileSystem(addr).getFile(jcrPath);
if (vaultFile == null) {
VaultFsApp.log.error("Not such remote file: {}", jcrPath);
return;
}
VaultFsApp.log.info("Exporting {} to {}", vaultFile.getPath(), localFile.getCanonicalPath());
if (verbose) {
exporter.setVerbose(new DefaultProgressListener());
}
exporter.setNoMetaInf(true);
exporter.export(vaultFile);
VaultFsApp.log.info("Exporting done.");
} finally {
if (exporter != null) {
exporter.close();
}
}
}