if (remoteDir == null) {
remoteDir = "/";
}
VaultFile vaultFile = ctx.getFileSystem(mountPoint).getFile(remoteDir);
if (vaultFile == null) {
throw new VltException(remoteDir, "Error during checkout. Remote directory does not exit.");
}
// store filter and config
if (!force) {
DefaultMetaInf inf = (DefaultMetaInf) ctx.getMetaInf();
inf.setConfig(vaultFile.getFileSystem().getConfig());
inf.setFilter(vaultFile.getFileSystem().getWorkspaceFilter());
inf.save(ctx.getExportRoot().getMetaDir());
}
if (ctx.isVerbose()) {
DumpContext dc = new DumpContext(new PrintWriter(ctx.getStdout()));
dc.println("Filter");
ctx.getMetaInf().getFilter().dump(dc, true);
dc.outdent();
dc.flush();
}
String path = PathUtil.getRelativeFilePath(ctx.getCwd().getPath(), localDir.getPath());
ctx.printMessage("Checking out " + vaultFile.getPath() + " to " + path);
VltDirectory dir = new VltDirectory(ctx, localDir);
if (dir.isControlled()) {
if (!force) {
throw dir.getContext().error(dir.getPath(), "already under vault control.");
}
} else {
dir.control(vaultFile.getPath(), vaultFile.getAggregate().getPath());
}
ctx.setMountpoint(vaultFile.getAggregate().getManager().getMountpoint());
// re-open parent dir to avoid problems with zip-meta-dirs
dir = new VltDirectory(ctx, localDir);
Update up = new Update(localDir, null, false);
up.setOnlyControlled(true);
up.setForce(force);
dir.applyWithRemote(up, Collections.<String>emptyList(), false);
ctx.printMessage("Checkout done.");
} catch (IOException e) {
throw new VltException(localDir.getPath(), "Error during checkout", e);
} catch (RepositoryException e) {
throw new VltException(remoteDir, "Error during checkout", e);
}
}