Package com.redwood.scheduler.api.tool
Interface ToolConnection
-
- All Known Implementing Classes:
ToolConnectionImpl
public interface ToolConnection
A connection to the tools interface.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CAR_MAP_KEY_JOB_ID
Key into result ofuploadCAR(File, String)
for the job id of the jobstatic String
JAR_MAP_KEY_JOB_ID
Key into result ofuploadJAR(File, String)
for the job id of the job
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ToolResultSet
executeQuery(String query, Map<String,String> options, Map<String,Object> parameters)
Execute a query and return the result as a ToolResultSet.String
executeQueryString(String query, Map<String,String> options, Map<String,Object> parameters)
Execute a query and return the result as a String.Long
executeScript(String script, OutputHandler stdout, OutputHandler stderr)
Execute RedwoodScript.String
get(String objectType, String businessKey, boolean search)
REST HTTP GETString
get(String objectType, String businessKey, boolean search, String propertiesSet, Set<String> includeProperties, Set<String> excludeProperties)
REST HTTP GETFile
get(String objectType, String businessKey, String filename, String filepath, boolean search)
REST HTTP GETString
getJobFile(String uniqueId, String destination, String defaultName)
REST HTTP GET JOBFILE Get the jobfile identified by the given uniqueId, and store it in the given directoryString
getLibraries(String filePath)
REST HTTP GET API Libraries for local buildsString
getRestCapabilitiesXML()
Retrieve the WADL file for the REST servlet.File
getScripts(Set<String> items, String filename, String filepath, boolean includeLibraries)
REST HTTP POSTString
getVersion()
REST HTTP GET Versionvoid
importCar(File file, String importRuleSet, OutputStreamOutputHandler stdout, StringBuilderOutputHandler newSboh)
import car filevoid
importCar(File file, String importRuleSet, String targetPartition, OutputStreamOutputHandler stdout, StringBuilderOutputHandler newSboh)
import car fileString
list(String objectType, String filter, String search, boolean stylesheet)
REST HTTP LISTString
list(String objectType, String filter, String search, String check, boolean stylesheet)
REST HTTP LISTString
put(File carFile, boolean async)
REST HTTP PUT CARString
put(String xml, boolean async)
REST HTTP PUT XML fileLong
raiseEvent(String eventName, String raiseComment)
Raise an eventString
scriptsList()
REST HTTP GET SCRIPTS-LIST This method returns all objects that have editable Redwood Script (JobDefinition, Trigger, ExtensionPoint etc.) either as a source, or via related objects like actions.Map<String,BigDecimal>
uploadCAR(File carFile, String importRuleSet)
Upload a CAR file to the server.Map<String,BigDecimal>
uploadCAR(File carFile, String importRuleSet, String targetPartition, Map<String,String> ruleSetParameters)
Upload a CAR file to the server.Map<String,BigDecimal>
uploadJAR(File jarFile, String libraryName)
Upload a JAR file to the server.
-
-
-
Field Detail
-
CAR_MAP_KEY_JOB_ID
static final String CAR_MAP_KEY_JOB_ID
Key into result ofuploadCAR(File, String)
for the job id of the job- See Also:
- Constant Field Values
-
JAR_MAP_KEY_JOB_ID
static final String JAR_MAP_KEY_JOB_ID
Key into result ofuploadJAR(File, String)
for the job id of the job- See Also:
- Constant Field Values
-
-
Method Detail
-
executeScript
Long executeScript(String script, OutputHandler stdout, OutputHandler stderr) throws ToolException
Execute RedwoodScript.- Parameters:
script
- the code to execute (NOT a filename).stdout
- the handler for stderr.stderr
- the handler for stdout.- Returns:
- the return code (may be null).
- Throws:
ToolException
- if an exception occurs.
-
raiseEvent
Long raiseEvent(String eventName, String raiseComment) throws ToolException, EventRaiseException
Raise an event- Parameters:
eventName
- the name of the event to raise.raiseComment
- the raise comment, may be null.- Returns:
- the event id.
- Throws:
ToolException
- if an exception occurs.EventRaiseException
- if the event cannot be raised.
-
executeQueryString
String executeQueryString(String query, Map<String,String> options, Map<String,Object> parameters) throws ToolException, QueryException
Execute a query and return the result as a String.- Parameters:
query
- the query to executeoptions
- options for output (see the documentation for set option value). SeeexecuteQuery(String, Map, Map)
parameters
- parameters to query (see the documentation for bind parameter type value). SeeexecuteQuery(String, Map, Map)
- Returns:
- a string representation of the query results.
- Throws:
QueryException
- if the query caused an errorToolException
- if an exception occurs
-
executeQuery
ToolResultSet executeQuery(String query, Map<String,String> options, Map<String,Object> parameters) throws ToolException, QueryException
Execute a query and return the result as a ToolResultSet.- Parameters:
query
- the query to executeoptions
- options for output (see the documentation for set option value).parameters
- parameters to query (see the documentation for bind parameter type value). Accepted Java parameter types:- String - for String parameters
- Long - for Integer parameters (the majority of numeric values, including UniqueId)
- BigDecimal - for Numbers (mainly in/out values of job parameters)
- Calendar - for DateTimeZone
import com.redwood.scheduler.api.tool.*; public class Main { public static void main(String [] args) throws Exception { ToolConnection con = ToolConnectionFactory.createConnection(args[0], 60000); ToolResultSet rs = con.executeQuery("select JobDefinition.Name, JobDefinition.UniqueId from JobDefinition", null, null); while (rs.next()) { System.out.println(rs.getString(1) + " = " + rs.getString(2)); } } }
- Returns:
- a string representation of the query results.
- Throws:
QueryException
- if the query caused an errorToolException
- if an exception occurs
-
uploadCAR
Map<String,BigDecimal> uploadCAR(File carFile, String importRuleSet) throws IOException, ToolException
Upload a CAR file to the server.- Parameters:
carFile
- the car file to upload, required.importRuleSet
- the import rule set to use, may be null.- Returns:
- a Map containing results from the server. The map will contain the job id of the submitted job, if the server supports it. The result will never be null, but may be an empty map
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
uploadCAR
Map<String,BigDecimal> uploadCAR(File carFile, String importRuleSet, String targetPartition, Map<String,String> ruleSetParameters) throws IOException, ToolException
Upload a CAR file to the server.- Parameters:
carFile
- the car file to upload, required.importRuleSet
- the import rule set to use, may be null.targetPartition
- the target partition, may be null.ruleSetParameters
- the ruleSet parameters, may be null.- Returns:
- a Map containing results from the server. The map will contain the job id of the submitted job, if the server supports it. The result will never be null, but may be an empty map
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
uploadJAR
Map<String,BigDecimal> uploadJAR(File jarFile, String libraryName) throws IOException, ToolException
Upload a JAR file to the server.- Parameters:
jarFile
- the jar file to upload, required.libraryName
- the library to upload it to, required.- Returns:
- a Map containing results from the server. The map will contain the job id of the submitted job, if the server supports it. The result will never be null, but may be an empty map
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
getRestCapabilitiesXML
String getRestCapabilitiesXML() throws ToolException, IOException
Retrieve the WADL file for the REST servlet. When this returns null, none was found (earlier version), and will not throw an exception, even though the server returned an error code.- Returns:
- the WADL file if one exists
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
put
String put(String xml, boolean async) throws ToolException, IOException
REST HTTP PUT XML file- Parameters:
xml
- The XML object to send to the serverasync
- (Optional) async=true - do the request asynchronously- Returns:
- the REST Response
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
put
String put(File carFile, boolean async) throws ToolException, IOException
REST HTTP PUT CAR- Parameters:
carFile
- the CAR file to send to the serverasync
- (Optional) async=true - do the request asynchronously- Returns:
- the REST Response
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
get
String get(String objectType, String businessKey, boolean search) throws ToolException, IOException
REST HTTP GET- Parameters:
objectType
- the object type to get from the REST server.businessKey
- the key of the object to get from the REST serversearch
- if search is true then businessKey is a search pattern to match one or more objects- Returns:
- the XML representation of the object
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
get
String get(String objectType, String businessKey, boolean search, String propertiesSet, Set<String> includeProperties, Set<String> excludeProperties) throws ToolException, IOException
REST HTTP GET- Parameters:
objectType
- the object type to get from the REST server.businessKey
- the key of the object to get from the REST serversearch
- if search is true then businessKey is a search pattern to match one or more objectspropertiesSet
- is the name of the properties set to include in the returned XMLincludeProperties
- are the properties to include on top of the given propertiesSetexcludeProperties
- are the properties to elide from the given propertiesSet- Returns:
- the XML representation of the object
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
get
File get(String objectType, String businessKey, String filename, String filepath, boolean search) throws ToolException, IOException
REST HTTP GET- Parameters:
objectType
- the object type to get from the REST server.businessKey
- the key of the object to get from the REST serverfilename
- the name of the file to be returned (optional)filepath
- the path to store the file when it is downloadedsearch
- if search is true then businessKey is a search pattern to match one or more objects- Returns:
- the CAR file representation of the object
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
getVersion
String getVersion() throws ToolException, IOException
REST HTTP GET Version- Returns:
- the BUILD ID of the server
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
getLibraries
String getLibraries(String filePath) throws ToolException, IOException
REST HTTP GET API Libraries for local builds- Parameters:
filePath
- the directory to store the libraries- Returns:
- the version of the server libraries
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
getJobFile
String getJobFile(String uniqueId, String destination, String defaultName) throws ToolException, IOException
REST HTTP GET JOBFILE Get the jobfile identified by the given uniqueId, and store it in the given directory- Parameters:
uniqueId
- is the uniqueId of the jobfile that must be retrieveddestination
- is the folder where the file will be written todefaultName
- is the name that will be given to the file if the server does not provide with a name.- Returns:
- the name of the file
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
list
String list(String objectType, String filter, String search, boolean stylesheet) throws ToolException, IOException
REST HTTP LIST- Parameters:
objectType
- is the list of objects requestedfilter
- is the name of the query filter to apply when queryingsearch
- is the search to use (on SearchName)stylesheet
- is to indicate if a stylesheet should be used to render the result. The stylesheet used the Document under path doc:/Redwood/REST/Custom_StyleSheet.xml, if that is not set, the default stylesheet doc:/Redwood/REST/Custom_StyleSheet.xml is used- Returns:
- the list of objects
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
list
String list(String objectType, String filter, String search, String check, boolean stylesheet) throws ToolException, IOException
REST HTTP LIST- Parameters:
objectType
- is the list of objects requestedfilter
- is the name of the query filter to apply when queryingsearch
- is the search to use (on SearchName)check
- is the name of the action that will be used to check if the object should be returned. This name will be passed into canPerform() and if it return false, it is not returned in the result. If null is passed in, the default "export" will be used, so only exportable objects will be returned. If the value "none" is passed in, no check will be performed.stylesheet
- is to indicate if a stylesheet should be used to render the result. The stylesheet used the Document under path doc:/Redwood/REST/Custom_StyleSheet.xml, if that is not set, the default stylesheet doc:/Redwood/REST/Custom_StyleSheet.xml is used- Returns:
- the list of objects
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
scriptsList
String scriptsList() throws ToolException, IOException
REST HTTP GET SCRIPTS-LIST This method returns all objects that have editable Redwood Script (JobDefinition, Trigger, ExtensionPoint etc.) either as a source, or via related objects like actions.- Returns:
- the objects that have editable Redwood Script
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
getScripts
File getScripts(Set<String> items, String filename, String filepath, boolean includeLibraries) throws ToolException, IOException
REST HTTP POST- Parameters:
items
- is the list of items to fetch from the serverfilename
- the name of the file to be returned (optional)filepath
- the path to store the file when it is downloadedincludeLibraries
- if true, it will also include the libraries that are referenced by the objects being requested.- Returns:
- the CAR file representation of the object
- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs
-
importCar
void importCar(File file, String importRuleSet, OutputStreamOutputHandler stdout, StringBuilderOutputHandler newSboh) throws ToolException, IOException
import car file- Parameters:
file
- is the car fileimportRuleSet
- is import rule setstdout
- the handler for stderr.newSboh
- the handler for stdout.- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs.
-
importCar
void importCar(File file, String importRuleSet, String targetPartition, OutputStreamOutputHandler stdout, StringBuilderOutputHandler newSboh) throws ToolException, IOException
import car file- Parameters:
file
- is the car fileimportRuleSet
- is import rule settargetPartition
- is import rule setstdout
- the handler for stderr.newSboh
- the handler for stdout.- Throws:
IOException
- if an IO exception occursToolException
- if an exception occurs.
-
-