protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
String cmd = (String) cl.getValue(argCommand);
List args = cl.getValues(argArgs);
if (cmd.equals("getRelated")) {
if (args.size()<1) {
throw new ExecutionException("getRelated. needs path argument.");
}
String path = (String) args.get(0);
ConsoleFile wo = ctx.getFile(path, true);
if (wo instanceof VaultFsCFile) {
VaultFile file = (VaultFile) wo.unwrap();
Collection<? extends VaultFile> related = file.getRelated();
if (related == null) {
System.out.println("(null)");
} else {
for (VaultFile f: related) {
System.out.println(f.getPath());
}
}
} else {
VaultFsApp.log.info("File not a jcrfs file.: {}", path);
}
}
if (cmd.equals("test")) {
if (args.size()<1) {
throw new ExecutionException("test. needs path argument.");
}
String path = (String) args.get(0);
ConsoleFile wo = ctx.getFile(path, true);
if (wo instanceof PlatformFile) {
File file = (File) wo.unwrap();
DefaultWorkspaceFilter r = new DefaultWorkspaceFilter();
try {
r.load(file);
DumpContext dCtx = new DumpContext(new PrintWriter(System.out));
r.dump(dCtx, false);
dCtx.flush();
IOUtils.copy(r.getSource(), System.out);
} catch (Exception e) {
e.printStackTrace();
throw new ExecutionException(e);
}
}
}
}