Reference Information
Authentification
Active Directory Connect
More Information
- ActiveDirectoryConnect Example
import com.resolve.connect.ActiveDirectoryConnect;
ActiveDirectoryConnect connect = null;
try {
connect = new ActiveDirectoryConnect("192.168.224.128", 389);
List<Map<String, Object>> response = connect.Search("ou=orgunit,dc=resolvetest-3,dc=com", 2, "(objectClass=*)", null, "resolvetest-3", "resolve", "xxxxx");
//if successful response will have data retrieved from the search
System.out.println(response.size());
} catch (ConnectException e) {
//do something about this exception
} finally {
if (connect != null) {
connect.close();
}
}
- ActiveDirectoryConnect API
Overview
The ActiveDirectoryConnect class provides a wrapper API to communicate with an Active Directory (AD) server.
Active Direct LDAP Connectory Connect
More Information
- LDAPConnect Example
Search with Authentication
This method searches the LDAP server and returns the result in a List of Map. Use of this method requires fairly good understanding of the LDAP server and various configurations. Use this method if your LDAP server requires user authentication.
import com.resolve.connect.LDAPConnect;
LDAPConnect connect = null;
try {
connect = new LDAPConnect("localhost", 10389);
if (connect.isConnected()) {
//here is an example of a typical user name which is actually
//a DN.
String username = "uid=joe,ou=people,dc=LDAP,dc=example,dc=com";
String password = "joepassword";
List < Map < String, Object >> response = connect.search("ou=system", 2, "(objectClass=*)", null, username, password);
for (Map < String, Object > item: response) {
System.out.println(item);
}
} else {
System.out.println("Not connected");
}
} catch (ConnectException e) {
//do something about this exception
} finally {
if (connect != null) {
connect.close();
}
}
Search without Authentication
import com.resolve.connect.LDAPConnect;
LDAPConnect connect = null;
try {
connect = new LDAPConnect("localhost", 10389);
if (connect.isConnected()) {
List <Map<String, Object>> response = connect.search("ou=system", 2, "(objectClass=*)", null);
for (Map <String, Object> item: response) {
System.out.println(item);
}
} else {
System.out.println("Not connected");
}
} catch (ConnectException e) {
//do something about this exception
} finally {
if (connect != null) {
connect.close();
}
}
Overview
The LDAPConnect class provides a wrapper API to communicate with an LDAP server.
Email
EmailConnect
Overview
The EmailConnect class is used to create connections to an email host and allows emails to be sent. It is built upon the javax.mail package.
Invoking the EmailConnect Class
The EmailConnect class can be invoked using one of these four calls:
public EmailConnect(String host, int port)
public EmailConnect(String host, int port, Boolean hasAttachment)
public EmailConnect(String host, int port, String username, String password)
public EmailConnect(String host, int port, String username, String password, Boolean hasAttachment)
Each instance of the EmailConnect class is associated with one Session and one MimeMessage (see javax.mail package for details).
Email Connect Methods
The Email Connect class supports the following API methods:
add Attachment(): Attaches a file to the message. Returns an error message upon failure.
- Signature(s): String add Attachment(File file)
addBCC(): Adds an email address to the 'BCC' field. Returns an error message upon failure.
- Signature(s): String addBCC(String address)
addCC(): Adds an email address to the 'CC' field. Returns an error message upon failure.
- Signature(s): String addCC(String address)
addTo(): Adds an email address to the 'To' field. Returns an error message upon failure.
- Signature(s): String addTo(String address)
getMessage(): Returns the current MimeMessage.
- Signature(s): MimeMessage getMessage()
getSession(): Returns the current Session.
- Signature(s): Session getSession()
send(): Sends the email message. Returns an error message upon failure.
- Signature(s): String send()
setFrom(): Sets the email address in the 'From' field. Returns an error message upon failure.
- Signature(s): String setFrom(String address)
setMessage(): Sets the current MimeMessage.
- Signature(s): void setMessage(MimeMessage message)
setSession(): Sets the current Session.
- Signature(s): void setSession(Session session)
setSubject(): Sets the subject of the message. Returns an error message upon failure.
- Signature(s): String setSubject(String subject)
setText(): Sets the text (body) of the message. Returns an error message upon failure.
- Signature(s): String setText(String text)
close():
- Signature(s): void close()
finalize():
- Signature(s): void finalize()
EmailConnect2
Overview
The EmailConnect2 class that enables connections to an email host and allows emails to be sent. It is built upon the org.apache.commons.mail package.
Databases
DB2DBConnect
Overview
The DB2DBConnect class enables connections to an IBM DB2 database using a JDBC driver.
More Information
- DB2DBConnect Examples
- DB2DBConnect API
Available APIs
The DB2DBConnect class supports the following API calls, which are static methods:
static String get Connector(String hostname, String dbname)
- Returns a correctly formatted URL to connect to the IBM DB2 database using the default port number 50000.
static String getConnectURL(String hostname, int port, String dbname)
- Returns a correctly formatted URL to connect to the IBM DB2 database using the specified port number.
static String getDriver()
- Returns the name of the JDBC driver for IBM DB2.
MySQLDBConnect
More Information
- MySQLDBConnect Examples
- MySQLDBConnect API
Overview
The MySQLDBConnect class enables connections to a MySQL database using a JDBC driver.
The MySQL JDBC driver is not freely distributable but can be downloaded (for free) at http://dev.mysql.com/downloads/connector/j/.
Available APIs
The MySQLDBConnect class supports the following API calls which are static methods:
static String getConnectURL(String hostname, String dbname)
- Returns a correctly formatted URL to connect to the MySQL database using the default port number 3306.
static String getConnectURL(String hostname, int port, String dbname)
- Returns a correctly formatted URL to connect to the MySQL database using the specified port number.
static String getDriver()
- Returns the name of the JDBC driver for MySQL.
InformixDBConnect
More Information
- InformixDBConnect Example
- InformixDBConnect API
Overview
The InformixDBConnect class enables connections to a Informix database using a JDBC driver.
The Informix JDBC driver is not freely distributable but can be downloaded (for free) after registering as an IBM developer at: Download Informix JDBC driver.
Place the driver .jar file in the lib folder (requires blueprint parameter "rsremote.run.informix" set to "true") or into the rsremote/lib folder to be used by the RSRemote.
Available APIs
The InformixDBConnect class supports the following API calls. These are static methods.
static String getConnectURL(String hostname, String dbname, String servername)
- Returns a correctly formatted URL to connect to the Informix database using the default port number 1526.
static String getConnectURL(String hostname, int port, String dbname, String servername)
- Returns a correctly formatted URL to connect to the Informix database using the specified port number.
static String getConnectURL(String hostname, String port, String dbname, String servername)
- Returns a correctly formatted URL to connect to the Informix database using the specified port number.
static String getConnectURL(String hostname, String dbname, String servername, String username, String password)
- Returns a correctly formatted URL to connect to the Informix database using the default port number 1526.
static String getDriver()
- Returns the name of the JDBC driver for the Informix database.
OracleDBConnect
More Information
- OracleDBConnect Examples
- OracleDBConnect API
Overview
The OracleDBConnect class enables connections to an Oracle database using a JDBC driver.
Available APIs
The OracleDBConnect class supports the following API calls. These are static methods.
static String getConnectURL(String hostname, String dbname)
- Returns a correctly formatted URL to connect to the Oracle database using the default port number 1521.
static String getConnectURL(String hostname, int port, String dbname)
- Returns a correctly formatted URL to connect to the Oracle database using the specified port number.
static String getConnectURL(String hostname, String port, String dbname)
- Returns a correctly formatted URL to connect to the Oracle database using the specified port number. If port is not numeric, then an error is thrown.
static String getDriver()
- Returns the name of the JDBC driver for the Oracle database.
MariaDBConnect
More Information
- MariaDBConnect Examples
- MariaDBConnect API
Overview
The MariaDBConnect class enables connections to a MariaDB database using a JDBC driver.
Available APIs
The MariaDBConnect class supports the following API calls. These are static methods.
static String getConnectURL(String hostname, String dbname)
- Returns a correctly formatted URL to connect to the Maria database using the default port number 3306.
static String getConnectURL(String hostname, int port, String dbname)
- Returns a correctly formatted URL to connect to the Maria database using the specified port number.
static String getDriver()
- Returns the name of the JDBC driver for the Maria database.
PostgreSQLDBConnect
More Information
- PostgreSQLDBConnect Example
- PostgreSQLDBConnect API
Overview
The PostgreSQLDBConnect class enables connections to a PostgreSQL database using a JDBC driver.
Available APIs
The PostgreSQLDBConnect class supports the following API calls. These are static methods.
static String getConnectURL(String hostname, String dbname)
- Returns a correctly formatted URL to connect to the PostgreSQL database using the default port number 5432.
static String getConnectURL(String hostname, int port, String dbname)
- Returns a correctly formatted URL to connect to the PostgreSQL database using the specified port number.
static String getConnectURL(String hostname, String port, String dbname)
- Returns a correctly formatted URL to connect to the PostgreSQL database using the specified port number.
static String getDriver()
- Returns the name of the JDBC driver for the PostgreSQL database.
MSSQLDBConnect
More Information
- MSSQLDBConnect Example
- MSSQLDBConnect API
Overview
The MSSQLDBConnect class enables connections to a Microsoft SQL database using a JDBC driver.
Available APIs
The MSSQLDBConnect class supports the following API calls which are static methods:
static String getConnectURL(String hostname, String dbname)
- Returns a correctly formatted URL to connect to the Microsoft SQL database using the default port number 1433.
static String getConnectURL(String hostname, int port, String dbname)
- Returns a correctly formatted URL to connect to the Microsoft SQL database using the specified port number.
static String getDriver()
- Returns the name of the JDBC driver for Microsoft SQL Server.
SybaseDBConnect
More Information
- SybaseDBConnect Example
- SybaseDBConnect API
Overview
The SybaseDBConnect class enables connections to a Sybase database using a JDBC driver.
Available APIs
The SybaseDBConnect class supports the following API calls. These are static methods.
static String getConnectURL(String hostname)
- Returns the Sybase JDBC driver URL using the default port of 7100. It is not recommended to use the default port number. The username and password must still be supplied elsewhere in order for the connection to succeed.
static String getConnectURL(String hostname, int port)
- Returns the appropriate Sybase JDBC driver URL. The username and password must still be supplied elsewhere in order for the connection to succeed.
static String getConnectURL(String hostname, int port, String dbname)
- Returns the appropriate Sybase JDBC driver URL. The username and password must still be supplied elsewhere in order for the connection to succeed.
static String getConnectURL(String hostname, String dbname)
- Returns the Sybase JDBC driver URL using the default port of 7100. The username and password must still be supplied elsewhere in order for the connection to succeed.
static String getDriver()
- Returns the name of the JDBC driver for the Sybase database.
Web
WebServiceConnect
More Information
- WebServiceConnect Example
- WebServiceConnect API
Overview
The WebServiceConnect class is used to communicate with third-party webservices. When communicating with a third-party system using the WebServiceConnect adaptor, start by creating a connection, then sending information or other communication requests.
HTTPConnect
More Information
- HTTPConnect Example
Overview
The HTTPConnect class enables HTTP connections using URIs.
Invoking the HTTPConnect Class
The HTTPConnect class can be invoked using one of these two calls:
public HTTPConnect()
public HTTPConnect(Map < String, String > properties)
Default uri is http://localhost
. This should be changed later. Add properties key-value pairs such as \["Content-Type", "text/xml; charset=utf-8"\], which is a default property for "Content-Type". The constructor automatically opens the connection, if possible.
HTTPConnect Methods
The HTTPConnect class supports the following API methods. The expect() method is referenced in many other methods, including its use of regular expressions and Patterns (see java.util.regex.Pattern package for details) as well as its storage of previously read content and Pattern matches.
Specific Methods
These methods are more specific to the HTTPConnect class.
addProperty(): Adds a key-value pair representation of a property.
- Signature(s): void addProperty(String keyOrProperty, String value)
getMessage(): Returns the message that will be sent to the host.
- Signature(s): String getMessage()
getProperties(): Returns the current key-value pair representation of properties.
- Signature(s): Map getProperties()
getProperty(): Returns the value associated with the property.
- Signature(s): String getProperty(String keyOrProperty)
getUri(): Returns the current URI to be used.
- Signature(s): String getUri()
send(): Sends a message to the host. Uses stored URI, message, and properties unless they are specified. Host response is stored in the Reader.
Signature(s):
- void send()
- void send(String uri)
- void send(String uri, String message)
- void send(String uri, String message, Map properties)
setMessage(): Sets the message to be sent to the host.
- Signature(s): void setMessage(String message)
setProperties(): Sets the properties key-value pairs.
- Signature(s): void setProperties(Map properties)
setUri(): Sets the URI to be used.
- Signature(s): void setUri(String uri)
General Methods
These methods are also implemented by the HTTPConnect class. They are more general and have the same implementation across various other classes. Each instance is associated with a Reader which reads information from the connected service.
clear(): Clears the Reader.
- Signature(s): void clear()
close(): Closes the connection.
- Signature(s): void close()
connect(): Opens the connection. This is a necessary condition for many other methods, and it is usually taken care of by the constructor of the Adaptor class.
- Signature(s): void connect()
expect(): Receives data/information from the connected service, which can be used for future comparisons, manipulations, etc. Simple call, expect(), is the same as read(). Other calls returns first match to pattern (or any pattern in a List of patterns). Excluding the simple call, saves all previously read content along with the most current match to the last defined pattern. Saved content can be retrieved by other methods. Throws an error if the connection has not been opened.
Signature(s):
- String expect()
- byte[] expect(byte[] pattern)
- byte[] expect(byte[] pattern, long timeout)
- String expect(String pattern)
- String expect(String pattern, long timeout)
- String expect(List patterns)
- String expect(List patterns, long timeout)
finalize(): Closes the connection. Will catch errors or exceptions.
- Signature(s): void finalize()
getContent(): Returns all content read by the Reader from all previous calls to expect().
- Signature(s): String getContent()
getMatchPattern(): Returns the current regular expression pattern to be matched.
- Signature(s): String getMatchPattern()
getOptions(): Returns the options which determine how the regular expression is compiled into a Pattern.
- Signature(s): int getOptions()
getPostMatch(): Returns the current match to the regular expression pattern given by expect().
- Signature(s): String getPostMatch()
isLastExpectTimeout(): Returns true if the previous expect() call returned due to a timeout rather than an output match.
- Signature(s): boolean isLastExpectTimeout()
read(): The Reader reads content from the input stream and returns the content. Does not save for getContent(). Throws an error if a connection has not been opened.
- Signature(s): String read()
readByte(): The Reader reads content from the input stream and returns the content. Throws an error if a connection has not been opened.
- Signature(s): byte[] readByte()
setDefaultTimeout(): Sets the default timeout, in seconds. (Original value is 10 seconds.)
- Signature(s): void setDefaultTimeout(long timeout)
setOptions(): Sets the options which determine how the regular expression is compiled into a Pattern.
- Signature(s): void setOptions(int options)
sleep(): Pauses the thread running the Adaptor class, in seconds.
- Signature(s): void sleep(long seconds)
WSConnect
More Information
- WSConnect Example
- WSConnect API
Overview
The WSConnect class enables connections using URIs and XML properties.
Invoking the WSConnect Class
The WSConnect class can be invoked using one of these four calls:
public WSConnect(String uri)
public WSConnect(String uri, HashMap<String, String> xmlProperties)
Each instance of the WSConnect class is associated with a HashMap of XML properties. The default entry, ["Content-Type", "text/xml; charset=utf-8"], is put in by the constructor.
WSConnect Methods
The WSConnect class supports the following API methods:
connect(): Connects to the web service using the stored URI. Throws an error upon failure.
- Signature(s): void connect()
createDefaultXMLProperties(): Puts the default XML property in the Hashmap. Called by the constructor.
- Signature(s): void createDefaultXMLProperties()
getProperties(): Returns the XML properties.
- Signature(s): HashMap<String, String> getProperties()
getProperty(): Returns the value of the specific property.
- Signature(s): String getProperty(String nameOfProperty)
initConnectionProperties(): Adds initial properties to the HashMap. Called internally.
- Signature(s): void initConnectionProperties()
send(): Sends xml to the web service and returns the response.
- Signature(s): String send(String xml)
setProperties(): Sets the HashMap of properties.
- Signature(s): void setProperties(HashMap<String, String> xmlProperties)
setProperty(): Adds the property to the HashMap.
- Signature(s): void setProperty(String nameOfProperty, String value)
WebConnect
More Information
- WebConnect Example
- WebConnect API
Overview
The WebConnect class facilitates connecting to, receiving information from, and sending information to a web page.
Invoking the WebConnect Class
The WebConnect class can be invoked using one of these two calls:
public WebConnect()
public WebConnect(Boolean debug)
Default values: debug = false.
Debug determines if the System property is "debug" (see java.lang.System package for details). The constructor automatically opens the connection, if possible.
WebConnect Methods
The WebConnect class supports the following API methods. The expect() method is referenced in many other methods, including its use of regular expressions and Patterns (see java.util.regex.Pattern package for details) as well as its storage of previously read content and Pattern matches.
Specific Methods
These methods are more specific to the WebConnect class.
get(): Connects to a website. If a path is given, it then attempts to connect to the given path, or else the default (http://localhost/) is used. It will throw an error if the connection fails.
- Signature(s): void get(), void get(String path)
getCookie(): Returns the cookie, null if there is none.
- Signature(s): String getCookie()
getParams(): Returns the parameters.
- Signature(s): Map getParams()
post(): Posts to a website. If a path is given, then it attempts to post to the given path, or else the default (http://localhost/) is used.. It will throw an error if posting fails.
- Signature(s): void post(), void post(String path)
send(): Calls get() with the argument.
- Signature(s): void send(String path)
setCookie(): Sets the cookie.
- Signature(s): void setCookie(String cookie)
setHost(): Sets the host to connect to.
- Signature(s): void setHost(String host)
setParams(): Sets the parameters.
- Signature(s): void setParams(Map params)
setURI(): Sets the URI path.
- Signature(s): void setURI(String uri)
setURL(): Sets the URL path.
- Signature(s): void setURL(String url)
General Methods
These methods are also implemented by the WebConnect class. They are more general and have the same implementation across various other classes. Each instance is associated with a Reader which reads information from the connected service.
clear(): Clears the Reader.
- Signature(s): void clear()
close(): Closes the connection.
- Signature(s): void close()
connect(): Opens the connection. This is a necessary condition for many other methods, and it is usually taken care of by the constructor of the Adaptor class.
- Signature(s): void connect()
expect(): Receives data/information from the connected service, which can be used for future comparisons, manipulations, etc. Simple call, expect(), is the same as read(). Other calls returns first match to pattern (or any pattern in a List of pattersn). Excluding the simple call, saves all previously read content along with the most current match to the last defined pattern. Saved content can be retrieved by other methods. . It will throw error if the connection has not been opened.
- Signature(s):
- String expect()
- byte[] expect(byte[] pattern)
- byte[] expect(byte[] pattern, long timeout)
- String expect(String pattern)
- String expect(String pattern, long timeout)
- String expect(List patterns)
- String expect(List patterns, long timeout)
finalize(): Closes the connection. It will catch errors or exceptions.
- Signature(s): void finalize()
getContent(): Returns all content read by the Reader from all previous calls to expect().
- Signature(s): String getContent()
getMatchPattern(): Returns the current regular expression pattern to be matched.
- Signature(s): String getMatchPattern()
getOptions(): Returns the options which determine how the regular expression is compiled into a Pattern.
- Signature(s): int getOptions()
getPostMatch(): Returns the current match to the regular expression pattern given by expect().
- Signature(s): String getPostMatch()
isLastExpectTimeout(): Returns true if the previous expect() call returned due to a timeout rather than an output match.
- Signature(s): boolean isLastExpectTimeout()
read(): The Reader reads content from the input stream and returns the content. Does not save for getContent().. It will throw an error if a connection has not been opened.
- Signature(s): String read()
readByte(): The Reader reads content from the input stream and returns the content. . It will throw an error if a connection has not been opened.
- Signature(s): byte[] readByte()
setDefaultTimeout(): Sets the default timeout, in seconds. (Original value is 10 seconds.)
- Signature(s): void setDefaultTimeout(long timeout)
setOptions(): Sets the options which determine how the regular expression is compiled into a Pattern.
- Signature(s): void setOptions(int options)
sleep(): Pauses the thread running the Adaptor class, in seconds.
- Signature(s): void sleep(long seconds)
WSLiteConnect
More Information
- WSLiteConnect Example
- WSLiteConnect API
Overview
The WSLiteConnect class enables connections using URIs and XML properties.
HTMLConnect
More Information
- HTMLConnect Example
- HTMLConnect API
Overview
The HTMLConnect class allows an ActionTask to retrieve data from and interact with webpages.
Remote Devices
SSHConnect
More Information
- SSHConnect Example
- SSHConnect API
Overview
The SSHConnect class is used to create secure shell connections to a remote host.
Establishing a Connection
Connection and interaction code should be placed in a try/catch block so that errors while trying to connect can be handled. Remember to always close the connection when finished. For all constructors, the default port number is '22' and the default timeout (in seconds) is '0'. All constructors open the connection, if possible. An SSH connection can be made using one of the following modes:
- PASSWORD
- PUBLIC KEY
- QUERY
- INTERACTIVE
PASSWORD
In this mode, the client provides a password to authenticate. This is one of the more preferred modes and most used modes to connect to a remote host. A snippet of how to use this:
try {
// Default port '22', default timeout '0'
conn = new SSHConnect(username, password, ipaddress);
// other options
// conn = new SSHConnect(username, password, ipaddress, port);
// conn = new SSHConnect(username, password, ipaddress, port, timeout);
...
}
PUBLIC KEY
This is a more secure way to acquire a connection as compared to the other modes. This client provides a private key file and passphrase to get a connection to the host.
try {
// Default port '22', default timeout '0'
conn = new SSHConnect(username, privateKeyFileName, privateKeyPassphrase, ipaddress4 );
// other options
// conn = new SSHConnect(username, privateKeyFileName, privateKeyPassphrase, ipaddress, port);
// conn = new SSHConnect(username, privateKeyFileName, privateKeyPassphrase, ipaddress, port, timeout);
...
}
INTERACTIVE
In this mode, the host ask a series of questions and the client prepares the response and provides the list of answers while connecting. For example, the host might have questions for username, password, security question, and security answer. The QUERY mode (see below) can sometimes be used to determine what kind of questions will the host ask, then based on that, allow the client to more easily prepare the list of responses and connect to the host.
// prepare the list of responses
def responses = new ArrayList();
// answer to the question - username
responses.add("john.doe");
// answer to "password"
responses.add("A&ree34$");
try {
// use the INTERACTIVE mode to get a connection
// Default port '22', default timeout '0'
conn = new SSHConnect(username, responses, ipaddress);
// other options
// conn = new SSHConnect(username, responses, ipaddress, port);
// conn = new SSHConnect(username, responses, ipaddress, port, timeout);
...
}
QUERY
QUERY can be used to determine the type of connections a host will accept. The QUERY mode can also sometimes be used to prepare the list of responses for the INTERACTIVE mode.
import com.resolve.connect.SSHConnect;
def username = INPUTS["USERNAME"];
def ipaddress = INPUTS["IPADDRESS"];
def prompt = INPUT["PROMPT"];
def conn = null;
def response = null;
try {
// use the QUERY mode to check out the list of questions that the host is asking
// This will throw an exception with list of questions from the host
// Default port '22', default timeout '0'
conn = new SSHConnect(username, ipaddress);
// other options
// conn = new SSHConnect(username, ipaddress, port);// default timeout '0'
// conn = new SSHConnect(username, ipaddress, port timeout);
conn.expect(prompt);
} catch (Exception e) {
// questions asked by the host. The questions are separated by commas.
response = e.getMessage();
} finally {
conn.close();
}
Sending Commands
Sending commands over the connection is similar to expect scripting. The basic steps are:
- Send a command string
- Wait for a known expected result (string) at the end of the response
- Retrieve results
The send() method is used to send commands. Once a command has been sent, the expect() method is used to wait for the results. The expect() method should be passed a pattern to look for in the response from the server. It will use this to know when the command is finished processing. Typically the terminal prompt is used as the pattern.
The following executes the "df -h" command, waits for the results, then sends the "ls" command:
def prompt = "\\\$";
def response = ""
conn.send("df -h")
response += conn.expect(prompt) + "\n"
conn.send("ls")
response += conn.expect(prompt) + "\n"
Closing the Connection
Remember to always close SSH connections when finished. This should be done in the 'finally' block of the try/catch.
finally {
conn.close();
}
SSHConnect Methods
The SSHConnect class supports the following API methods. The expect() method is referenced in many other methods, including its use of regular expressions and Patterns (see java.util.regex.Pattern package for details) as well as its storage of previously read content and Pattern matches.
Specific Methods
These methods are more specific to the SSHConnect class.
- close(): Closes the SSH Connection. Place it in the 'finally' block to make sure the connection is closed after use.
- Signature(s): void close()
- get(): Uses SCP to transfer a remote file to the local system. Returns true upon success. Thros an error if the local path is not valid.
- Signature(s): boolean get(String remoteFile, String localDirectory)
- put(): SCP a file from the local system to a remote system. Unless specified, default location on the remote system is the Home directory and the default mode is 0644. Throws errors if the local file cannot be found or mode is not a number.
- Signature(s):
void put(File fromFile)
void put(File fromFile, String toDirectory)
void put(File fromFile, String toDirectory, String mode)
void put(String fileName)
void put(String fileName, String toDirectory)
void put(String fileName, String toDirectory, String mode)
- Signature(s):
- send(): Clears the reader and then writes to host output stream. Throws an error if the connection has not been opened.
- Signature(s): void send(String line)
General Methods
These methods are also implemented by the SSHConnect class. They are more general and have the same implementation across various other classes. Each instance is associated with a Reader which reads information from the connected service.
- clear(): Clears the Reader.
- Signature(s): void clear()
- expect(): Recieves data/information from the connected service, which can be used for future comparisons, manipulations, etc. Simple call, expect(), is the same as read(). Other calls returns first match to pattern (or any pattern in a List of pattersn). Excluding the simple call, saves all previously read content along with the most current match to the last defined pattern. Saved content can be retrieved by other methods. Throws an error if the connection has not been opened.
- Signature(s):
- String expect()
- byte[] expect(byte[] pattern)
- byte[] expect(byte[] pattern, long timeout)
- String expect(String pattern)
- String expect(String pattern, long timeout)
- String expect(List patterns)
- String expect(List patterns, long timeout)
- Signature(s):
- getContent(): Returns all content read by the Reader from all previous calls to expect().
- Signature(s): String getContent()
- isLastExpectTimeout(): Returns true if the previous expect() call returned due to a timeout rather than an output match.
- Signature(s): boolean isLastExpectTimeout()
TN3270oConnect
More Information
- TN3270oConnect Example
- TN3270oConnect API
Overview
The TN3270oConnect class enables telnet 3270 data streams to a remote host using the iOhioScreen terminal emulator.
Invoking the TN3270oConnect Class
The TN3270oConnect class is invoked with this constructor:
TN3270oConnect(String host, int port)
The constructor opens the connection, if possible.
T3270oConnect Methods
The T3270oConnect class supports the following API methods.
Connectivity and Session Management
close(): Closes the connection. All connection resources are released.
- Signature(s): void close()
connect(): Opens a connection. Not needed unless a connection is explicitly closed or disconnected.
- Signature(s): void connect()
disconnect(): Closes the connection. All connection resources are released. Does not write to Log.
- Signature(s): void disconnect()
finalize(): Closes the connection. All connection resources are released.
- Signature(s): void finalize()
Getting and Setting the Cursor Position
getCursor(): Returns the location of the cursor in the terminal emulator.
- Signature(s): iOhioPosition getCursor()
setCursor(): Sets the location of the cursor in the terminal emulator.
- Signature(s): void setCursor(iOhioPosition position), void setCursor(int row, int col)
Getting the OhioScreen Object and Object Metadata
getScreen(): Retrieves the OhioScreen object.
- Signature(s): OhioScreen getScreen()
Getting Data at a Specified Location
getData(): Returns a string based on a starting cursor position and either the stopping cursor position, or string length. Start and end point positions are included in the returned value.
- Signature(s):
- String getData(iOhioPosition position, int len)
- String getData(int row, int col, int len)
- String getData(iOhioPosition startPos, iOhioPosition endPos)
- String getData(int startRow, int startCol, int endRow, int endCol)
Sending Strings and Keys to the Host/Terminal Emulator
With the following functions, the values are sent to the current location of the cursor. Use setCursor() first if necessary to specify a location. See the org.osohio.screen.OhioScreen package for key mappings.
send(): Sends a string value.
- Signature(s): void send(String value), void send(String value, iOhioPosition position), void send(String value, int row, int col)
sendEnter(): Sends the "Enter" key.
- Signature(s): void sendEnter()
sendKey(): Sends a key, typically a function key. Any location other that the current cursor position can be specified.
Signature(s):
- void sendKey(String value)
- void sendKey(String value, iOhioPosition position)
- void sendKey(String value, int row, int col)
- void sendKey(int value)
- void sendKey(int value, iOhioPosition position)
- void sendKey(int value, int row, int col)
sendFunctionKey(): Sends a function key.
- Signature(s): void sendFunctionKey(int value)
sendAidKey(): Sends an aid key. The aid keys is a single special keystroke, such as the "Enter" key, the "Tab" key, or the "Page Up" key.
- Signature(s): void sendAidKey(int value)
Waiting for the Screen to Refresh
waitForScreen(): Instructs the application to wait for the terminal emulator virtual screen to refresh. Timeout, if specified, is in seconds. Default is 10 seconds.
- Signature(s): boolean waitForScreen(), boolean waitForScreen(int timeout)
Displaying the Virtual Screen
printScreen(): Displays the current contents of the virtual screen to the user's display. Typically, the client should first issue the waitForScreen() command to give any pending emulator commands a chance to process.
- Signature(s): String printScreen()
Objects
In addition to standard data types, the APIs may take or return the following objects:
iOhioPosition: An object containing the integer row and integer column of a position
- iOhioPosition(int initRow, int initCol): Constructor initializes row and column values.
- Int getRow(): Returns the row value.
- Int getColumn(): Returns the column value.
- Void setRow(int row): Sets the row value.
- Void setColumn(int col): Sets the column value.
OhioScreen: An object of the presentation space (see org.ohio.iOhio package for details).
SocketConnect
More Information
- SocketConnect Example
- SocketConnect API
Overview
The SocketConnect class is used to create socket connections to a remote host. It allows Resolve Actions Pro to receive unformatted data from any device.
Invoking the SocketConnect Class
The SocketConnect class can be invoked using one of the following calls:
public SocketConnect(String hostname, int port)
public SocketConnect(String hostname,intport, int timeout)
Each instance of the SocketConnect class is associated with one Socket (see java.net.Socket package for details). Timeout is in milliseconds and default timeout is 0. The constructor automatically opens the connection, if possible.
SocketConnect Methods
The SocketConnect class supports the following API methods. The expect() method is referenced in many other methods, including its use of regular expressions and Patterns (see java.util.regex.Pattern package for details) as well as its storage of previously read content and Pattern matches.
Specific Methods
These methods are more specific to the SocketConnect class.
close(): Disconnects the Socket connection.
- Signature(s): void close()
flush(): Flushes the output stream.
- Signature(s): void flush()
isConnected(): Returns true if the Socket is currently connected to the host.
- Signature(s): boolean isConnected()
send(): Clears the Reader and then writes to the output stream. If a character set such as US-ASCII or UTF-8 has been defined, encodes before writing. Throws an error if the connection has not been opened.
Signature(s): void send(String line), void send(byte[] data)
setCharset(): Sets the character set to encode. Default is null.
- Signature(s): void setCharset(String charset)
General Methods
These methods are also implemented by the SocketConnect class. They are more general and have the same implementation across various other classes. Each instance is associated with a Reader which reads information from the connected service.
clear(): Clears the Reader.
- Signature(s): void clear()
connect(): Opens the connection. This is a necessary condition for many other methods, and it is usually taken care of by the constructor of the Adaptor class.
- Signature(s): void connect()
expect(): Receives data/information from the connected service, which can be used for future comparisons, manipulations, etc. Simple call, expect(), is the same as read(). Other calls returns first match to pattern (or any pattern in a List of pattersn). Excluding the simple call, saves all previously read content along with the most current match to the last defined pattern. Saved content can be retrieved by other methods. Throws an error if the connection has not been opened.
Signature(s):
String expect()
byte[] expect(byte[] pattern)
byte[] expect(byte[] pattern, long timeout)
String expect(String pattern)
String expect(String pattern, long timeout)
String expect(List patterns)
String expect(List patterns, long timeout)
finalize(): Closes the connection. Will catch errors or exceptions.
- Signature(s): void finalize()
getContent(): Returns all content read by the Reader from all previous calls to expect().
- Signature(s): String getContent()
getMatchPattern(): Returns the current regular expression pattern to be matched.
- Signature(s): String getMatchPattern()
getOptions(): Returns the options which determine how the regular expression is compiled into a Pattern.
- Signature(s): int getOptions()
getPostMatch(): Returns the current match to the regular expression pattern given by expect().
- Signature(s): String getPostMatch()
isLastExpectTimeout(): Returns true if the previous expect() call returned due to a timeout rather than an output match.
- Signature(s): boolean isLastExpectTimeout()
read(): The Reader reads content from the input stream and returns the content. Does not save for getContent(). Throws an error if a connection has not been opened.
- Signature(s): String read()
readByte(): The Reader reads content from the input stream and returns the content. Throws an error if a connection has not been opened.
Signature(s): byte[] readByte()
setDefaultTimeout(): Sets the default timeout, in seconds. (Original value is 10 seconds.)
- Signature(s): void setDefaultTimeout(long timeout)
setOptions(): Sets the options which determine how the regular expression is compiled into a Pattern.
- Signature(s): void setOptions(int options)
sleep(): Pauses the thread running the Adaptor class, in seconds.
- Signature(s): void sleep(long seconds)
VTConnect
More Information
- VTConnect Examples
- VTConnect API
Overview
The VTConnect class is used to create telnet (ex. VT100) connections to a remote host.
Invoking the VTConnect Class
The VTConnect class can be invoked using one of these three calls:
public VTConnect(String sessionName, String host, int port)
public VTConnect(String sessionName, String hos int port, String terminalType)
public VTConnect(String sessionName, String host, int port, String terminalType, String sslKeyFile, String sslKeyPassword)
The constructor opens the connection, if possible.
VTConnect Methods
The VTConnect class supports the following API methods: Connectivity and Session Management
abort(): Aborts the current session.
- Signature(s): void abort()
close(): Closes the session.
- Signature(s): void close()
finalize(): Closes the session.
- Signature(s): void finalize()
getLoggable(): Returns the logger.
- Signature(s): Loggable getLoggable()
getName(): Returns the session name.
- Signature(s): String getName()
getProperties(): Returns the Jagacy properties.
- Signature(s): JagacyProperties getProperties()
open(): Opens a session.
- Signature(s): void open(), void open(String answerback), void open(String sslKeyFile, String sslKeyPassword), void open(String answerback, String sslKeyFile, StringsslKeyPassword)
Location and Display Management
createLocation(): Creates a Location object.
- Signature(s): Location createLocation(int row, int column), Location createLocation(String propertyPrefix)
createUi(): Creates a user interface.
- Signature(s): protected UserInterface createUi()
getHeight(): Returns the screen's height.
- Signature(s): int getHeight()
getWidth(): Returns the screen's width.
- Signature(s): int getWidth()
isInsertOn(): Determines if insert is on or not.
- Signature(s): boolean isInsertOn()
isLedOn(): Determines if an LED is on or not.
Signature(s): boolean isLedOn(int led)
UserInterface(): Creates a user interface.Signature(s): protected abstract UserInterface createUi()
Reading Values
read(): Reads a string at the current cursor position or property.
- Signature(s): String read(int length), String read(String lengthProperty)
readAlarmCount(): Returns the number of times the alarm has sounded.
- Signature(s): long readAlarmCount()
readCursorLocation(): Returns the cursor location.
- Signature(s): Location readCursorLocation()
readPosition(): Returns a string at the given location or coordinates.
- Signature(s): String readPosition(int row, int column, int length), String readPosition(Location location, int length), String readPosition(String propertyPrefix)
readRow(): Returns the row.
- Signature(s): String readRow(introw)
readScreen(): Returns the screen.
- Signature(s): String[] readScreen()
readScreenText(): Returns the screen as character text.
- Signature(s): char[] readScreenText()
Writing Values
writeAfterLabel(): Writes a string in the next unprotected field after a protected label.
- Signature(s): void writeAfterLabel(String propertyPrefix), void writeAfterLabel(String label, String value)
writeAfterLabelProperty(): Writes a string in the next unprotected field after a protected label.
- Signature(s): void writeAfterLabelProperty(String labelProperty, String value)
writeCursor(): Writes the cursor at the given coordinates or location.
- Signature(s): void writeCursor(int row, int column), void writeCursor(Location location), void writeCursor(String propertyPrefix)
writeKey(): Writes the given key.
- Signature(s): Key writeKey(Key key), Key writeKey(String keyProperty)
writePosition(): Writes a string at the given coordinates or location.
- Signature(s): void writePosition(int row, int column, String value), void writePosition(Location location, String value), void writePosition(String propertyPrefix), void writePosition(String propertyPrefix, String value)
writeProperty(): Writes the contents of valueProperty at the current cursor position.
- Signature(s): void writeProperty(String valueProperty)
writeString(): Writes a string at the current cursor position.
- Signature(s): void writeString(String value)
Waiting for Events
waitForChange(): Waits for the screen to change and the keyboard to unlock.
- Signature(s):
- boolean waitForChange(intmainTimeout, int trailingTimeout)
- boolean waitForChange(int mainTimeout, inttrailingTimeout, String tag)
- boolean waitForChange(int timeout, String tag)
- boolean waitForChange(String mainTimeoutProperty, String trailingTimeoutProperty)
- boolean waitForChange(String mainTimeoutProperty, String trailingTimeoutProperty, String tagProperty)
- boolean waitForChange(inttimeout)
- boolean waitForChange(String timeoutProperty)
waitForChangeProperty(): Waits for the tag to be received and the keyboard to unlock.
- Signature(s): boolean waitForChangeProperty(String timeoutProperty, String tagProperty)
waitForPosition(): Waits (in INTERNAL_WAIT millisecond intervals) for the value to appear at the given coordinates or Location.
- Signature(s):
- boolean waitForPosition(int row, int column, String value, int mainTimeout, int trailingTimeout)
- boolean waitForPosition(Location location, String value, int mainTimeout, int trailingTimeout)
- boolean waitForPosition(String propertyPrefix, int mainTimeout, int trailingTimeout)
- boolean waitForPosition(String propertyPrefix, String value, int mainTimeout, int trailingTimeout)
- boolean waitForPosition(String propertyPrefix, String value, String mainTimeoutProperty, String trailingTimeoutProperty)
- boolean waitForPosition(int row, int column, String value, int timeout)
- boolean waitForPosition(Location location, String value, int timeout)
- boolean waitForPosition(String propertyPrefix, int timeout)
- boolean waitForPosition(String propertyPrefix, String timeoutProperty)
- boolean waitForPosition(String propertyPrefix, String value, int timeout)
- boolean waitForPosition(String propertyPrefix, String value, String timeoutProperty)
waitForPositionProperty(): Waits (in INTERNAL_WAIT millisecond intervals) for the value to appear at the given coordinates.
- Signature(s): boolean waitForPositionProperty(String propertyPrefix, String mainTimeoutProperty, String trailingTimeoutProperty)
waitForUnlock(): Waits for the keyboard to unlock.
- Signature(s): boolean waitForUnlock(int timeout), boolean waitForUnlock(String timeoutProperty)
Constants
In addition to standard data types, the APIs may take or return the following objects:
Key: The following fields can be used with the Key object and define keys that can be written to the interface.
static Key ATTN
static int ATTN_ID
static String ATTN_NAME
static Key ATTN_WAIT (Deprecated)
static Key BACK_TAB
static int BACK_TAB_ID
static String BACK_TAB_NAME
static Key BACKSPACE
static int BACKSPACE_ID
static String BACKSPACE_NAME
static Key CLEAR
static int CLEAR_ID
static String CLEAR_NAME
static Key CLEAR_WAIT (Deprecated)
static Key CURSOR_SELECT
static int CURSOR_SELECT_ID
static String CURSOR_SELECT_NAME
static Key CURSOR_SELECT_WAIT (Deprecated)
static Key DELETE
static int DELETE_ID
static String DELETE_NAME
static Key DOWN_ARROW
static int DOWN_ARROW_ID
static String DOWN_ARROW_NAME
static Key DUPLICATE
static int DUPLICATE_ID
static String DUPLICATE_NAME
static Key ENTER
static int ENTER_ID
static String ENTER_NAME
static Key ENTER_WAIT (Deprecated)
static Key ERASE_EOF
static int ERASE_EOF_ID
static String ERASE_EOF_NAME
static Key ERASE_INPUT
static int ERASE_INPUT_ID
static String ERASE_INPUT_NAME
static Key HOME
static int HOME_ID
static String HOME_NAME
static Key INSERT
static int INSERT_ID
static String INSERT_NAME
static Key KEYPAD_0
static int KEYPAD_0_ID
static String KEYPAD_0_NAME
static Key KEYPAD_1
static int KEYPAD_1_ID
static String KEYPAD_1_NAME
static Key KEYPAD_2
static int KEYPAD_2_ID
static String KEYPAD_2_NAME
static Key KEYPAD_3
static int KEYPAD_3_ID
static String KEYPAD_3_NAME
static Key KEYPAD_4
static int KEYPAD_4_ID
static String KEYPAD_4_NAME
static Key KEYPAD_5
static int KEYPAD_5_ID
static String KEYPAD_5_NAME
static Key KEYPAD_6
static int KEYPAD_6_ID
static String KEYPAD_6_NAME
static Key KEYPAD_7
static int KEYPAD_7_ID
static String KEYPAD_7_NAME
static Key KEYPAD_8
static int KEYPAD_8_ID
static String KEYPAD_8_NAME
static Key KEYPAD_9
static int KEYPAD_9_ID
static String KEYPAD_9_NAME
static Key KEYPAD_COMMA
static int KEYPAD_COMMA_ID
static String KEYPAD_COMMA_NAME
static Key KEYPAD_HYPHEN
static int KEYPAD_HYPHEN_ID
static String KEYPAD_HYPHEN_NAME
static Key KEYPAD_PERIOD
static int KEYPAD_PERIOD_ID
static String KEYPAD_PERIOD_NAME
static Key KEYPAD_RETURN
static int KEYPAD_RETURN_ID
static String KEYPAD_RETURN_NAME
static Key LEFT_ARROW
static int LEFT_ARROW_ID
static String LEFT_ARROW_NAME
static int MAX_ID
static Key NEWLINE
static int NEWLINE_ID
static String NEWLINE_NAME
static Key PA1
static int PA1_ID
static String PA1_NAME
static Key PA1_WAIT (Deprecated)
static Key PA2
static int PA2_ID
static String PA2_NAME
static Key PA2_WAIT (Deprecated)
static Key PA3
static int PA3_ID
static String PA3_NAME
static Key PA3_WAIT (Deprecated)
static Key PF1
static int PF1_ID
static String PF1_NAME
static Key PF1_WAIT (Deprecated)
static Key PF10
static int PF10_ID
static String PF10_NAME
static Key PF10_WAIT (Deprecated)
static Key PF11
static int PF11_ID
static String PF11_NAME
static Key PF11_WAIT (Deprecated)
static Key PF12
static int PF12_ID
static String PF12_NAME
static Key PF12_WAIT (Deprecated)
static Key PF13
static int PF13_ID
static String PF13_NAME
static Key PF13_WAIT (Deprecated)
static Key PF14
static int PF14_ID
static String PF14_NAME
static Key PF14_WAIT (Deprecated)
static Key PF15
static int PF15_ID
static String PF15_NAME
static Key PF15_WAIT (Deprecated)
static Key PF16
static int PF16_ID
static String PF16_NAME
static Key PF16_WAIT (Deprecated)
static Key PF17
static int PF17_ID
static String PF17_NAME
static Key PF17_WAIT (Deprecated)
static Key PF18
static int PF18_ID
static String PF18_NAME
static Key PF18_WAIT (Deprecated)
static Key PF19
static int PF19_ID
static String PF19_NAME
static Key PF19_WAIT (Deprecated)
static Key PF2
static int PF2_ID
static String PF2_NAME
static Key PF2_WAIT (Deprecated)
static Key PF20
static int PF20_ID
static String PF20_NAME
static Key PF20_WAIT (Deprecated)
static Key PF21
static int PF21_ID
static String PF21_NAME
static Key PF21_WAIT (Deprecated)
static Key PF22
static int PF22_ID
static String PF22_NAME
static Key PF22_WAIT (Deprecated)
static Key PF23
static int PF23_ID
static String PF23_NAME
static Key PF23_WAIT (Deprecated)
static Key PF24
static int PF24_ID
static String PF24_NAME
static Key PF24_WAIT (Deprecated)
static Key PF3
static int PF3_ID
static String PF3_NAME
static Key PF3_WAIT (Deprecated)
static Key PF4
static int PF4_ID
static String PF4_NAME
static Key PF4_WAIT (Deprecated)
static Key PF5
static int PF5_ID
static String PF5_NAME
static Key PF5_WAIT (Deprecated)
static Key PF6
static int PF6_ID
static String PF6_NAME
static Key PF6_WAIT (Deprecated)
static Key PF7
static int PF7_ID
static String PF7_NAME
static Key PF7_WAIT (Deprecated)
static Key PF8
static int PF8_ID
static String PF8_NAME
static Key PF8_WAIT (Deprecated)
static Key PF9
static int PF9_ID
static String PF9_NAME
static Key PF9_WAIT (Deprecated)
static Key RESET
static int RESET_ID
static String RESET_NAME
static Key RIGHT_ARROW
static int RIGHT_ARROW_ID
static String RIGHT_ARROW_NAME
static Key SYSREQ
static int SYSREQ_ID
static String SYSREQ_NAME
static Key SYSREQ_WAIT (Deprecated)
static Key TAB
static int TAB_ID
static String TAB_NAME
static Key UP_ARROW
static int UP_ARROW_ID
static String UP_ARROW_NAME
TN3270Connect
More Information
- TN3270Connect Examples
- TN3270Connect API
Overview
The TN3270Connect class enables telnet 3270 data streams to a remote host. When using TN3270Connect, be aware of the following:
- You know the exact output of the server you will connect to, and can therefore expect specific screens
- You know what keys you want to send, and when
- No anti-automation strategies have been implemented (e.g. captchas will defeat automation since the ActionTask will not know what to enter)
- TN3270Connect is enabled in the blueprint.properties file
Invoking the TN3270Connect Class
The TN3270Connect class can be invoked using one of these calls:
public TN3270Connect(String sessionName, String host, int port)
public TN3270Connect(String sessionName, String host, int port, String terminalType)
public TN3270Connect(String sessionName, String host, int port, String terminalType, String sslKeyFile, String sslKeyPassword)
The constructor opens the connection, if possible.
TN3270Connect Methods
The TN3270Connect class supports the following API methods.
Connectivity and Session Management
abort(): Aborts the current session.
- Signature(s): void abort()
close(): Closes the session.
- Signature(s): void close()
finalize(): Closes the session.
- Signature(s): void finalize()
getName(): Returns the session name.
- Signature(s): String getName()
isInsertOn(): Returns whether insert is on or not.
- Signature(s): boolean isInsertOn()
logoff(): Closes the active session.
- Signature(s): void logoff()
logon(): Is called by open().
- Signature(s): boolean logon()
open(): Opens a session.
- Signature(s): void open(String deviceName), void open(String sslKeyFile, String sslKeyPassword), void open(String deviceName, String sslKeyFile, StringsslKeyPassword)
Location and Display Management
createLocation(): Creates a Location object.
- Signature(s): Location createLocation(int row, int column), Location createLocation(String propertyPrefix)
createUi(): Creates a user interface.
- Signature(s): UserInterface createUi()
getHeight(): Returns the screen's height.
- Signature(s): int getHeight()
getPositionField(): Used internally.
- Signature(s) int getPositionField(int position, int[] offset, int[] length)
getWidth(): Returns the screen's width.
- Signature(s): int getWidth()
Reading Values
read(): Reads a string at the current cursor position or property.
- Signature(s): String read(int length), String read(String lengthProperty)
readAlarmCount(): Returns the number of times the alarm has sounded.
- Signature(s): long readAlarmCount()
readCursor(): Deprecated. Use readCursorLocation(). readCursorLocation(): Returns the cursor location.
- Signature(s): Location readCursorLocation()
readField(): Reads a string at the given field and offset. - Signature(s): String readField(int field, int offset, int length), String readField(String propertyPrefix)
readFieldLength(): Returns the length of a field.
- Signature(s): int readFieldLength(int field), int readFieldLength(String fieldProperty)
readFields(): Returns an array of all fields on the screen.
- Signature(s): Field[] readFields()
readPosition(): Returns a string at the given location or coordinates.
- Signature(s): String readPosition(int row, int column, int length), String readPosition(Location location, int length), String readPosition(String propertyPrefix)
readRow(): Returns the row at the current cursor location.
- Signature(s): String readRow(int row)
readScreen(): Returns the screen.
- Signature(s): String[] readScreen()
readScreenText(): Returns the screen as character text.
- Signature(s): char[] readScreenText()
Writing Values
writeAfterLabel(): Writes a string in the next unprotected field after a protected label.
- Signature(s): void writeAfterLabel(String propertyPrefix), void writeAfterLabel(String label, String value)
writeAfterLabelProperty(): Writes a string in the next unprotected field after a protected label.
- Signature(s): void writeAfterLabelProperty(String labelProperty, String value)
writeCursor(): Writes the cursor at the given coordinates or location.
- Signature(s): void writeCursor(int row, int column), void writeCursor(Location location), void writeCursor(String propertyPrefix)
writeField(): Writes a string at the given field and offset.
- Signature(s): void writeField(int field, int offset, String value), void writeField(String propertyPrefix), void writeField(String propertyPrefix, String value)
writeKey(): Writes the given key.
- Signature(s): Key writeKey(Key key), Key writeKey(String keyProperty)
writePosition(): Writes a string at the given coordinates or location.
Signature(s): void writePosition(int row, int column, String value), void writePosition(Location location, String value), void writePosition(String propertyPrefix)
writeProperty(): Writes the contents of valueProperty at the current cursor position.Signature(s): void writeProperty(String valueProperty)
writeString(): Writes a string at the current cursor position.
- Signature(s): void writeString(String value)
Waiting for Events
waitForChange(): Waits for the screen to change and the keyboard to unlock. timeout is in seconds.
- Signature(s): boolean waitForChange(int timeout), boolean waitForChange(String timeoutProperty)
waitForField(): Waits (in INTERNAL_WAIT millisecond intervals) for the value to appear at the given field and offset.
- Signature(s):
- boolean waitForField(int field, int offset, String value, int timeout)
- boolean waitForField(String propertyPrefix, int timeout)
- boolean waitForField(String propertyPrefix, String timeoutProperty)
- boolean waitForField(String propertyPrefix, String value, int timeout)
- boolean waitForField(String propertyPrefix, String value, String timeoutProperty)
waitForPosition(): Waits (in INTERNAL_WAIT millisecond intervals) for the value to appear at the given coordinates or location.
- Signature(s):
- boolean waitForPosition(int row, int column, String value, int timeout)
- boolean waitForPosition(Location location, String value, int timeout)
- boolean waitForPosition(String propertyPrefix, int timeout)
- boolean waitForPosition(String propertyPrefix, String timeoutProperty)
- boolean waitForPosition(String propertyPrefix, String value, int timeout)
- boolean waitForPosition(String propertyPrefix, String value, String timeoutProperty)
waitForUnlock(): Waits for the keyboard to unlock.
- Signature(s): boolean waitForUnlock(int timeout), boolean waitForUnlock(String timeoutProperty)
Constants
In addition to standard data types, the APIs may take or return the following objects:
Key: The following fields can be used with the Key object and define keys that can be written to the interface.
static Key ATTN
static int ATTN_ID
static String ATTN_NAME
static Key ATTN_WAIT (Deprecated)
static Key BACK_TAB
static int BACK_TAB_ID
static String BACK_TAB_NAME
static Key BACKSPACE
static int BACKSPACE_ID
static String BACKSPACE_NAME
static Key CLEAR
static int CLEAR_ID
static String CLEAR_NAME
static Key CLEAR_WAIT (Deprecated)
static Key CURSOR_SELECT
static int CURSOR_SELECT_ID
static String CURSOR_SELECT_NAME
static Key CURSOR_SELECT_WAIT (Deprecated)
static Key DELETE
static int DELETE_ID
static String DELETE_NAME
static Key DOWN_ARROW
static int DOWN_ARROW_ID
static String DOWN_ARROW_NAME
static Key DUPLICATE
static int DUPLICATE_ID
static String DUPLICATE_NAME
static Key ENTER
static int ENTER_ID
static String ENTER_NAME
static Key ENTER_WAIT (Deprecated)
static Key ERASE_EOF
static int ERASE_EOF_ID
static String ERASE_EOF_NAME
static Key ERASE_INPUT
static int ERASE_INPUT_ID
static String ERASE_INPUT_NAME
static Key HOME
static int HOME_ID
static String HOME_NAME
static Key INSERT
static int INSERT_ID
static String INSERT_NAME
static Key KEYPAD_0
static int KEYPAD_0_ID
static String KEYPAD_0_NAME
static Key KEYPAD_1
static int KEYPAD_1_ID
static String KEYPAD_1_NAME
static Key KEYPAD_2
static int KEYPAD_2_ID
static String KEYPAD_2_NAME
static Key KEYPAD_3
static int KEYPAD_3_ID
static String KEYPAD_3_NAME
static Key KEYPAD_4
static int KEYPAD_4_ID
static String KEYPAD_4_NAME
static Key KEYPAD_5
static int KEYPAD_5_ID
static String KEYPAD_5_NAME
static Key KEYPAD_6
static int KEYPAD_6_ID
static String KEYPAD_6_NAME
static Key KEYPAD_7
static int KEYPAD_7_ID
static String KEYPAD_7_NAME
static Key KEYPAD_8
static int KEYPAD_8_ID
static String KEYPAD_8_NAME
static Key KEYPAD_9
static int KEYPAD_9_ID
static String KEYPAD_9_NAME
static Key KEYPAD_COMMA
static int KEYPAD_COMMA_ID
static String KEYPAD_COMMA_NAME
static Key KEYPAD_HYPHEN
static int KEYPAD_HYPHEN_ID
static String KEYPAD_HYPHEN_NAME
static Key KEYPAD_PERIOD
static int KEYPAD_PERIOD_ID
static String KEYPAD_PERIOD_NAME
static Key KEYPAD_RETURN
static int KEYPAD_RETURN_ID
static String KEYPAD_RETURN_NAME
static Key LEFT_ARROW
static int LEFT_ARROW_ID
static String LEFT_ARROW_NAME
static int MAX_ID
static Key NEWLINE
static int NEWLINE_ID
static String NEWLINE_NAME
static Key PA1
static int PA1_ID
static String PA1_NAME
static Key PA1_WAIT (Deprecated)
static Key PA2
static int PA2_ID
static String PA2_NAME
static Key PA2_WAIT (Deprecated)
static Key PA3
static int PA3_ID
static String PA3_NAME
static Key PA3_WAIT (Deprecated)
static Key PF1
static int PF1_ID
static String PF1_NAME
static Key PF1_WAIT (Deprecated)
static Key PF10
static int PF10_ID
static String PF10_NAME
static Key PF10_WAIT (Deprecated)
static Key PF11
static int PF11_ID
static String PF11_NAME
static Key PF11_WAIT (Deprecated)
static Key PF12
static int PF12_ID
static String PF12_NAME
static Key PF12_WAIT (Deprecated)
static Key PF13
static int PF13_ID
static String PF13_NAME
static Key PF13_WAIT (Deprecated)
static Key PF14
static int PF14_ID
static String PF14_NAME
static Key PF14_WAIT (Deprecated)
static Key PF15
static int PF15_ID
static String PF15_NAME
static Key PF15_WAIT (Deprecated)
static Key PF16
static int PF16_ID
static String PF16_NAME
static Key PF16_WAIT (Deprecated)
static Key PF17
static int PF17_ID
static String PF17_NAME
static Key PF17_WAIT (Deprecated)
static Key PF18
static int PF18_ID
static String PF18_NAME
static Key PF18_WAIT (Deprecated)
static Key PF19
static int PF19_ID
static String PF19_NAME
static Key PF19_WAIT (Deprecated)
static Key PF2
static int PF2_ID
static String PF2_NAME
static Key PF2_WAIT (Deprecated)
static Key PF20
static int PF20_ID
static String PF20_NAME
static Key PF20_WAIT (Deprecated)
static Key PF21
static int PF21_ID
static String PF21_NAME
static Key PF21_WAIT (Deprecated)
static Key PF22
static int PF22_ID
static String PF22_NAME
static Key PF22_WAIT (Deprecated)
static Key PF23
static int PF23_ID
static String PF23_NAME
static Key PF23_WAIT (Deprecated)
static Key PF24
static int PF24_ID
static String PF24_NAME
static Key PF24_WAIT (Deprecated)
static Key PF3
static int PF3_ID
static String PF3_NAME
static Key PF3_WAIT (Deprecated)
static Key PF4
static int PF4_ID
static String PF4_NAME
static Key PF4_WAIT (Deprecated)
static Key PF5
static int PF5_ID
static String PF5_NAME
static Key PF5_WAIT (Deprecated)
static Key PF6
static int PF6_ID
static String PF6_NAME
static Key PF6_WAIT (Deprecated)
static Key PF7
static int PF7_ID
static String PF7_NAME
static Key PF7_WAIT (Deprecated)
static Key PF8
static int PF8_ID
static String PF8_NAME
static Key PF8_WAIT (Deprecated)
static Key PF9
static int PF9_ID
static String PF9_NAME
static Key PF9_WAIT (Deprecated)
static Key RESET
static int RESET_ID
static String RESET_NAME
static Key RIGHT_ARROW
static int RIGHT_ARROW_ID
static String RIGHT_ARROW_NAME
static Key SYSREQ
static int SYSREQ_ID
static String SYSREQ_NAME
static Key SYSREQ_WAIT (Deprecated)
static Key TAB
static int TAB_ID
static String TAB_NAME
static Key UP_ARROW
static int UP_ARROW_ID
static String UP_ARROW_NAME
Files
PDFAdaptor
More Information
- PDFAdaptor Example
- PDFAdaptor API
Overview
The PDFAdaptor class that helps with reading and writing PDF files from an Action Task.
FTPConnect
More Information
- FTPConnect Example
- FTPConnect API
Overview
The FTPConnect class is used to create connections to an FTP server.
Apache POI
Overview
Apache POI can be used to create, maintain, and edit through Java APIs various files whose formats are based upon the Office OpenXML and Microsoft OLE2 Compound Document format. By including the Apache POI libraries into the build path of an RSRemote, you can give REMOTE-type ActionTasks the ability to use Apache POI's functionality, and most importantly, the ability to use Apache POI's high level APIs for Microsoft Excel, Word, and Powerpoint.
Installation Instructions
Because Apache POI requires reading from the local file system, it is recommended to select one RSRemote to use Apache POI and use targets or queue names to Direct All POI related tasks to that RSRemote.
To enable the Apache POI, perform the following steps:
- Shutdown RSRemote
- Edit the blueprint.properties file and set:
rsremote.run.mspoi=FALSE
Run bin/config.sh
Restart RSRemote
Example Apache POI Task (Microsoft Excel)
Importing necessary classes into INPUTFILE
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.extractor.ExcelExtractor;Instantiate necessary variables
def result = "";
def location = INPUTS["FILE_LOCATION"]; // Set aside location for storing Excel sheets to Work on
def file = INPUTS["FILENAME"]; // Name of specific Excel sheet to read
file = file.replaceAll(" ","\\ "); // Fix for Unix File System and spaces in File Name
def path = location + "/" + file; // Absolute File PathRead in Excel file
try {
// Read from Input Stream into Extractor
InputStream inp = new FileInputStream(path);
HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(inp));
ExcelExtractor extractor = new ExcelExtractor(wb);
// set Extractor options
extractor.setFormulasNotResults(false);
extractor.setIncludeSheetNames(false);
extractor.setIncludeBlankCells(true);
extractor.setIncludeHeadersFooters(false);
// Convert Excel sheet to String[]
def lines = extractor.getText().split("\n");
}Work with Excel file
for (i = 1; i < lines.size(); i++) {
line = lines[i];
def values = StringUtils.stringToList(line, "\t");
// Some logic
}Finally it is recommended to catch any Exceptions thrown for easier debugging.
catch (Exception e) {
result += "FAIL: Unexpected Exception: " + e.getMessage();
for (trace in e.getStackTrace()) {
result += "\n\t" + trace;
}
}
return result;
Apache POI Tips and Tricks
- Returning the whole content of a larger file sizes (i.e. several MB) to the Assessor can cause massive slowdown, failure to return results, and even cause problems with High Availability RSMQ setups. Because of this it is recommended to contain all logic and assessment needed on the File to the INPUTFILE rather than passing its data through OUTPUTS/FLOWS or assessing the full file in the Assessor as is usual. If this cannot be done it is recommended to read the contents of the Excel sheet to Actions Pro Database Table inside the INPUTFILE then use the table in Assessor and later ActionTasks.
- Because Apache POI requires reading from the local file system, it is recommended to select one RSRemote to use Apache POI and use Targets or Queue Names to Direct All POI related tasks to that RSRemote.