org.jclouds.scriptbuilder.domain
Class Statements

java.lang.Object
  extended by org.jclouds.scriptbuilder.domain.Statements

public class Statements
extends Object

Statements used in shell scripts.

Author:
Adrian Cole

Constructor Summary
Statements()
           
 
Method Summary
static Statement appendFile(String path, Iterable<String> lines)
           
static Statement appendFile(String path, Iterable<String> lines, String delimeter)
           
static Statement appendFile(String path, String line, String delimeter)
           
static Statement call(String function, String... args)
           
static Statement createOrOverwriteFile(String path, Iterable<String> lines)
           
static Statement createOrOverwriteFile(String path, Iterable<String> lines, String delimeter)
           
static CreateRunScript createRunScript(String instanceName, Iterable<String> exports, String pwd, Iterable<Statement> statements)
           
static Statement exec(String portableStatement)
          interprets and adds a newline to the statement
static Statement extractTargzIntoDirectory(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers, String directory)
          untar, ungzip the data received from the request parameters.
static Statement extractTargzIntoDirectory(URI targz, String directory)
           
static Statement extractZipIntoDirectory(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers, String directory)
          unzip the data received from the request parameters.
static Statement findPid(String args)
          Stores the pid into the variable FOUND_PID if successful.
static Statement forget(String instanceName, String script, String logDir)
          Runs the script in a way that it can be matched later with findPid(java.lang.String)
static Statement interpret(String... portableStatements)
          statement can have multiple newlines, note you should use lf to be portable
static Statement kill()
          Kills the pid and subprocesses related to the variable FOUND_PID if set.
static Statement newStatementList(Statement... statements)
           
static Statement pipeHttpResponseToBash(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers)
          exec the data received from the request parameters.
static Statement rm(String path)
           
static Statement saveHttpResponseTo(URI source, String dir, String file)
           
static Statement switchArg(int arg, Map<String,Statement> valueToActions)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statements

public Statements()
Method Detail

newStatementList

public static Statement newStatementList(Statement... statements)

switchArg

public static Statement switchArg(int arg,
                                  Map<String,Statement> valueToActions)

rm

public static Statement rm(String path)

call

public static Statement call(String function,
                             String... args)

appendFile

public static Statement appendFile(String path,
                                   String line,
                                   String delimeter)

appendFile

public static Statement appendFile(String path,
                                   Iterable<String> lines)

appendFile

public static Statement appendFile(String path,
                                   Iterable<String> lines,
                                   String delimeter)

createOrOverwriteFile

public static Statement createOrOverwriteFile(String path,
                                              Iterable<String> lines)

createOrOverwriteFile

public static Statement createOrOverwriteFile(String path,
                                              Iterable<String> lines,
                                              String delimeter)

createRunScript

public static CreateRunScript createRunScript(String instanceName,
                                              Iterable<String> exports,
                                              String pwd,
                                              Iterable<Statement> statements)

findPid

public static Statement findPid(String args)
Stores the pid into the variable FOUND_PID if successful.

Parameters:
args - - what to search for in the process tree.

forget

public static Statement forget(String instanceName,
                               String script,
                               String logDir)
Runs the script in a way that it can be matched later with findPid(java.lang.String)

Parameters:
instanceName - - what to match the process on
script - - what to run in the background
logDir - - where to write the following logs:
  1. stdout.log
  2. stderr.log

kill

public static Statement kill()
Kills the pid and subprocesses related to the variable FOUND_PID if set.

See Also:
findPid(java.lang.String)

interpret

public static Statement interpret(String... portableStatements)
statement can have multiple newlines, note you should use lf to be portable

See Also:
ShellToken

exec

public static Statement exec(String portableStatement)
interprets and adds a newline to the statement


extractTargzIntoDirectory

public static Statement extractTargzIntoDirectory(String method,
                                                  URI endpoint,
                                                  com.google.common.collect.Multimap<String,String> headers,
                                                  String directory)
untar, ungzip the data received from the request parameters.

Parameters:
method - http method: ex GET
endpoint - uri corresponding to the request
headers - request headers to send
directory -

extractTargzIntoDirectory

public static Statement extractTargzIntoDirectory(URI targz,
                                                  String directory)

extractZipIntoDirectory

public static Statement extractZipIntoDirectory(String method,
                                                URI endpoint,
                                                com.google.common.collect.Multimap<String,String> headers,
                                                String directory)
unzip the data received from the request parameters.

Parameters:
method - http method: ex GET
endpoint - uri corresponding to the request
headers - request headers to send
directory -

saveHttpResponseTo

public static Statement saveHttpResponseTo(URI source,
                                           String dir,
                                           String file)

pipeHttpResponseToBash

public static Statement pipeHttpResponseToBash(String method,
                                               URI endpoint,
                                               com.google.common.collect.Multimap<String,String> headers)
exec the data received from the request parameters.

Parameters:
method - http method: ex GET
endpoint - uri corresponding to the request
headers - request headers to send


Copyright © 2009-2012 jclouds. All Rights Reserved.