Package org.apache.jackrabbit.vault.util.console

Examples of org.apache.jackrabbit.vault.util.console.ExecutionException


                name = file.getName();
            }
            File local = ctx.getVaultFsApp().getPlatformFile(name, false);
            doGet(file, local, forced);
        } else {
            throw new ExecutionException("'get' only possible in jcr fs context");
        }
    }
View Full Code Here


        }
    }

    private void doGet(VaultFile remote, File local, boolean forced) {
        if (local.exists() && !forced) {
            throw new ExecutionException("Local file already exists. Use -f to overwrite: " + local.getName());
        }
        try {
            FileOutputStream out = new FileOutputStream(local);
            remote.getArtifact().spool(out);
            System.out.println(local.getName() + "  " + local.length() + " bytes.");
            long lastMod = remote.lastModified();
            if (lastMod > 0) {
                local.setLastModified(lastMod);
            }
        } catch (IOException e) {
            throw new ExecutionException("Error while downloading file: " + e);
        } catch (RepositoryException e) {
            throw new ExecutionException("Error while downloading file: " + e);
        }
    }
View Full Code Here

    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);
                }

            }
        }
    }
View Full Code Here

        ConsoleFile wo = ctx.getFile(jcrPath, true);
        if (wo instanceof VaultFsCFile) {
            VaultFile file = (VaultFile) wo.unwrap();
            file.invalidate();
        } else {
            throw new ExecutionException("'cat' only possible in jcr fs context");
        }
    }
View Full Code Here

                    System.out.print(nt.getName());
                    delim = ", ";
                }
                System.out.println();
            } catch (RepositoryException e) {
                throw new ExecutionException("Error while downloading file: " + e);
            }
        } else {
            throw new ExecutionException("'mixins' only possible in repcontext");
        }
    }
View Full Code Here

        ConsoleFile file = ctx.getFile(path, true);
        if (file instanceof AggregateCFile) {
            AggregateImpl node = (AggregateImpl) file.unwrap();
            node.remove(recursive);
        } else {
            throw new ExecutionException("remove only allowed in afct mode.");
        }
    }
View Full Code Here

            Node node = (Node) wo.unwrap();
            try {
                node.refresh(cl.hasOption(optKeepChanges));
                System.out.println("Modifications refreshed.");
            } catch (RepositoryException e) {
                throw new ExecutionException("Error while refreshing: " + e);
            }
        } else {
            throw new ExecutionException("'refresh' only possible in repcontext");
        }
    }
View Full Code Here

                    System.out.flush();
                } else {
                    System.out.printf("Refusing to print contents of a '%s' file.%n", ct);
                }
            } catch (IOException e) {
                throw new ExecutionException("Error while downloading file.",e);
            } catch (RepositoryException e) {
                throw new ExecutionException("Error while downloading file", e);
            }
        } else {
            throw new ExecutionException("'cat' only possible in jcr fs context");
        }
    }
View Full Code Here

                    return new RepositoryCFile(item.getSession().getItem(path));
                } else {
                    return new RepositoryCFile(((Node) item).getNode(path));
                }
            } else {
                throw new ExecutionException("can't cd into property");
            }
        } catch (PathNotFoundException e) {
            throw new FileNotFoundException(path);
        } catch (RepositoryException e) {
            throw new IOException(e.toString());
View Full Code Here

    protected void doExecute(ConsoleExecutionContext ctx, CommandLine cl) throws Exception {
        String macro = (String) cl.getValue(argMacro);
        String cmd = ctx.getProperty("macro." + macro);
        if (cmd == null) {
            throw new ExecutionException("Macro " + macro + " does not exist.");
        }
        ctx.execute(cmd);
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.vault.util.console.ExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.