Search in sources :

Example 11 with CommandException

use of org.apache.jackrabbit.standalone.cli.CommandException in project jackrabbit by apache.

the class SourceCommand method execute.

/**
     * {@inheritDoc}
     */
public boolean execute(Context ctx) throws Exception {
    File f = new File((String) ctx.get(this.fileKey));
    if (!f.exists()) {
        throw new CommandException("exception.file.not.found", new String[] { f.getAbsolutePath() });
    }
    // client
    JcrClient client = new JcrClient(ctx);
    BufferedReader in = new BufferedReader(new FileReader(f));
    PrintWriter out = CommandHelper.getOutput(ctx);
    String line = null;
    while ((line = in.readLine()) != null) {
        out.println(bundle.getString("word.running") + ": " + line);
        client.runCommand(line);
    }
    in.close();
    return false;
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) CommandException(org.apache.jackrabbit.standalone.cli.CommandException) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

CommandException (org.apache.jackrabbit.standalone.cli.CommandException)11 File (java.io.File)7 Node (javax.jcr.Node)4 BufferedOutputStream (java.io.BufferedOutputStream)3 FileOutputStream (java.io.FileOutputStream)3 InputStream (java.io.InputStream)2 PrintWriter (java.io.PrintWriter)2 Session (javax.jcr.Session)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 URL (java.net.URL)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 NodeIterator (javax.jcr.NodeIterator)1 Repository (javax.jcr.Repository)1