|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.function.UserFunctions
public class UserFunctions
This class contains a number of convenience methods widely used by the scripting environment. An instance of this class is available in scripts, with the scripting name of system.
Field Summary | |
---|---|
static char[] |
INVALID_XML_CHARS
|
Exception |
lastError
The Exception object set by the last call in this library. |
RSInterface |
server
RSInterface object. |
Constructor Summary | |
---|---|
UserFunctions()
Default constructor. |
|
UserFunctions(RSInterface server)
Constructor with one parameter. |
Method Summary | |
---|---|
void |
abortAssemblyLine(String reason)
Throws an AbortALException to instruct the AssemblyLine to terminate. |
String |
arrayToString(byte[] array)
Converts a ByteArray to a string using platform's default charset. |
static byte[] |
base64Decode(String str)
base64Decode: Obtain Byte Array from a Base 64 encoded String. |
static String |
base64Encode(byte[] b)
base64Encode: Obtain Base 64 encoded String from a binary Byte Array |
String |
binaryGUIDtoString(byte[] binaryData)
Generates the hexadecimal String representation of an Active Directory GUID based on its 128-bit binary representation. |
boolean |
chdir(String directory)
Change Java runtime working directory. |
static boolean |
containsIC(String first,
String second)
Returns true if the second String is a substring of the first, ignoring case. |
void |
continueLoop()
Throws a ContinueloopException to tell the AssemblyLine to continue with the next value in the loop. |
void |
continueLoop(String name)
Throws a ContinueLoopException to tell the AssemblyLine to continue with the next value in the named loop. |
boolean |
copyBinaryFile(String fromPath,
String toPath,
boolean overwrite)
Deprecated. Use copyFile(String, String) instead |
void |
copyDirectory(String source,
String target,
boolean recursive,
boolean overwrite,
Log log)
Copy a directory. |
static boolean |
copyFile(File fromFile,
File toFile,
boolean overwrite)
Copy file. |
boolean |
copyFile(String oldFile,
String newFile)
Copy a file. |
static boolean |
copyFile(String fromPath,
String toPath,
boolean overwrite)
Copy file. |
AssemblyLinePool |
createALPool(String assemblyLine,
Log log)
Creates an AssemblyLine Pool object from the specified AssemblyLine name. |
static IDispatch |
createCOMInstance(String progID)
Creates an IDispatch automation object. |
boolean |
deleteFile(String filePath)
Deletes a file. |
Object |
deletePersistentObject(String key)
This method deletes a named object in the default system property store. |
static void |
deletePipe(String pipeName)
Deletes specified pipe from default instance Drops the associated table in System Store with the specified memory queue (if it’s a persistent queue). |
static void |
deletePipe(String instName,
String pipeName)
Deletes the specified pipe from the specified instance. |
String |
dtSeconds()
Returns the number of milliseconds since Jan 1 1970 as a string. |
void |
dumpEntry(Entry e)
Dumps an entry to the console log. |
boolean |
dumpJavaClass(String className)
Dumps the public methods for a Java class. |
static String |
encodeToHexstring(byte[] data)
encodeToHexstring: Obtain HexString from a byte array. |
static boolean |
endsWithIC(String first,
String second)
Returns true if the first String ends with the second String, ignoring case If at least one if the Strings are null, returns false.This method is case insensitive. |
String |
entry2LDIF(Entry e)
Converts an Entry object to an LDIF string. |
void |
exitBranch()
Throws an ExitBranchException that tells the AssemblyLine to exit the current branch/loop. |
void |
exitBranch(String name)
Throws an ExitBranchException that tells the AssemblyLine to exit the named branch/loop. |
void |
exitFlow()
Throws an ExitBranchException that tells the AssemblyLine to not execute any more of the Flow Section components. |
void |
exitFlow(boolean skipResponse)
Throws an ExitBranchException that tells the AssemblyLine to not execute any more of the Flow Section components. |
String |
formatDate(Date date,
String format)
This method formats a java.util.Date object using the provided template. |
ConnectorInterface |
getConnector(String name)
Load a connector. |
String |
getcwd()
Returns the current working directory. |
Object |
getExternalProperty(String propName)
Deprecated. use getTDIProperty(String) instead |
Object |
getExternalProperty(String extObj,
String propName)
Deprecated. use getTDIProperty(String, String) instead
Implementation of the method is changed due to defect 12968 |
ExternalPropertiesConfig |
getExtProp(String name)
Deprecated. use getTDIProperties() instead |
FTPBean |
getFTP()
Returns an instance of the FTP object. |
FunctionInterface |
getFunction(String name)
Load a Function component Interface from the current Config. |
String |
getJavaProperty(String prop)
Returns the value for a system property. |
String |
getOSName()
Returns the name of the operating system. |
ParserInterface |
getParser(String name)
Load a parser Interface from the current Config. |
Object |
getPersistentObject(String key)
This method retrieves a named object from the default system property store. |
static MemBufferQ |
getPipe(String instName,
String pipeName)
This method returns a handle to a pipe with the specified instName and pipeName (if it already exists). |
String |
getRacfCredential(byte[] pwbytes,
String recipientKeystore,
String recipientKeystorePW,
String recipientCertAlias,
String recipientCertPW,
String signerKeystore,
String signerKeystorePW,
String signerCertAlias)
This method returns the String representation of the decrypted password from the RACF PasswordEnvelope |
RacfCredential |
getRacfCredentialObject(byte[] pwbytes,
String recipientKeystore,
String recipientKeystorePW,
String recipientCertAlias,
String recipientCertPW,
String signerKeystore,
String signerKeystorePW,
String signerCertAlias)
This method returns a RacfPassword object containing the decrypted RACF password envelope |
String |
getRacfCredentialObjectDump(byte[] pwbytes,
String recipientKeystore,
String recipientKeystorePW,
String recipientCertAlias,
String recipientCertPW,
String signerKeystore,
String signerKeystorePW,
String signerCertAlias)
This method returns the String representation of the decrypted racfpasswordenvelope The syntax for the String is: Password: <password>, Version: <version>, Change Time: <timestamp>, Language: <language>, Expired: <true/false> |
String |
getRacfPassword(byte[] pwbytes,
String recipientKeystore,
String recipientKeystorePW,
String recipientCertAlias,
String recipientCertPW,
String signerKeystore,
String signerKeystorePW,
String signerCertAlias)
Deprecated. |
RacfPassword |
getRacfPasswordObject(byte[] pwbytes,
String recipientKeystore,
String recipientKeystorePW,
String recipientCertAlias,
String recipientCertPW,
String signerKeystore,
String signerKeystorePW,
String signerCertAlias)
Deprecated. |
String |
getRacfPasswordObjectDump(byte[] pwbytes,
String recipientKeystore,
String recipientKeystorePW,
String recipientCertAlias,
String recipientCertPW,
String signerKeystore,
String signerKeystorePW,
String signerCertAlias)
Deprecated. |
String |
getRsaDecrypted(String cipherText,
String ksPath,
String ksPassword,
String certificateAlias,
String certificatePassword)
getRsaDecrypted: Obtain plain ascii text for encrypted ciphertext specified. |
String |
getRsaEncrypted(String plainText,
String ksPath,
String ksPassword,
String certificateAlias)
getRsaEncrypted: Obtain encrypted (and ascii-encoded) value for plain text specified, null strings are not processed and will be returned as null. |
static Vector<AssemblyLine> |
getRunningALs()
This method returns a Vector containing all AssemblyLines that were running when the function was called. |
static Vector<AssemblyLine> |
getRunningALs(String name)
This method returns a Vector containing all AssemblyLines with the given name that were running when the function was called |
String |
getScriptText(String name)
Returns the text from the Script Library. |
RSInterface |
getServer()
Returns the RS instance associated with the current ThreadGroup, or the dummy RSInterface object defined by the Config Editor. |
static ParameterSubstitution |
getTDIExpression(String pattern)
Returns a ParameterSubstitution object using the given pattern. |
TDIProperties |
getTDIProperties()
Returns the TDIProperties object for the current configuration |
Object |
getTDIProperty(String name)
Returns the value for a TDI property |
Object |
getTDIProperty(String propstore,
String name)
Returns the property value from a specific TDI property store |
String |
getX400Attribute(String x400,
String sep,
String attribute)
Returns an attribute value from an X.400 address. |
org.apache.xpath.XPathAPI |
getXPathAPI()
Returns the Apache XPathAPI |
Entry |
httpGet(String url)
Gets file from a web server. |
Entry |
httpPost(String url,
Object file)
Posts file to a web server. |
Entry |
httpRequest(String method,
String contentType,
String url,
Object file)
Sends HTTP Request message to web server. |
void |
ignoreEntry()
Throws an IgnoreEntryException to tell the AssemblyLine to skip the current component and continue with the next component in flow. |
void |
ignoreEntry(String msg)
Throws an IgnoreEntryException to tell the AssemblyLine to skip the current component and continue with the next component in flow. |
boolean |
isValidInt(String str)
Returns true if a string holds a valid Integer. |
ConnectorInterface |
loadConnector(String connectorName)
Load a Connector Interface from the current Config. |
static void |
loadJarFile(String path)
Dynamically add jar file containing class definitions. |
String |
makeTitleCase(String in)
Convert A String Into Title Case (Like This), using the current Locale. |
String |
mapString(String source,
String fromSet,
String toSet)
Translates characters in a string. |
Attribute |
newAttribute(String name)
Creates a new Attribute object. |
Entry |
newEntry()
Creates a new Entry object. |
Object |
newObject(String className)
Creates a new object. |
static MemBufferQ |
newPipe(String instName,
String pipeName,
int watermark)
This method create a new Memory Buffer Queue if it does not already exist. |
static MemBufferQ |
newPipe(String instName,
String pipeName,
int watermark,
int pagesize)
This method create a new Memory Buffer Queue if it does not already exist. |
SearchCriteria |
newSearchCriteria()
Creates a new rscSearchCriteira object. |
TaskCallBlock |
newTCB()
Create an empty TaskCallBlock. |
TaskCallBlock |
newTCB(String assemblyLine)
Create a TaskCallBlock with i/o specifications from an existing assemblyline. |
String |
normalizeX400(String value,
String cursep,
String newsep)
Converts an X.400 address to a string using short form attribute names. |
BufferedWriter |
openFileForAppend(String path)
Opens a file in append mode and returns the associated BufferedWriter object. |
BufferedReader |
openFileForInput(String path)
Opens a file for input and returns the associated BufferedReader object. |
BufferedWriter |
openFileForOutput(String path)
Opens a file in output mode and returns the associated BufferedWriter object. |
Date |
parseDate(String value,
String format)
Converts a String to a java.util.Date object. |
Entry |
parseObject(String parser,
Object data)
Use a parser to interpret data. |
String |
remove(String s,
String source)
Remove characters from a string. |
static String |
removeInvalidXMLChars(String aString)
Removes invalid XML chars. |
String |
removeStringChars(String source,
String fromSet)
Removes occurrences of characters from a string. |
boolean |
renameFile(String oldName,
String newName)
Rename a file. |
void |
restartEntry()
Throws a RestartEntryException to tell the AssemblyLine to restart. |
void |
restartEntry(String msg)
Throws a RestartEntryException to tell the AssemblyLine to restart, using the current work object. |
void |
retryEntry()
Throws a RetryEntryException to tell the AssemblyLine to retry this component. |
org.w3c.dom.traversal.NodeIterator |
selectNodeIterator(Node contextNode,
String str)
Selects nodes using an XPath expression from an XML node. |
NodeList |
selectNodeList(Node contextNode,
String str)
Selects nodes using an XPath expression from an XML node. |
Node |
selectSingleNode(Node contextNode,
String str)
Selects a single node using an XPath expression from an XML node. |
String |
sendMail(String from,
String recipient,
String subject,
String body,
String attachment)
Sends an email message. |
String |
sendMail(String from,
String recipient,
String subject,
String body,
String attachments,
String replyTo)
Sends an email message with ReplyTo field. |
void |
setExternalProperty(String propName,
Object value)
Deprecated. use setTDIProperty(String, Object) instead |
void |
setExternalProperty(String extObj,
String propName,
Object value)
Deprecated. use setTDIProperty(String, String, Object) instead |
void |
setJavaProperty(String prop,
String value)
Sets the value of a property name. |
Object |
setPersistentObject(String key,
Object value)
This method stores a named object in the default system property store. |
void |
setTDIProperty(String name,
Object value)
Sets the property value for a property (store selection based on naming rules and order). |
void |
setTDIProperty(String propstore,
String name,
Object value)
Sets the property value in a specific TDI property store |
ExecuteCommand |
shellCommand(String command)
Executes a shell command. |
ExecuteCommand |
shellCommand(String command,
Object args)
Executes a shell command with arguments. |
void |
skipEntry()
Throws a SkipEntryException which causes the AssemblyLine to stop the current cycle and pass control to the currently active Iterator in order to get the next entry. |
void |
skipEntry(String msg)
* Throws a SkipEntryException which causes the AssemblyLine to stop the current cycle and pass control to the currently active Iterator in order to get the next entry. |
void |
skipTo(String name)
Throws a SkipToException to tell the AssemblyLine to skip to the named Connector/ScriptComponent. |
InterruptedException |
sleep(int seconds)
Causes the current thread (e.g. |
boolean |
snmpTrap(String host,
int port,
String oid,
String value)
Sends an SNMP trap. |
boolean |
snmpTrap(String agentIP,
String host,
int port,
String community,
String enterprise,
int genericTrap,
int specificTrap,
String oid,
Object value)
Sends an SNMP trap. |
String[] |
splitString(String source,
String separators)
Splits a string into an array of strings. |
static boolean |
startsWithIC(String first,
String second)
Returns true if the first String starts with the second String, ignoring case. |
static String |
substitute(String pattern,
Map<String,Object> params)
Performs a one-time parsing and substitution of pattern with the objects available in params. |
static String |
substitute(String pattern,
String[] names,
Object[] objects)
Performs a one-time parsing and substitution of pattern with named objects. |
void |
throwException(String message)
Throws a generic java.lang.Exception. |
String |
toHex(String str)
Converts a string to a hexadecimal string where each character is converted to a two-byte hex value. |
Integer |
toInt(String str)
Convert a string to a java.lang.Integer object. |
String |
translateString(String str,
String fromCharset,
String toCharset)
Translate a string from one character set to another. |
String |
trim(String str)
Trims leading/trailing white-space from a string. |
void |
writeln(Writer w,
String str)
Writes a string plus a CRLF using a Writer object. |
String |
xslTransform(Object xsl,
Object xml)
Calls the XSLTransformer to transform an XML document using a given style sheet."\n" needs to be present in the XSL and XML string for xslTransfrom to work correctly. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Exception lastError
public RSInterface server
RSInterface
object.
public static final char[] INVALID_XML_CHARS
Constructor Detail |
---|
public UserFunctions()
public UserFunctions(RSInterface server)
server
- server instanceMethod Detail |
---|
public RSInterface getServer()
main
object in
JavaScript.
RS
instance or null
if it couldn't be
found, e.g. because the current Thread was not created by the TDI
framework.public String remove(String s, String source) throws Exception
remove (" ", "J O P")
. The returned value would then be "JOP".
var a = "A string with blanks and vowels"; var b = system.remove("AEIOUaeiou ", a); task.logmsg("Result: " + b); // "strngwthblnksndvwls"
s
- The characters to be removedsource
- The string from which characters are removed
s
Exception
public String trim(String str)
Example:
var a = " A string with leading/trailing white-spaces "; var b = system.trim(a); task.logmsg("Result: " + b); // "A string with leading/trailing white-spaces"
str
- The string to trim
public Integer toInt(String str) throws Exception
str
- The string with a number
Exception
public boolean isValidInt(String str)
str
- The string to test
public BufferedWriter openFileForAppend(String path) throws Exception
Example:
var out = system.openFileForAppend("out.txt"); out.write("Hello world!"); out.newLine(); out.close();
path
- The file path to open. If the file does not exist it is
created.
Exception
public BufferedWriter openFileForOutput(String path) throws Exception
Example:
var out = system.openFileForOutput("out.txt"); out.write("Hello world!"); out.newLine(); out.close();
path
- The file path to open (overwrites existing file)
Exception
public BufferedReader openFileForInput(String path) throws Exception
Example:
var inp = system.openFileForInput("inp.txt"); var str = inp.readLine(); if (str == null) task.logmsg("End of file"); inp.close();
path
- The file path to open
Exception
- FileNotFoundExceptionpublic void writeln(Writer w, String str) throws Exception
Example:
var a = "Some line with text."; var b = "Another line with text."; var fileWriter = new java.io.FileWriter("c:\\docs\\myfile.txt"); system.writeln(fileWriter, a); system.writeln(fileWriter, b);The result in the file would look like this:
Some line with text.
Another line with text.
w
- The writer objectstr
- The string to write
Exception
public String sendMail(String from, String recipient, String subject, String body, String attachment) throws Exception
Example:
var res = system.sendMail("Sender","address1@mail.or, address2@mail.or","Subject","Message text", "C:\\docs\\myfile.txt"); if(res != null) task.logmsg("Error occurred: "+res);
from
- The From fieldrecipient
- A comma separated list of recipient addressessubject
- The Subject fieldbody
- The message textattachment
- If specified a file-path that will be attached to the message
Exception
public String sendMail(String from, String recipient, String subject, String body, String attachments, String replyTo) throws Exception
Example:
var res = system.sendMail("Sender","address1@mail.or, address2@mail.or","Subject","Message text", "c\\docs\\myfile.txt","my_address@mail.or"); if(res != null) task.logmsg("Error occurred: "+res);
from
- The From fieldrecipient
- A comma separated list of recipient addressessubject
- The Subject fieldbody
- The message textattachments
- If specified a comma separated list of file-paths that will be
attached to the messagereplyTo
- A comma separated list of ReplyTo addresses
Exception
public static boolean copyFile(String fromPath, String toPath, boolean overwrite) throws Exception
Example:
var fromPath = "c:\\docs\\myfile.txt"; var toPath = "c:\\backup\\myfile.txt"; if (!system.copyFile(fromPath, toPath, false)) task.logmsg("Error " + toPath + " file exist!");
fromPath
- The source filetoPath
- The destination fileoverwrite
- Specify true if destination should be overwritten.
Exception
public static boolean copyFile(File fromFile, File toFile, boolean overwrite) throws Exception
fromFile
- The source filetoFile
- The destination fileoverwrite
- Specify true if destination should be overwritten.
Exception
@Deprecated public boolean copyBinaryFile(String fromPath, String toPath, boolean overwrite) throws Exception
copyFile(String, String)
instead
fromPath
- The name of the file to copytoPath
- The name of the new fileoverwrite
- Specify true if destination should be overwritten.
true
if copyBinaryFile successed, otherwise
false
.
Exception
public void copyDirectory(String source, String target, boolean recursive, boolean overwrite, Log log) throws Exception
target
.
Example:
var dir1 = "c:\\docs"; var dir2 = "c:\\backup"; system.copyDirectory(dir1, dir2, true, true, null);
source
- Source directorytarget
- Target directoryrecursive
- Specify true if recursion should be usedoverwrite
- Specify true if existing files should be overwritten.log
- If not null, log activity to this Log
Exception
public Attribute newAttribute(String name)
Example:
ocAttr = system.newAttribute("objectClass"); ocAttr.addValue("top"); ocAttr.addValue("person"); ocAttr.addValue("organizationalPerson"); ocAttr.addValue("inetOrgPerson"); work.setAttribute(ocAttr);
name
- The attribute name
public SearchCriteria newSearchCriteria()
SearchCriteria
public Entry newEntry()
Example:
var entry = system.newEntry(); entry.setAttribute("linenumber", "1"); entry.setAttribute("line", "Simple line of text!"); write.getConnector().putEntry(entry);
newAttribute(String)
public Object newObject(String className)
className
- The java class name
public void skipEntry() throws SkipEntryException
This call bypasses End-of-cycle behaviors, like accumulating (see
TaskCallBlock), committing JDBC operations or persisting Iterator State
for Change Detection Connectors. If you instead wish to stop the current
cycle and still invoke End-of-cycle behaviors, use the
exitFlow()
call instead.
SkipEntryException
- to tell the AssemblyLine to skip the current Entry.skipTo(String)
public void skipEntry(String msg) throws SkipEntryException
This call bypasses End-of-cycle behaviors, like accumulating (see
TaskCallBlock), committing JDBC operations or persisting Iterator State
for Change Detection Connectors. If you instead wish to stop the current
cycle and still invoke End-of-cycle behaviors, use the
exitFlow()
call instead.
msg
- A message supplied by the user
SkipEntryException
- to tell the AssemblyLine to skip the current Entry.skipEntry()
public void ignoreEntry() throws IgnoreEntryException
IgnoreEntryException
public void ignoreEntry(String msg) throws IgnoreEntryException
msg
- A message supplied by the user
IgnoreEntryException
public void restartEntry() throws RestartEntryException
RestartEntryException
public void restartEntry(String msg) throws RestartEntryException
msg
- A message supplied by the user
RestartEntryException
restartEntry()
public void retryEntry() throws RetryEntryException
RetryEntryException
public void skipTo(String name) throws SkipToException
name
- The name of the Connector to skip to.
SkipToException
public void abortAssemblyLine(String reason) throws AbortALException
If you want your AssemblyLine to terminate gracefully (i.e. not abort), use one of the following functions system.exitBranch("AssemblyLine") or task.shutdown() instead.
reason
- Descriptive text why the AssemblyLine is terminated
AbortALException
exitBranch()
public void throwException(String message) throws Exception
Whereas the JavaScript throw command allows you to throw a JavaScript
exception, this method creates and throws a Exception
object.
message
- The message text of the Exception
Exception
public void exitBranch() throws ExitBranchException
ExitBranchException
public void exitBranch(String name) throws ExitBranchException
name
- The name of the branch/loop to exit
ExitBranchException
- to tell the AssemblyLine to exit the named branch/looppublic void exitFlow() throws ExitBranchException
This behavior is identical to that caused by the following call:
system.exitBranch("Flow");
ExitBranchException
- to tell the AssemblyLine to exit the Flow Sectionpublic void exitFlow(boolean skipResponse) throws ExitBranchException
If the skipResponse parameter pass is false, then in the case of a Server mode Connector, the Response is carried out. If skipResponse is true, no Response is sent.
skipResponse
- Whether or not a Response should be sent if a Server mode
Connector is feeding this AL.
ExitBranchException
- to tell the AssemblyLine to exit the Flow Sectionpublic void continueLoop() throws ContinueLoopException
ContinueLoopException
public void continueLoop(String name) throws ContinueLoopException
name
- The name of the loop
ContinueLoopException
public ConnectorInterface loadConnector(String connectorName)
Example:
var con = system.loadConnector("ADChangelogConnectorv2"); con.initialize(null);
connectorName
- The connector name as it appears in the configuration file
public String dtSeconds()
public InterruptedException sleep(int seconds)
seconds
- Number of seconds to sleep
public String removeStringChars(String source, String fromSet)
Example:
var str = "Some short string"; var str1 = system.removeStringChars(str, 's'); task.logmsg("Result: " + str1); //Some hort tring
source
- The source stringfromSet
- A string specifying characters to be removed from source
public String makeTitleCase(String in)
Example:
var str = "some short string"; var str1 = system.makeTitleCase(str); task.logmsg("Result: " + str1); //Some Short String
in
- The string to convert
public String mapString(String source, String fromSet, String toSet)
Example:
var str = system.mapString("Some example text", "Somexamplt", "Noneracklg"); task.logmsg("Result: " + str); //None erankle gerg
source
- The source stringfromSet
- The characters to be replacedtoSet
- The characters to replace characters in fromSet
public String translateString(String str, String fromCharset, String toCharset)
Example:
var str = system.translateString("Some example text", "UTF-8", "UTF-16"); task.logmsg("Result: " + str);
str
- The source stringfromCharset
- The source character settoCharset
- The target character set
public String toHex(String str)
Example:
var str = system.toHex("text"); task.logmsg("Result: " + str); //74 65 78 74
str
- The source string
public String getX400Attribute(String x400, String sep, String attribute)
Example:
var str = "C=no;ADMD= ;PRMD=uninett;O=sintef;OU=delab;S=Smith;G=John"; task.logmsg("Result: " + system.getX400Attribute(str, ';', "PRMD"));
x400
- The X.400 addresssep
- The separator used in the address ( typically "/" or ";" )attribute
- The X.400 attribute
public String normalizeX400(String value, String cursep, String newsep)
Example:
var str = "C=no;ADMD= ;PRMD=uninett;O=sintef;OU=delab;S=Smith;G=John"; task.logmsg("Result: " + system.normalizeX400(str, ';', '/'));
value
- The X.400 addresscursep
- The separator used in valuenewsep
- The separator to be used in the result
public Date parseDate(String value, String format)
Example:
var dateobj = system.parseDate("23/01/07", "DD/MM/yy"); task.logmsg("Result: " + dateobj); //Tue Jan 23 00:00:00 EET 2007
value
- A string representing dateformat
- The format of value (e.g. "yyyy.MM.DD", "MM/DD/yy" etc
...) A complete list of format characters can be found at
http://icu.sourceforge.net/apiref/icu4j/com/ibm/icu/text/
SimpleDateFormat.html
lastError
public String formatDate(Date date, String format)
Example:
var d = com.ibm.icu.util.Calendar.getInstance().getTime(); task.logmsg("Result: " + system.formatDate(d, "dd/MM/yy")); task.logmsg("Result: " + system.formatDate(d, "yyyy.MM.dd"));
date
- The date objectformat
- The format of value (e.g. "yyyy.MM.dd", "MM/dd/yy" etc
...) A complete list of format characters can be found at
http://icu.sourceforge.net/apiref/icu4j/com/ibm/icu/text/
SimpleDateFormat.html.
lastError
public String[] splitString(String source, String separators)
Example:
var str = "Some short string"; task.logmsg("Result: " + system.splitString(str, ' ')); //Some,short,string
source
- The source stringseparators
- The word-separating characters
public ConnectorInterface getConnector(String name)
name
- The connector name as it appears in the configuration file
loadConnector(String)
public ParserInterface getParser(String name)
name
- The parser name as it appears in the configuration file
public Entry parseObject(String parser, Object data)
Example:
var data = new java.io.FileInputStream("c:\\docs\\LDIFfile.txt"); var entry = system.newEntry(); entry = system.parseObject("LDIFParser", data); task.dumpEntry(entry);
parser
- The parser namedata
- Any object of type Reader, InputStream or object that has a
toString method
lastError
public ExecuteCommand shellCommand(String command)
command
- A String containing the shell command to execute. This String
will be parsed with a simple StringTokenizer, to split the
command and arguments.
ExecuteCommand
public ExecuteCommand shellCommand(String command, Object args)
Example:
myArr = ["-c", "/bin/ls", "/mnt/cd rom"]; cmd = system.shellCommand ("su", myArr); main.logmsg("The result was:\n" + cmd.getOutputBuffer() );
command
- The shell command to executeargs
- The arguments to the command. E.g. a String array containing
the arguments. In JavaScript you could have code like this:
ExecuteCommand
public String getOSName()
public String getJavaProperty(String prop)
prop
- The property name
public void setJavaProperty(String prop, String value)
prop
- The property namevalue
- The property valuepublic String entry2LDIF(Entry e)
Example:
var entry = system.newEntry(); entry.addAttributeValue("$dn", "cn=Login Server"); entry.addAttributeValue("cn", "Login Server"); entry.addAttributeValue("description", "Central Authentication Authority"); entry.addAttributeValue("objectClass", "top"); entry.addAttributeValue("objectClass", "applicationProcess"); task.logmsg("Result: " + system.entry2LDIF(entry));
e
- The entry
lastError
public FTPBean getFTP()
Example:
var ftpbean = system.getFTP(); ftpbean.connect("ftp://ftp.myhost.com", "user", "pass"); ftpbean.get("ftp://ftp.myhost.com/myfile.txt", "c:\\docs\\myfile.txt");
FTPBean
public void dumpEntry(Entry e)
Entry
.
e
- The entry objectEntry
public org.apache.xpath.XPathAPI getXPathAPI()
public Node selectSingleNode(Node contextNode, String str)
<?xml version="1.0" ?>
<note>
<from>Tony</from>
<to>Michael</to>
<to>John</to>
<heading>Question</heading>
<body>Are you ready?</body>
</note>
Since com.ibm.di.entry.Entry implements the org.w3c.dom.Document to get
the first from
node we could use XMLParser to read an Entry
which could be passed to this method as a contextNode
parameter.
Example:
var entry = input.getConnector().getNextEntry(); var res = system.selectSingleNode(entry, "note/to"); task.logmsg(res); // to:Michael
contextNode
- The XML document nodestr
- The XPath search string
lastError
public NodeList selectNodeList(Node contextNode, String str)
<?xml version="1.0" ?>
<note>
<from>Tony</from>
<to>Michael</to>
<to>John</to>
<heading>Question</heading>
<body>Are you ready?</body>
</note>
Example:
var entry = input.getConnector().getNextEntry(); var res = system.selectNodeList(entry, "note/to"); for (var i = 0; i < res.getLength(); i++) { task.logmsg(res.item(i)); //to:Michael, to:John }
contextNode
- The XML document nodestr
- The XPath search string
lastError
,
selectSingleNode(Node, String)
public org.w3c.dom.traversal.NodeIterator selectNodeIterator(Node contextNode, String str)
<?xml version="1.0" ?>
<note>
<from>Tony</from>
<to>Michael</to>
<to>John</to>
<heading>Question</heading>
<body>Are you ready?</body>
</note>
Example:
var entry = input.getConnector().getNextEntry(); var iter = system.selectNodeIterator(entry, "note"); var node; while (node = iter.nextNode()) { task.logmsg(node); }
contextNode
- The XML document nodestr
- The XPath search string
lastError
,
selectSingleNode(Node, String)
public String xslTransform(Object xsl, Object xml)
xsl
- The XSL Style sheet (String, java.io.File, java.io.Reader )xml
- The XML document (String, java.io.File, java.io.Reader )
lastError
public boolean dumpJavaClass(String className)
className
- The java class name
lastError
public boolean chdir(String directory)
directory
- File system directory
public String getcwd()
public String getScriptText(String name)
name
- The script name as it appears in the configuration.
public boolean snmpTrap(String host, int port, String oid, String value)
host
- The IP hostport
- The TCP portoid
- The OIDvalue
- The value
lastError
public boolean snmpTrap(String agentIP, String host, int port, String community, String enterprise, int genericTrap, int specificTrap, String oid, Object value)
oid
is null, value
must be an Entry. All Attribute names will be taken as oids, and the
values of that Attribute will be the corresponding values.
Example:
var entry = system.newEntry(); entry.setAttribute("1.2.3.4.1", "MyString"); entry.setAttribute("1.2.3.4.2", com.ibm.di.protocols.SNMP.createIPAddress("10.0.0.1")); entry.setAttribute("1.2.3.4.3", com.ibm.di.protocols.SNMP.createGauge(200)); if (!system.snmpTrap("192.1.1.1", targetIP, 162, "public", enterpriseOID, 0, 0, null, entry)) { task.logmsg("Error sending trap: " + system.lastError); }If oid is non-null, value should be a java.util.Vector, a javascript array or any other object. The conversion of the values to SNMP PDU values are as follows: If you provide an object whose class starts with "com.tivoli.snmp.data" the value is used asis (see com.ibm.di.protocols.SNMP on how to create these objects). If you provide an Integer then a com.tivoli.snmp.data.Counter object is created. In all other cases an OctetString object is created from the object value's toString() method.
Example:
var varBind = [ "MyString", com.ibm.di.protocols.SNMP.createIPAddress("10.0.0.1"), com.ibm.di.protocols.SNMP.createGauge(200) ]; if ( !system.snmpTrap( "192.1.1.1", targetIP, 162, "public", enterpriseOID, 0, 0, "1.2.3.4", varBind) ) { task.logmsg("Error sending trap: " + system.lastError); }
agentIP
- The agent IP address or null to use the local host ip address
(e.g. InetAddress.getLocalHost().getHostAddress())host
- The target IP hostport
- The target TCP portcommunity
- The SNMP community stringenterprise
- The Enterprise OIDgenericTrap
- Trap type: coldStart(0), warmStart(1), linkDown(2), linkUp(3),
authenticationFailure(4), egpNeighborLoss(5),
enterpriseSpecific(6)specificTrap
- Used for enterpriseSpecific trapsoid
- The OID for the values. If oid is null, value must be an Entry
where the Attribute names will be used as OIDsvalue
- The value(s)
lastError
public Entry httpGet(String url)
Example:
var response = system.httpGet("http://www.mysite.com/files"); if (response == null) { task.logmsg("Error getting file: " + system.lastError); }
url
- Identifies the resource to get from the web server
httpRequest(String, String, String, Object)
,
lastError
public Entry httpPost(String url, Object file)
file
typically will be an application or a document that
must be opened in an application.
Example:
var file = "c:\\docs\\myfile.doc"); var response =system.httpPost("http://www.mysite.com/files",file); if (response == null){ task.logmsg("Error posting file: " + system.lastError); } else { task.logmsg("HTTP server response: " + response); }
url
- The URL to the web serverfile
- The file name to be sent. You can provide this parameter as a
String or as a java.io.File object. If this parameter is NULL
the method will do as GET with no additional data, otherwise a
POST is performed.
httpRequest(String, String, String, Object)
,
lastError
public Entry httpRequest(String method, String contentType, String url, Object file)
method
to web server at given address url
.
Example:
var file = new java.lang.FileInputStream("c:\\docs\\myfile.html"); var response; if (file.exist()) response = system.httpRequest("POST", "text/html", "http://www.mysite.com/files", file); if (response == null) { task.logmsg("Error sending file: " + system.lastError); } else { task.logmsg("HTTP server response: " + response); }
method
- Type of request method. Possible values: POST, GET, PUT etc.contentType
- Type of the contents.url
- The URL to the web serverfile
- The body of the request message
httpGet(String)
,
httpPost(String, Object)
public String arrayToString(byte[] array)
Example:
ret.value = system.arrayToString(work.getObject("userpassword"));
array
- The byte array to be converted
public boolean deleteFile(String filePath) throws Exception
Example:
var filePath = new java.lang.String("c:\\docs\\myfile.txt"); if (!system.deleteFile(filePath)) main.logmsg("Error file " + file + " not deleted!");
filePath
- The name of the file to be deleted
Exception
- if filePath
is not a filelastError
public boolean renameFile(String oldName, String newName)
Example:
var oldName = "c:\\docs\\myfile.txt"; var newName = "c:\\docs\\newname.txt"; if (! system.renameFile(oldName, newName) ) { //The rename failed. Handle the problem. }
oldName
- The old name of the filenewName
- The new name of the file
public boolean copyFile(String oldFile, String newFile)
var oldName = "c:\\docs\\myfile.txt"; var newName = "c:\\docs\\newname.txt"; system.copyFile(oldName, newName);
oldFile
- The name of the file to copynewFile
- The name of the new file
lastError
public TaskCallBlock newTCB()
Example:
var tcb = system.newTCB(); tcb.setAssemblyLineName("ALName"); tcb.setRunMode(com.ibm.di.server.AssemblyLine.RUNMODE_NORMAL); // "normal" var entry = system.newEntry(); entry.setAttribute("linenumber", "1"); entry.setAttribute("line", "Simple line of text!"); tcb.setInitialWorkEntry(entry); var al = main.startAL(tcb); al.join(); // Wait for called AL to complete
newEntry()
public TaskCallBlock newTCB(String assemblyLine)
assemblyLine
- name of the assembly line
public Object getPersistentObject(String key) throws Exception
key
- The unique key
Exception
public Object setPersistentObject(String key, Object value) throws Exception
key
- The unique keyvalue
- The object to store (must be java serializable)
Exception
public Object deletePersistentObject(String key) throws Exception
key
- The unique key
Exception
public static Vector<AssemblyLine> getRunningALs()
Example:
var ral = system.getRunningALs(); var al = new com.ibm.di.server.AssemblyLine(); task.logmsg("Running ALs:"); for (var i = 0; i < ral.size(); i++) { al = ral.get(i); task.logmsg(al.getShortName()); }
public static Vector<AssemblyLine> getRunningALs(String name)
name
- Find all AssemblyLines with this name. Only the last part of
the name (after optional /) is used.
public RacfCredential getRacfCredentialObject(byte[] pwbytes, String recipientKeystore, String recipientKeystorePW, String recipientCertAlias, String recipientCertPW, String signerKeystore, String signerKeystorePW, String signerCertAlias) throws Exception
pwbytes
- the byte array containing the racfpasswordenveloperecipientKeystore
- the file path to the recipient's keystore filerecipientKeystorePW
- the password for access to the recipient's keystore filerecipientCertAlias
- String alias name of certificate for recipientrecipientCertPW
- the password for access to the recipient's certificatesignerKeystore
- the file path to the signer's keystore file (note: signer cert
and recip cert keystore can be same file)signerKeystorePW
- the password for access to the recipient's keystore filesignerCertAlias
- String alias name of certificate for recipient
Exception
@Deprecated public RacfPassword getRacfPasswordObject(byte[] pwbytes, String recipientKeystore, String recipientKeystorePW, String recipientCertAlias, String recipientCertPW, String signerKeystore, String signerKeystorePW, String signerCertAlias) throws Exception
getRacfCredentialObject(byte[], String, String, String, String, String, String, String)
pwbytes
- recipientKeystore
- recipientKeystorePW
- recipientCertAlias
- recipientCertPW
- signerKeystore
- signerKeystorePW
- signerCertAlias
-
Exception
public String getRacfCredential(byte[] pwbytes, String recipientKeystore, String recipientKeystorePW, String recipientCertAlias, String recipientCertPW, String signerKeystore, String signerKeystorePW, String signerCertAlias) throws Exception
pwbytes
- the byte array containing the racfpasswordenveloperecipientKeystore
- the file path to the recipient's keystore filerecipientKeystorePW
- the password for access to the recipient's keystore filerecipientCertAlias
- String alias name of certificate for recipientrecipientCertPW
- the password for access to the recipient's certificatesignerKeystore
- the file path to the signer's keystore file (note: signer cert
and recip cert keystore can be same file)signerKeystorePW
- the password for access to the recipient's keystore filesignerCertAlias
- String alias name of certificate for recipient
Exception
@Deprecated public String getRacfPassword(byte[] pwbytes, String recipientKeystore, String recipientKeystorePW, String recipientCertAlias, String recipientCertPW, String signerKeystore, String signerKeystorePW, String signerCertAlias) throws Exception
getRacfCredential(byte[], String, String, String, String, String, String, String)
pwbytes
- recipientKeystore
- recipientKeystorePW
- recipientCertAlias
- recipientCertPW
- signerKeystore
- signerKeystorePW
- signerCertAlias
-
Exception
public String getRacfCredentialObjectDump(byte[] pwbytes, String recipientKeystore, String recipientKeystorePW, String recipientCertAlias, String recipientCertPW, String signerKeystore, String signerKeystorePW, String signerCertAlias) throws Exception
pwbytes
- the byte array containing the racfpasswordenveloperecipientKeystore
- the file path to the recipient's keystore filerecipientKeystorePW
- the password for access to the recipient's keystore filerecipientCertAlias
- String alias name of certificate for recipientrecipientCertPW
- the password for access to the recipient's certificatesignerKeystore
- the file path to the signer's keystore file (note: signer cert
and recip cert keystore can be same file)signerKeystorePW
- the password for access to the recipient's keystore filesignerCertAlias
- String alias name of certificate for recipient
Exception
@Deprecated public String getRacfPasswordObjectDump(byte[] pwbytes, String recipientKeystore, String recipientKeystorePW, String recipientCertAlias, String recipientCertPW, String signerKeystore, String signerKeystorePW, String signerCertAlias) throws Exception
pwbytes
- recipientKeystore
- recipientKeystorePW
- recipientCertAlias
- recipientCertPW
- signerKeystore
- signerKeystorePW
- signerCertAlias
-
Exception
public String getRsaEncrypted(String plainText, String ksPath, String ksPassword, String certificateAlias) throws Exception
plainText
- String representing value to be encrypted using public keyksPath
- String representing file path to jks fileksPassword
- String representing password for jks file as specified by pathcertificateAlias
- String naming the alias of certificate in keystore file
Exception
- when underlying function fails
Exception
public String getRsaDecrypted(String cipherText, String ksPath, String ksPassword, String certificateAlias, String certificatePassword) throws Exception
cipherText
- String representing value to be decrypted using private keyksPath
- String representing file path to jks fileksPassword
- String representing password for jks file as specified by pathcertificateAlias
- String naming the alias of certificate in keystore filecertificatePassword
- String representing password certificate
Exception
- when underlying function fails
Exception
public AssemblyLinePool createALPool(String assemblyLine, Log log) throws Throwable
assemblyLine
- The name of the assemblylinelog
- The Log object to use or null to use the system logger
Throwable
public FunctionInterface getFunction(String name) throws Exception
name
- The name of the function.
Exception
public static String base64Encode(byte[] b)
Example:
var e = Array(6); e[0] = 7; e[1] = -66; e[2] = -35; e[3] = -21; e[4] = -66; e[5] = -35; task.logmsg("Result: " + system.base64Encode(e)); //B77d677d
b
- byte array containing binary data
public static byte[] base64Decode(String str)
Example:
var str = "B77d677d"; task.logmsg("Result: " + system.base64Decode(str)); //7,-66,-35,-21,-66,-35
str
- String containing base64 Data.
public static String encodeToHexstring(byte[] data)
Example:
var e = new Array(4); e[0] = 7; e[1] = -66; e[2] = -35; e[3] = -21; task.logmsg("Result: " + system.encodeToHexstring(e)); // \07\be\dd\eb
data
- byte array containing binary data
public static IDispatch createCOMInstance(String progID)
Example:
var cominst = system.createCOMInstance("Word.Basic");
progID
- the progID (Programmatic IDentifier)is a string that uniquely
identifies the COM object, stored in the registry and is of
the form: Project.ClassName
public static MemBufferQ newPipe(String instName, String pipeName, int watermark) throws Exception
Example:
var con = input.getConnector(); var pipe = system.newPipe(null, "new_pipe", 2); var entry1 = con.getNextEntry(); pipe.write(entry1); var entry2 = con.getNextEntry(); pipe.write(entry2);
instName
- name of the instance. Default instance will be used if this
param is null.pipeName
- name of the pipe to be createdwatermark
- With Paging On, it is the threshold at which objects are
persisted to the System Store With Paging Off, it is the
maximum queue size
Exception
public static MemBufferQ newPipe(String instName, String pipeName, int watermark, int pagesize) throws Exception
instName
- name of the instance. Default instance will be used if this
param is null.pipeName
- name of the pipe to be createdwatermark
- With Paging On, it is the threshold at which objects are
persisted to the System Store With Paging Off, it is the
maximum queue sizepagesize
-
Exception
public static MemBufferQ getPipe(String instName, String pipeName) throws Exception
instName
- name of the instance. Default instance will be used if this
param is null.pipeName
- name of the pipe to be returned
Exception
public static void deletePipe(String instName, String pipeName) throws Exception
instName
- name of the instance. Default instance will be used if this
param is null.pipeName
- name of the pipe to be deleted
Exception
public static void deletePipe(String pipeName) throws Exception
pipeName
- name of the pipe to be deleted
Exception
@Deprecated public Object getExternalProperty(String propName) throws Exception
getTDIProperty(String)
instead
Note that the getTDIProperty(String)
method is recommended over
this older version.
propName
-
Exception
@Deprecated public void setExternalProperty(String propName, Object value) throws Exception
setTDIProperty(String, Object)
instead
propName
- value
-
Exception
@Deprecated public Object getExternalProperty(String extObj, String propName) throws Exception
getTDIProperty(String, String)
instead
Implementation of the method is changed due to defect 12968
Note that the getTDIProperty(String, String)
method is
recommended over this older version.
extObj
- propName
-
Exception
@Deprecated public void setExternalProperty(String extObj, String propName, Object value) throws Exception
setTDIProperty(String, String, Object)
instead
extObj
- propName
- value
-
Exception
@Deprecated public ExternalPropertiesConfig getExtProp(String name) throws Exception
getTDIProperties()
instead
Note that the getTDIProperty(String)
and
getTDIProperty(String, String)
methods are recommended over this
older version.
name
- name of the extprop
Exception
public String binaryGUIDtoString(byte[] binaryData)
Example:
var e = new Array(4); e[0] = 0xd0; e[8] = 0x8a; e[1] = 0xef; e[9] = 0x94; e[2] = 0x68; e[10] = 0xb1; e[3] = 0x8e; e[11] = 0xc1; e[4] = 0xbe; e[12] = 0x46; e[5] = 0x1a; e[13] = 0x85; e[6] = 0x5c; e[14] = 0xbe; e[7] = 0x40; e[15] = 0xd7; task.logmsg("Result: " + system.binaryGUIDtoString(e)); //{8E68EFD0-1ABE-405C-8A94-B1C14685BED7}
binaryData
- a 16-byte byte array, holding the 128-bit binary
representation of the GUID.
public static String removeInvalidXMLChars(String aString)
aString
- string to clean
public static void loadJarFile(String path)
path
- The full path name of a jar file or a directory containing jar
filesIDILoader.addFiles(String)
public TDIProperties getTDIProperties() throws Exception
Exception
public Object getTDIProperty(String name) throws Exception
name
- The name of the property
Exception
public Object getTDIProperty(String propstore, String name) throws Exception
propstore
- The property store namename
- The name of the property
Exception
public void setTDIProperty(String name, Object value) throws Exception
name
- The name of the propertyvalue
- The property value
Exception
public void setTDIProperty(String propstore, String name, Object value) throws Exception
propstore
- The property store namename
- The name of the propertyvalue
- The property value
Exception
public static boolean startsWithIC(String first, String second)
Example:
var str1 = "IBM Corporation"; var str2 = "ibm"; if (system.startsWithIC(str1, str2)) { task.logmsg("str1 starts with str2"); } else { task.logmsg("str1 does not start with str2"); }
first
- The first Stringsecond
- The second String
public static boolean endsWithIC(String first, String second)
Example:
var str1 = "Directory Integrator"; var str2 = "Rator"; if (system.endsWithIC(str1, str2)) { task.logmsg("str1 ends with str2"); } else { task.logmsg("str1 does not end with str2"); }
first
- The first Stringsecond
- The second String
public static boolean containsIC(String first, String second)
Example:
system.containsIC("abcde", "BCD"); // Returns true system.containsIC("abcde", "bd"); // Returns false
first
- The first Stringsecond
- The second String
public static ParameterSubstitution getTDIExpression(String pattern) throws Exception
" John 62-58-99
Lily 056/6563425
Michael +359 88 540 90"
And read this file into two fields called 'name' and 'phone' you could print the information by this way:
expression = system.getTDIExpression("{work.name}'s number is {work.phone}."); map = new java.util.HashMap(); map.put("mc", main.getMetamergeConfig()); while ((work = input.getConnector().getNextEntry()) != null) { map.put("work", work); task.logmsg(expression.substitute(map)); // John's number is 62-58-99. and so on... }
pattern
- The pattern to use for substitution.
Exception
substitute(String, Map)
public static String substitute(String pattern, Map<String,Object> params) throws Exception
You should at least provide "mc=MetamergeConfig" or "config=BaseConfiguration" object, otherwise expansion of TDI-properties will not work. If you want to expand AL component parameters, you need to provide a "config=BaseConfiguration" object.
Example:
map = new java.util.HashMap(); map.put("mc", main.getMetamergeConfig()); map.put("work", work); result = system.substitute("{work.cn} {property.myprop}", map);
pattern
- The pattern string to expandparams
- The available objects (e.g. conn, work, task etc)
Exception
public static String substitute(String pattern, String[] names, Object[] objects) throws Exception
Example:
result = system.substitute("{work.cn} {property.myprop}", ["mc", "work"], [main.getMetamergeConfig(), work]);
pattern
- The pattern string to expandnames
- The names of the available objects (e.g. "conn", "work",
"task" etc)objects
- The available objects (e.g. conn, work, task etc)
Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |