Class UserFunctions
- java.lang.Object
-
- com.ibm.di.function.UserFunctions
-
public class UserFunctions extends java.lang.Object
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
Fields Modifier and Type Field Description static char[]
INVALID_XML_CHARS
java.lang.Exception
lastError
The Exception object set by the last call in this library.RSInterface
server
RSInterface
object.
-
Constructor Summary
Constructors Constructor Description UserFunctions()
Default constructor.UserFunctions(RSInterface server)
Constructor with one parameter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abortAssemblyLine(java.lang.String reason)
Throws an AbortALException to instruct the AssemblyLine to terminate.java.lang.String
arrayToString(byte[] array)
Converts a ByteArray to a string using platform's default charset.static byte[]
base64Decode(java.lang.String str)
base64Decode: Obtain Byte Array from a Base 64 encoded String.static java.lang.String
base64Decode(java.lang.String str, java.lang.String encoding)
Converts a base64 encoded String back to a regular String.static java.lang.String
base64Encode(byte[] b)
base64Encode: Obtain Base 64 encoded String from a binary Byte Arraystatic java.lang.String
base64Encode(java.lang.String string, java.lang.String encoding)
Return the base64 encoding of a String.java.lang.String
binaryGUIDtoString(byte[] binaryData)
Generates the hexadecimal String representation of an Active Directory GUID based on its 128-bit binary representation.boolean
chdir(java.lang.String directory)
Change Java runtime working directory.static boolean
containsIC(java.lang.String first, java.lang.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(java.lang.String name)
Throws a ContinueLoopException to tell the AssemblyLine to continue with the next value in the named loop.boolean
copyBinaryFile(java.lang.String fromPath, java.lang.String toPath, boolean overwrite)
Deprecated.UsecopyFile(String, String)
insteadvoid
copyDirectory(java.lang.String source, java.lang.String target, boolean recursive, boolean overwrite, Log log)
Copy a directory.static boolean
copyFile(java.io.File fromFile, java.io.File toFile, boolean overwrite)
Copy file.boolean
copyFile(java.lang.String oldFile, java.lang.String newFile)
Copy a file.static boolean
copyFile(java.lang.String fromPath, java.lang.String toPath, boolean overwrite)
Copy file.AssemblyLinePool
createALPool(java.lang.String assemblyLine, Log log)
Creates an AssemblyLine Pool object from the specified AssemblyLine name.static IDispatch
createCOMInstance(java.lang.String progID)
Creates an IDispatch automation object.boolean
deleteFile(java.lang.String filePath)
Deletes a file.java.lang.Object
deletePersistentObject(java.lang.String key)
This method deletes a named object in the default system property store.static void
deletePipe(java.lang.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(java.lang.String instName, java.lang.String pipeName)
Deletes the specified pipe from the specified instance.java.lang.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(java.lang.String className)
Dumps the public methods for a Java class.static java.lang.String
encodeToHexstring(byte[] data)
encodeToHexstring: Obtain HexString from a byte array.static boolean
endsWithIC(java.lang.String first, java.lang.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.java.lang.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(java.lang.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.java.lang.String
formatDate(java.util.Date date, java.lang.String format)
This method formats a java.util.Date object using the provided template.ConnectorInterface
getConnector(java.lang.String name)
Load a connector.java.lang.String
getcwd()
Returns the current working directory.java.lang.Object
getExternalProperty(java.lang.String propName)
Deprecated.usegetTDIProperty(String)
insteadjava.lang.Object
getExternalProperty(java.lang.String extObj, java.lang.String propName)
Deprecated.usegetTDIProperty(String, String)
instead Implementation of the method is changed due to defect 12968ExternalPropertiesConfig
getExtProp(java.lang.String name)
Deprecated.usegetTDIProperties()
insteadFTPBean
getFTP()
Returns an instance of the FTP object.FunctionInterface
getFunction(java.lang.String name)
Load a Function component Interface from the current Config.java.lang.String
getJavaProperty(java.lang.String prop)
Returns the value for a system property.java.lang.String
getOSName()
Returns the name of the operating system.ParserInterface
getParser(java.lang.String name)
Load a parser Interface from the current Config.java.lang.Object
getPersistentObject(java.lang.String key)
This method retrieves a named object from the default system property store.static MemBufferQ
getPipe(java.lang.String instName, java.lang.String pipeName)
This method returns a handle to a pipe with the specified instName and pipeName (if it already exists).java.lang.String
getRsaDecrypted(java.lang.String cipherText, java.lang.String ksPath, java.lang.String ksPassword, java.lang.String certificateAlias, java.lang.String certificatePassword)
getRsaDecrypted: Obtain plain ascii text for encrypted ciphertext specified.java.lang.String
getRsaEncrypted(java.lang.String plainText, java.lang.String ksPath, java.lang.String ksPassword, java.lang.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 java.util.Vector<AssemblyLine>
getRunningALs()
This method returns a Vector containing all AssemblyLines that were running when the function was called.static java.util.Vector<AssemblyLine>
getRunningALs(java.lang.String name)
This method returns a Vector containing all AssemblyLines with the given name that were running when the function was calledstatic java.util.Vector<Sequence>
getRunningSequences(java.lang.String name)
This method returns a Vector containing all Sequences with the given name that were running when the function was calledjava.lang.String
getScriptText(java.lang.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.java.lang.String
getStackTrace(java.lang.Throwable t)
Returns the backtrace for a throwable.static ParameterSubstitution
getTDIExpression(java.lang.String pattern)
Returns a ParameterSubstitution object using the given pattern.TDIProperties
getTDIProperties()
Returns the TDIProperties object for the current configurationjava.lang.Object
getTDIProperty(java.lang.String name)
Returns the value for a TDI propertyjava.lang.Object
getTDIProperty(java.lang.String propstore, java.lang.String name)
Returns the property value from a specific TDI property storejava.lang.String
getX400Attribute(java.lang.String x400, java.lang.String sep, java.lang.String attribute)
Returns an attribute value from an X.400 address.org.apache.xpath.XPathAPI
getXPathAPI()
Returns the Apache XPathAPIEntry
httpGet(java.lang.String url)
Gets file from a web server.Entry
httpPost(java.lang.String url, java.lang.Object file)
Posts file to a web server.Entry
httpRequest(java.lang.String method, java.lang.String contentType, java.lang.String url, java.lang.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(java.lang.String msg)
Throws an IgnoreEntryException to tell the AssemblyLine to skip the current component and continue with the next component in flow.boolean
isValidInt(java.lang.String str)
Returns true if a string holds a valid Integer.ConnectorInterface
loadConnector(java.lang.String connectorName)
Load a Connector Interface from the current Config.static void
loadJarFile(java.lang.String path)
Dynamically add jar file containing class definitions.java.lang.String
makeTitleCase(java.lang.String in)
Convert A String Into Title Case (Like This), using the current Locale.java.lang.String
mapString(java.lang.String source, java.lang.String fromSet, java.lang.String toSet)
Translates characters in a string.Attribute
newAttribute(java.lang.String name)
Creates a new Attribute object.Entry
newEntry()
Creates a new Entry object.java.lang.Object
newObject(java.lang.String className)
Creates a new object.static MemBufferQ
newPipe(java.lang.String instName, java.lang.String pipeName, int watermark)
This method create a new Memory Buffer Queue if it does not already exist.static MemBufferQ
newPipe(java.lang.String instName, java.lang.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(java.lang.String assemblyLine)
Create a TaskCallBlock with i/o specifications from an existing assemblyline.java.lang.String
normalizeX400(java.lang.String value, java.lang.String cursep, java.lang.String newsep)
Converts an X.400 address to a string using short form attribute names.java.io.BufferedWriter
openFileForAppend(java.lang.String path)
Opens a file in append mode and returns the associated BufferedWriter object.java.io.BufferedReader
openFileForInput(java.lang.String path)
Opens a file for input and returns the associated BufferedReader object.java.io.BufferedWriter
openFileForOutput(java.lang.String path)
Opens a file in output mode and returns the associated BufferedWriter object.java.util.Date
parseDate(java.lang.String value, java.lang.String format)
Converts a String to a java.util.Date object.Entry
parseObject(java.lang.String parser, java.lang.Object data)
Use a parser to interpret data.byte[]
readBytes(java.lang.String fileName)
Returns all bytes in the file as a byte array.java.lang.String
remove(java.lang.String s, java.lang.String source)
Remove characters from a string.static java.lang.String
removeInvalidXMLChars(java.lang.String aString)
Removes invalid XML chars.java.lang.String
removeStringChars(java.lang.String source, java.lang.String fromSet)
Removes occurrences of characters from a string.boolean
renameFile(java.lang.String oldName, java.lang.String newName)
Rename a file.void
restartEntry()
Throws a RestartEntryException to tell the AssemblyLine to restart.void
restartEntry(java.lang.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(org.w3c.dom.Node contextNode, java.lang.String str)
Selects nodes using an XPath expression from an XML node.org.w3c.dom.NodeList
selectNodeList(org.w3c.dom.Node contextNode, java.lang.String str)
Selects nodes using an XPath expression from an XML node.org.w3c.dom.Node
selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String str)
Selects a single node using an XPath expression from an XML node.java.lang.String
sendMail(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String attachments)
Sends an email message.java.lang.String
sendMail(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String attachments, java.lang.String replyTo)
Sends an email message with ReplyTo field.void
setExternalProperty(java.lang.String propName, java.lang.Object value)
Deprecated.usesetTDIProperty(String, Object)
insteadvoid
setExternalProperty(java.lang.String extObj, java.lang.String propName, java.lang.Object value)
Deprecated.usesetTDIProperty(String, String, Object)
insteadvoid
setJavaProperty(java.lang.String prop, java.lang.String value)
Sets the value of a property name.java.lang.Object
setPersistentObject(java.lang.String key, java.lang.Object value)
This method stores a named object in the default system property store.void
setTDIProperty(java.lang.String name, java.lang.Object value)
Sets the property value for a property (store selection based on naming rules and order).void
setTDIProperty(java.lang.String propstore, java.lang.String name, java.lang.Object value)
Sets the property value in a specific TDI property storeExecuteCommand
shellCommand(java.lang.String command)
Executes a shell command.ExecuteCommand
shellCommand(java.lang.String command, java.lang.Object args)
Executes a shell command with arguments.ExecuteCommand
shellCommand(java.lang.String command, java.lang.String cp, java.lang.Object args)
Executes a shell command with encoding (codepage) and arguments.ExecuteCommand
shellCommandCP(java.lang.String command, java.lang.String cp)
Executes a shell command with encoding (codepage).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(java.lang.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(java.lang.String name)
Throws a SkipToException to tell the AssemblyLine to skip to the named Connector/ScriptComponent.java.lang.InterruptedException
sleep(int seconds)
Causes the current thread (e.g.boolean
snmpTrap(java.lang.String host, int port, java.lang.String oid, java.lang.String value)
Sends an SNMP trap.boolean
snmpTrap(java.lang.String agentIP, java.lang.String host, int port, java.lang.String community, java.lang.String enterprise, int genericTrap, int specificTrap, java.lang.String oid, java.lang.Object value)
Sends an SNMP trap.java.lang.String[]
splitString(java.lang.String source, java.lang.String separators)
Splits a string into an array of strings.static boolean
startsWithIC(java.lang.String first, java.lang.String second)
Returns true if the first String starts with the second String, ignoring case.static java.lang.String
substitute(java.lang.String pattern, java.lang.String[] names, java.lang.Object[] objects)
Performs a one-time parsing and substitution of pattern with named objects.static java.lang.String
substitute(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params)
Performs a one-time parsing and substitution of pattern with the objects available in params.void
throwException(java.lang.String message)
Throws a generic java.lang.Exception.java.lang.String
toHex(java.lang.String str)
Converts a string to a hexadecimal string where each character is converted to a two-byte hex value.java.lang.Integer
toInt(java.lang.String str)
Convert a string to a java.lang.Integer object.java.lang.String
translateString(java.lang.String str, java.lang.String fromCharset, java.lang.String toCharset)
Translate a string from one character set to another.java.lang.String
trim(java.lang.String str)
Trims leading/trailing white-space from a string.void
writeln(java.io.Writer w, java.lang.String str)
Writes a string plus a CRLF using a Writer object.java.lang.String
xslTransform(java.lang.Object xsl, java.lang.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.
-
-
-
Field Detail
-
lastError
public java.lang.Exception lastError
The Exception object set by the last call in this library.
-
server
public RSInterface server
RSInterface
object.
-
INVALID_XML_CHARS
public static final char[] INVALID_XML_CHARS
-
-
Constructor Detail
-
UserFunctions
public UserFunctions()
Default constructor.
-
UserFunctions
public UserFunctions(RSInterface server)
Constructor with one parameter.- Parameters:
server
- server instance
-
-
Method Detail
-
getServer
public RSInterface getServer()
Returns the RS instance associated with the current ThreadGroup, or the dummy RSInterface object defined by the Config Editor. Although this method is public, it is meant for internal use,. The usual way to get the current RS instance would be to use themain
object in JavaScript.- Returns:
- the
RS
instance ornull
if it couldn't be found, e.g. because the current Thread was not created by the TDI framework.
-
remove
public java.lang.String remove(java.lang.String s, java.lang.String source) throws java.lang.Exception
Remove characters from a string. For example, if you want to remove all blanks from the string "J O P" then you would useremove (" ", "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"
- Parameters:
s
- The characters to be removedsource
- The string from which characters are removed- Returns:
- string with removed characters specified by
s
- Throws:
java.lang.Exception
-
trim
public java.lang.String trim(java.lang.String str)
Trims leading/trailing white-space from a string. Returns an empty string if the argument is null.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"
- Parameters:
str
- The string to trim- Returns:
- The trimmed string
-
toInt
public java.lang.Integer toInt(java.lang.String str) throws java.lang.Exception
Convert a string to a java.lang.Integer object.- Parameters:
str
- The string with a number- Returns:
- The Integer object
- Throws:
java.lang.Exception
-
isValidInt
public boolean isValidInt(java.lang.String str)
Returns true if a string holds a valid Integer.- Parameters:
str
- The string to test- Returns:
- True if the string can be converted to an Integer
-
openFileForAppend
public java.io.BufferedWriter openFileForAppend(java.lang.String path) throws java.lang.Exception
Opens a file in append mode and returns the associated BufferedWriter object. The default character encoding is used.Example:
var out = system.openFileForAppend("out.txt"); out.write("Hello world!"); out.newLine(); out.close();
- Parameters:
path
- The file path to open. If the file does not exist it is created.- Returns:
- The BufferedWriter object
- Throws:
java.lang.Exception
-
openFileForOutput
public java.io.BufferedWriter openFileForOutput(java.lang.String path) throws java.lang.Exception
Opens a file in output mode and returns the associated BufferedWriter object.Example:
var out = system.openFileForOutput("out.txt"); out.write("Hello world!"); out.newLine(); out.close();
- Parameters:
path
- The file path to open (overwrites existing file)- Returns:
- The BufferedWriter object
- Throws:
java.lang.Exception
-
openFileForInput
public java.io.BufferedReader openFileForInput(java.lang.String path) throws java.lang.Exception
Opens a file for input and returns the associated BufferedReader object. The default character encoding is used.Example:
var inp = system.openFileForInput("inp.txt"); var str = inp.readLine(); if (str == null) task.logmsg("End of file"); inp.close();
- Parameters:
path
- The file path to open- Returns:
- The BufferedReader object
- Throws:
java.lang.Exception
- FileNotFoundException
-
writeln
public void writeln(java.io.Writer w, java.lang.String str) throws java.lang.Exception
Writes a string plus a CRLF using a Writer object.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.- Parameters:
w
- The writer objectstr
- The string to write- Throws:
java.lang.Exception
-
sendMail
public java.lang.String sendMail(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String attachments) throws java.lang.Exception
Sends an email message. Make sure the mail.smtp.host Java property is configured with the hostname of a valid SMTP server.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);
- Parameters:
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 message- Returns:
- If null, the message was sent. Otherwise, this is the error message.
- Throws:
java.lang.Exception
-
sendMail
public java.lang.String sendMail(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String attachments, java.lang.String replyTo) throws java.lang.Exception
Sends an email message with ReplyTo field. Make sure the mail.smtp.host Java property is configured with the hostname of a valid SMTP server.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);
- Parameters:
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- Returns:
- If null, the message was sent. Otherwise, this is the error message.
- Throws:
java.lang.Exception
-
copyFile
public static boolean copyFile(java.lang.String fromPath, java.lang.String toPath, boolean overwrite) throws java.lang.Exception
Copy file. This method copies fromPath to toPath. The overwrite flag specifies whether the destination file should be overwritten.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!");
- Parameters:
fromPath
- The source filetoPath
- The destination fileoverwrite
- Specify true if destination should be overwritten.- Returns:
- true if file was copied, false if toPath exists and overwrite=false.
- Throws:
java.lang.Exception
-
copyFile
public static boolean copyFile(java.io.File fromFile, java.io.File toFile, boolean overwrite) throws java.lang.Exception
Copy file. This method copies fromPath to toPath. The overwrite flag specifies whether the destination file should be overwritten.- Parameters:
fromFile
- The source filetoFile
- The destination fileoverwrite
- Specify true if destination should be overwritten.- Returns:
- true if file was copied, false if toPath exists and overwrite=false.
- Throws:
java.lang.Exception
-
copyBinaryFile
@Deprecated public boolean copyBinaryFile(java.lang.String fromPath, java.lang.String toPath, boolean overwrite) throws java.lang.Exception
Deprecated.UsecopyFile(String, String)
insteadCopy file. This method copies fromPath to toPath without using buffer. The overwrite flag specifies whether the destination file should be overwritten.- Parameters:
fromPath
- The name of the file to copytoPath
- The name of the new fileoverwrite
- Specify true if destination should be overwritten.- Returns:
true
if copyBinaryFile successed, otherwisefalse
.- Throws:
java.lang.Exception
-
copyDirectory
public void copyDirectory(java.lang.String source, java.lang.String target, boolean recursive, boolean overwrite, Log log) throws java.lang.Exception
Copy a directory. The recursive flag specifies whether recursion should be used to copy child directories oftarget
.Example:
var dir1 = "c:\\docs"; var dir2 = "c:\\backup"; system.copyDirectory(dir1, dir2, true, true, null);
- Parameters:
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- Throws:
java.lang.Exception
-
newAttribute
public Attribute newAttribute(java.lang.String name)
Creates a new Attribute object.Example:
ocAttr = system.newAttribute("objectClass"); ocAttr.addValue("top"); ocAttr.addValue("person"); ocAttr.addValue("organizationalPerson"); ocAttr.addValue("inetOrgPerson"); work.setAttribute(ocAttr);
- Parameters:
name
- The attribute name- Returns:
- The Attribute object
-
newSearchCriteria
public SearchCriteria newSearchCriteria()
Creates a new rscSearchCriteira object.- Returns:
- The SearchCriteria object
- See Also:
SearchCriteria
-
newEntry
public Entry newEntry()
Creates a new Entry object.Example:
var entry = system.newEntry(); entry.setAttribute("linenumber", "1"); entry.setAttribute("line", "Simple line of text!"); write.getConnector().putEntry(entry);
- Returns:
- The Entry object
- See Also:
newAttribute(String)
-
newObject
public java.lang.Object newObject(java.lang.String className)
Creates a new object. This method only works for Java objects that have empty constructors. It is a convenience method for scripting languages that cannot create Java objects directly.- Parameters:
className
- The java class name- Returns:
- The newly created object
-
skipEntry
public void skipEntry() throws SkipEntryException
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.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.- Throws:
SkipEntryException
- to tell the AssemblyLine to skip the current Entry.- See Also:
skipTo(String)
-
skipEntry
public void skipEntry(java.lang.String msg) throws SkipEntryException
* 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.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.- Parameters:
msg
- A message supplied by the user- Throws:
SkipEntryException
- to tell the AssemblyLine to skip the current Entry.- See Also:
skipEntry()
-
ignoreEntry
public void ignoreEntry() throws IgnoreEntryException
Throws an IgnoreEntryException to tell the AssemblyLine to skip the current component and continue with the next component in flow.- Throws:
IgnoreEntryException
-
ignoreEntry
public void ignoreEntry(java.lang.String msg) throws IgnoreEntryException
Throws an IgnoreEntryException to tell the AssemblyLine to skip the current component and continue with the next component in flow.- Parameters:
msg
- A message supplied by the user- Throws:
IgnoreEntryException
-
restartEntry
public void restartEntry() throws RestartEntryException
Throws a RestartEntryException to tell the AssemblyLine to restart. The AssemblyLine will continue at the first non-Iterator component in the AssemblyLine, using the current work object.- Throws:
RestartEntryException
-
restartEntry
public void restartEntry(java.lang.String msg) throws RestartEntryException
Throws a RestartEntryException to tell the AssemblyLine to restart, using the current work object.- Parameters:
msg
- A message supplied by the user- Throws:
RestartEntryException
- See Also:
restartEntry()
-
retryEntry
public void retryEntry() throws RetryEntryException
Throws a RetryEntryException to tell the AssemblyLine to retry this component. The AssemblyLine will perform the operation of the current component again, using the current work object.- Throws:
RetryEntryException
-
skipTo
public void skipTo(java.lang.String name) throws SkipToException
Throws a SkipToException to tell the AssemblyLine to skip to the named Connector/ScriptComponent.- Parameters:
name
- The name of the Connector to skip to.- Throws:
SkipToException
-
abortAssemblyLine
public void abortAssemblyLine(java.lang.String reason) throws AbortALException
Throws an AbortALException to instruct the AssemblyLine to terminate. The AssemblyLine will continue with the Epilog. If the Epilog is already executed, continue on to the next step (closing Connectors or "Epilog - After Close").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.
- Parameters:
reason
- Descriptive text why the AssemblyLine is terminated- Throws:
AbortALException
- See Also:
exitBranch()
-
throwException
public void throwException(java.lang.String message) throws java.lang.Exception
Throws a generic java.lang.Exception.Whereas the JavaScript throw command allows you to throw a JavaScript exception, this method creates and throws a
Exception
object.- Parameters:
message
- The message text of the Exception- Throws:
java.lang.Exception
-
exitBranch
public void exitBranch() throws ExitBranchException
Throws an ExitBranchException that tells the AssemblyLine to exit the current branch/loop.- Throws:
ExitBranchException
-
exitBranch
public void exitBranch(java.lang.String name) throws ExitBranchException
Throws an ExitBranchException that tells the AssemblyLine to exit the named branch/loop. Some special values for name can also be used:
null - exit current (innermost) branch or loop
"Loop" - exit current Loop
"Branch" - exit current branch
"Cycle" - exit this cycle (jump to end of cycle), and begin the next cycle
"Flow" - jump to end of cycle, and send response if there is a Connector in Server mode. Then begin the next cycle
"AssemblyLine" - exit dataflow, jump to Epilog- Parameters:
name
- The name of the branch/loop to exit- Throws:
ExitBranchException
- to tell the AssemblyLine to exit the named branch/loop
-
exitFlow
public void exitFlow() throws ExitBranchException
Throws an ExitBranchException that tells the AssemblyLine to not execute any more of the Flow Section components. In other words, the current cycle of the AL ends, and in the case of a Server mode Connector, the Response is carried out.This behavior is identical to that caused by the following call:
system.exitBranch("Flow");
- Throws:
ExitBranchException
- to tell the AssemblyLine to exit the Flow Section
-
exitFlow
public void exitFlow(boolean skipResponse) throws ExitBranchException
Throws an ExitBranchException that tells the AssemblyLine to not execute any more of the Flow Section components. In other words, the current cycle of the AL ends.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.
- Parameters:
skipResponse
- Whether or not a Response should be sent if a Server mode Connector is feeding this AL.- Throws:
ExitBranchException
- to tell the AssemblyLine to exit the Flow Section
-
continueLoop
public void continueLoop() throws ContinueLoopException
Throws a ContinueloopException to tell the AssemblyLine to continue with the next value in the loop.- Throws:
ContinueLoopException
-
continueLoop
public void continueLoop(java.lang.String name) throws ContinueLoopException
Throws a ContinueLoopException to tell the AssemblyLine to continue with the next value in the named loop.- Parameters:
name
- The name of the loop- Throws:
ContinueLoopException
-
loadConnector
public ConnectorInterface loadConnector(java.lang.String connectorName)
Load a Connector Interface from the current Config.Example:
var con = system.loadConnector("ADChangelogConnectorv2"); con.initialize(null);
- Parameters:
connectorName
- The connector name as it appears in the configuration file- Returns:
- The connector object
-
dtSeconds
public java.lang.String dtSeconds()
Returns the number of milliseconds since Jan 1 1970 as a string.- Returns:
- Number of milliseconds
-
sleep
public java.lang.InterruptedException sleep(int seconds)
Causes the current thread (e.g. AssemblyLine, etc..) to sleep for a number of seconds. If the sleep is interrupted the InterruptedException value is returned. If not, null is returned.- Parameters:
seconds
- Number of seconds to sleep- Returns:
- null if successful, exception object otherwise
-
removeStringChars
public java.lang.String removeStringChars(java.lang.String source, java.lang.String fromSet)
Removes occurrences of characters from a string. The method is case sensitive.Example:
var str = "Some short string"; var str1 = system.removeStringChars(str, 's'); task.logmsg("Result: " + str1); //Some hort tring
- Parameters:
source
- The source stringfromSet
- A string specifying characters to be removed from source- Returns:
- The resulting string
-
makeTitleCase
public java.lang.String makeTitleCase(java.lang.String in)
Convert A String Into Title Case (Like This), using the current Locale.Example:
var str = "some short string"; var str1 = system.makeTitleCase(str); task.logmsg("Result: " + str1); //Some Short String
- Parameters:
in
- The string to convert- Returns:
- The converted string
-
mapString
public java.lang.String mapString(java.lang.String source, java.lang.String fromSet, java.lang.String toSet)
Translates characters in a string. The fromSet and toSet contains the characters used to perform substitution. The first character in fromSet is replace with the first character in toSet etc.Example:
var str = system.mapString("Some example text", "Somexamplt", "Noneracklg"); task.logmsg("Result: " + str); //None erankle gerg
- Parameters:
source
- The source stringfromSet
- The characters to be replacedtoSet
- The characters to replace characters in fromSet- Returns:
- The substituted string
-
translateString
public java.lang.String translateString(java.lang.String str, java.lang.String fromCharset, java.lang.String toCharset)
Translate a string from one character set to another.Example:
var str = system.translateString("Some example text", "UTF-8", "UTF-16"); task.logmsg("Result: " + str);
- Parameters:
str
- The source stringfromCharset
- The source character settoCharset
- The target character set- Returns:
- The translated string
-
toHex
public java.lang.String toHex(java.lang.String str)
Converts a string to a hexadecimal string where each character is converted to a two-byte hex value.Example:
var str = system.toHex("text"); task.logmsg("Result: " + str); //74 65 78 74
- Parameters:
str
- The source string- Returns:
- The hexadecimal string
-
getX400Attribute
public java.lang.String getX400Attribute(java.lang.String x400, java.lang.String sep, java.lang.String attribute)
Returns an attribute value from an X.400 address.Example:
var str = "C=no;ADMD= ;PRMD=uninett;O=sintef;OU=delab;S=Smith;G=John"; task.logmsg("Result: " + system.getX400Attribute(str, ';', "PRMD"));
- Parameters:
x400
- The X.400 addresssep
- The separator used in the address ( typically "/" or ";" )attribute
- The X.400 attribute- Returns:
- The value or null if no attribute was found
-
normalizeX400
public java.lang.String normalizeX400(java.lang.String value, java.lang.String cursep, java.lang.String newsep)
Converts an X.400 address to a string using short form attribute names. Attributes are sorted in order of significance.Example:
var str = "C=no;ADMD= ;PRMD=uninett;O=sintef;OU=delab;S=Smith;G=John"; task.logmsg("Result: " + system.normalizeX400(str, ';', '/'));
- Parameters:
value
- The X.400 addresscursep
- The separator used in valuenewsep
- The separator to be used in the result- Returns:
- The reformatted X.400 address
-
parseDate
public java.util.Date parseDate(java.lang.String value, java.lang.String format)
Converts a String to a java.util.Date object.Example:
var dateobj = system.parseDate("23/01/07", "DD/MM/yy"); task.logmsg("Result: " + dateobj); //Tue Jan 23 00:00:00 EET 2007
- Parameters:
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://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html- Returns:
- The Date object or null if an error occurred
- See Also:
lastError
-
formatDate
public java.lang.String formatDate(java.util.Date date, java.lang.String format)
This method formats a java.util.Date object using the provided template.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"));
- Parameters:
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.- Returns:
- The string representation or null if an error occurred
- See Also:
lastError
-
splitString
public java.lang.String[] splitString(java.lang.String source, java.lang.String separators)
Splits a string into an array of strings.Example:
var str = "Some short string"; task.logmsg("Result: " + system.splitString(str, ' ')); //Some,short,string
- Parameters:
source
- The source stringseparators
- The word-separating characters- Returns:
- Array of strings
-
getConnector
public ConnectorInterface getConnector(java.lang.String name)
Load a connector. This method loads a connector from the current config file. The call to this method is the same as loadConnector(String).- Parameters:
name
- The connector name as it appears in the configuration file- Returns:
- The connector object
- See Also:
loadConnector(String)
-
getParser
public ParserInterface getParser(java.lang.String name)
Load a parser Interface from the current Config.- Parameters:
name
- The parser name as it appears in the configuration file- Returns:
- The parser object
-
parseObject
public Entry parseObject(java.lang.String parser, java.lang.Object data)
Use a parser to interpret data. This method will either use the data object as-is if it is a reader or inputstream class, or it will create a StringReader from the string representation of the data object and pass it to the parser. The parser will be called to interpret the byte stream and return an Entry. If the parse fails a null is returned.Example:
var data = new java.io.FileInputStream("c:\\docs\\LDIFfile.txt"); var entry = system.newEntry(); entry = system.parseObject("LDIFParser", data); task.dumpEntry(entry);
- Parameters:
parser
- The parser namedata
- Any object of type Reader, InputStream or object that has a toString method- Returns:
- The parsed entry or null if the parser fails
- See Also:
lastError
-
shellCommand
public ExecuteCommand shellCommand(java.lang.String command)
Executes a shell command.- Parameters:
command
- A String containing the shell command to execute. This String will be parsed with a simple StringTokenizer, to split the command and arguments.- Returns:
- An ExecuteCommand object
- See Also:
ExecuteCommand
-
shellCommand
public ExecuteCommand shellCommand(java.lang.String command, java.lang.Object args)
Executes a shell command with arguments.Example:
myArr = ["-c", "/bin/ls", "/mnt/cd rom"]; cmd = system.shellCommand ("su", myArr); main.logmsg("The result was:\n" + cmd.getOutputBuffer() );
- Parameters:
command
- The shell command to executeargs
- The arguments to the command. E.g. a String array containing the arguments.- Returns:
- An ExecuteCommand object
- See Also:
ExecuteCommand
-
shellCommandCP
public ExecuteCommand shellCommandCP(java.lang.String command, java.lang.String cp)
Executes a shell command with encoding (codepage). On some operating systems, e.g. Windows, an issue could arise because the output from the command is encoded with an old codepage. This method allows you to specify the encoding to use when reading the output from the command.- Parameters:
command
- A String containing the shell command to execute. This String will be parsed with a simple StringTokenizer, to split the command and arguments.cp
- The CodePage (encoding) to use- Returns:
- An ExecuteCommand object
- See Also:
ExecuteCommand
-
shellCommand
public ExecuteCommand shellCommand(java.lang.String command, java.lang.String cp, java.lang.Object args)
Executes a shell command with encoding (codepage) and arguments. On some operating systems, e.g. Windows, an issue could arise because the output from the command is encoded with an old codepage. This method allows you to specify the encoding to use when reading the output from the command.Example:
myArr = ["-c", "/bin/ls", "/mnt/cd rom"]; cmd = system.shellCommand ("su", "cp850", myArr); main.logmsg("The result was:\n" + cmd.getOutputBuffer() );
- Parameters:
command
- The shell command to executecp
- The CodePage to useargs
- The arguments to the command. E.g. a String array containing the arguments.- Returns:
- An ExecuteCommand object
- See Also:
ExecuteCommand
-
getOSName
public java.lang.String getOSName()
Returns the name of the operating system.- Returns:
- The OS name
-
getJavaProperty
public java.lang.String getJavaProperty(java.lang.String prop)
Returns the value for a system property.- Parameters:
prop
- The property name- Returns:
- The property value or null if no such property exists
-
setJavaProperty
public void setJavaProperty(java.lang.String prop, java.lang.String value)
Sets the value of a property name.- Parameters:
prop
- The property namevalue
- The property value
-
entry2LDIF
public java.lang.String entry2LDIF(Entry e)
Converts an Entry object to an LDIF string. If the passed entry is tagged with delta codes then the resulting LDIF will be incremental, reflecting this tagging.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));
- Parameters:
e
- The entry- Returns:
- The LDIF string
- See Also:
lastError
-
getFTP
public FTPBean getFTP()
Returns an instance of the FTP object.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");
- Returns:
- The FTP object
- See Also:
FTPBean
-
dumpEntry
public void dumpEntry(Entry e)
Dumps an entry to the console log. In order to get more verbose information use the toDeltaString() method of anEntry
.- Parameters:
e
- The entry object- See Also:
Entry
-
getXPathAPI
public org.apache.xpath.XPathAPI getXPathAPI()
Returns the Apache XPathAPI- Returns:
- XPathAPI object
-
selectSingleNode
public org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String str)
Selects a single node using an XPath expression from an XML node. For example if we have the following xml file:<?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 acontextNode
parameter.Example:
var entry = input.getConnector().getNextEntry(); var res = system.selectSingleNode(entry, "note/to"); task.logmsg(res); // to:Michael
- Parameters:
contextNode
- The XML document nodestr
- The XPath search string- Returns:
- XML Document node
- See Also:
lastError
-
selectNodeList
public org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node contextNode, java.lang.String str)
Selects nodes using an XPath expression from an XML node. For example if we have the following xml file:<?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 }
- Parameters:
contextNode
- The XML document nodestr
- The XPath search string- Returns:
- A NodeList object
- See Also:
lastError
,selectSingleNode(Node, String)
-
selectNodeIterator
public org.w3c.dom.traversal.NodeIterator selectNodeIterator(org.w3c.dom.Node contextNode, java.lang.String str)
Selects nodes using an XPath expression from an XML node. For example if we have the following xml file:<?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); }
- Parameters:
contextNode
- The XML document nodestr
- The XPath search string- Returns:
- A NodeIterator object
- See Also:
lastError
,selectSingleNode(Node, String)
-
xslTransform
public java.lang.String xslTransform(java.lang.Object xsl, java.lang.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.- Parameters:
xsl
- The XSL Style sheet (String, java.io.File, java.io.Reader )xml
- The XML document (String, java.io.File, java.io.Reader )- Returns:
- The translated document
- See Also:
lastError
-
dumpJavaClass
public boolean dumpJavaClass(java.lang.String className)
Dumps the public methods for a Java class.- Parameters:
className
- The java class name- Returns:
- True if dump succeeded
- See Also:
lastError
-
chdir
public boolean chdir(java.lang.String directory)
Change Java runtime working directory. Sets the "user.dir" property.- Parameters:
directory
- File system directory- Returns:
- True if directory exists, false if directory is not valid
-
getcwd
public java.lang.String getcwd()
Returns the current working directory.- Returns:
- working directory
-
getScriptText
public java.lang.String getScriptText(java.lang.String name)
Returns the text from the Script Library.- Parameters:
name
- The script name as it appears in the configuration.- Returns:
- The script text or null if not found.
-
snmpTrap
public boolean snmpTrap(java.lang.String host, int port, java.lang.String oid, java.lang.String value)
Sends an SNMP trap. This method only accepts a String as the value. If you need to send more complex data use the other snmpTrap() method in this library.- Parameters:
host
- The IP hostport
- The TCP portoid
- The OIDvalue
- The value- Returns:
- True if Trap was sent
- See Also:
lastError
-
snmpTrap
public boolean snmpTrap(java.lang.String agentIP, java.lang.String host, int port, java.lang.String community, java.lang.String enterprise, int genericTrap, int specificTrap, java.lang.String oid, java.lang.Object value)
Sends an SNMP trap. This method allows you to set most of the attributes of the SNMP trap PDU. Ifoid
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); }
- Parameters:
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)- Returns:
- True if Trap was sent, otherwise check the system.lastError object for the exception
- See Also:
lastError
-
httpGet
public Entry httpGet(java.lang.String url)
Gets file from a web server. Calling this method is equivalent to calling httpRequest("GET", null, url, null) and both will return identical results.Example:
var response = system.httpGet("http://www.mysite.com/files"); if (response == null) { task.logmsg("Error getting file: " + system.lastError); }
- Parameters:
url
- Identifies the resource to get from the web server- Returns:
- The response from the server is encapsulated into an Entry object or NULL if an error occurred.
- See Also:
httpRequest(String, String, String, Object)
,lastError
-
httpPost
public Entry httpPost(java.lang.String url, java.lang.Object file)
Posts file to a web server. This method sends to the server request message with content type "application/octet-stream". Sofile
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); }
- Parameters:
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.- Returns:
- The response from the server is encapsulated into an Entry object or NULL if an error occurred.
- See Also:
httpRequest(String, String, String, Object)
,lastError
-
httpRequest
public Entry httpRequest(java.lang.String method, java.lang.String contentType, java.lang.String url, java.lang.Object file)
Sends HTTP Request message to web server. This methods uses HTTPClient Connector to send request message of type specified bymethod
to web server at given addressurl
.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); }
- Parameters:
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- Returns:
- The response from the server is encapsulated into an Entry object or NULL if an error occurred.
- See Also:
httpGet(String)
,httpPost(String, Object)
-
arrayToString
public java.lang.String arrayToString(byte[] array)
Converts a ByteArray to a string using platform's default charset. For example, if you want to set a password(which is sometime a binary value) you could use this in the attribute mapping.Example:
ret.value = system.arrayToString(work.getObject("userpassword"));
- Parameters:
array
- The byte array to be converted- Returns:
- The String object created from byte array
-
deleteFile
public boolean deleteFile(java.lang.String filePath) throws java.lang.Exception
Deletes a file.Example:
var filePath = new java.lang.String("c:\\docs\\myfile.txt"); if (!system.deleteFile(filePath)) main.logmsg("Error file " + file + " not deleted!");
- Parameters:
filePath
- The name of the file to be deleted- Returns:
- True if file was deleted, false if not deleted or if an error occurred
- Throws:
java.lang.Exception
- iffilePath
is not a file- See Also:
lastError
-
renameFile
public boolean renameFile(java.lang.String oldName, java.lang.String newName)
Rename a file.Example:
var oldName = "c:\\docs\\myfile.txt"; var newName = "c:\\docs\\newname.txt"; if (! system.renameFile(oldName, newName) ) { //The rename failed. Handle the problem. }
- Parameters:
oldName
- The old name of the filenewName
- The new name of the file- Returns:
- True if the rename succeeded, false otherwise
-
copyFile
public boolean copyFile(java.lang.String oldFile, java.lang.String newFile)
Copy a file. Example:var oldName = "c:\\docs\\myfile.txt"; var newName = "c:\\docs\\newname.txt"; system.copyFile(oldName, newName);
- Parameters:
oldFile
- The name of the file to copynewFile
- The name of the new file- Returns:
- true if the copying succeeded, false if an exception occurred
- See Also:
lastError
-
newTCB
public TaskCallBlock newTCB()
Create an empty TaskCallBlock.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
- Returns:
- TaskCallBlock object
- See Also:
newEntry()
-
newTCB
public TaskCallBlock newTCB(java.lang.String assemblyLine)
Create a TaskCallBlock with i/o specifications from an existing assemblyline. The TCB will contain all input/output parameters as well as all connectors and their initial parameters and values.- Parameters:
assemblyLine
- name of the assembly line- Returns:
- TaskCallBlock object with i/o specifications from an existing assemblyline
-
getPersistentObject
public java.lang.Object getPersistentObject(java.lang.String key) throws java.lang.Exception
This method retrieves a named object from the default system property store.- Parameters:
key
- The unique key- Returns:
- Object
- Throws:
java.lang.Exception
-
setPersistentObject
public java.lang.Object setPersistentObject(java.lang.String key, java.lang.Object value) throws java.lang.Exception
This method stores a named object in the default system property store.- Parameters:
key
- The unique keyvalue
- The object to store (must be java serializable)- Returns:
- The old object if any
- Throws:
java.lang.Exception
-
deletePersistentObject
public java.lang.Object deletePersistentObject(java.lang.String key) throws java.lang.Exception
This method deletes a named object in the default system property store.- Parameters:
key
- The unique key- Returns:
- The old object if any
- Throws:
java.lang.Exception
-
getRunningALs
public static java.util.Vector<AssemblyLine> getRunningALs()
This method returns a Vector containing all AssemblyLines that were running when the function was called. The example code shows how to print the names of all running AssemblyLines.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()); }
- Returns:
- a java.util.Vector containing the AssemblyLines
-
getRunningALs
public static java.util.Vector<AssemblyLine> getRunningALs(java.lang.String name)
This method returns a Vector containing all AssemblyLines with the given name that were running when the function was called- Parameters:
name
- Find all AssemblyLines with this name. Only the last part of the name (after optional /) is used.- Returns:
- a java.util.Vector containing the AssemblyLines
-
getRunningSequences
public static java.util.Vector<Sequence> getRunningSequences(java.lang.String name)
This method returns a Vector containing all Sequences with the given name that were running when the function was called- Parameters:
name
- Find all Sequences with this name. Only the last part of the name (after optional /) is used.- Returns:
- a java.util.Vector containing the Sequences
-
getRsaEncrypted
public java.lang.String getRsaEncrypted(java.lang.String plainText, java.lang.String ksPath, java.lang.String ksPassword, java.lang.String certificateAlias) throws java.lang.Exception
getRsaEncrypted: Obtain encrypted (and ascii-encoded) value for plain text specified, null strings are not processed and will be returned as null.- Parameters:
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- Returns:
- String representing encrypted format, null is returned if a null is passed in.
- Throws:
java.lang.Exception
- when underlying function failsjava.lang.Exception
-
getRsaDecrypted
public java.lang.String getRsaDecrypted(java.lang.String cipherText, java.lang.String ksPath, java.lang.String ksPassword, java.lang.String certificateAlias, java.lang.String certificatePassword) throws java.lang.Exception
getRsaDecrypted: Obtain plain ascii text for encrypted ciphertext specified. Null strings are not processed and will be returned as received. Empty strings will be encoded/encrypted.- Parameters:
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- Returns:
- String representing the decrypted format of the received string. Null is returned when a null is received.
- Throws:
java.lang.Exception
- when underlying function failsjava.lang.Exception
-
createALPool
public AssemblyLinePool createALPool(java.lang.String assemblyLine, Log log) throws java.lang.Throwable
Creates an AssemblyLine Pool object from the specified AssemblyLine name.- Parameters:
assemblyLine
- The name of the assemblylinelog
- The Log object to use or null to use the system logger- Returns:
- created AssemblyLinePool object
- Throws:
java.lang.Throwable
-
getFunction
public FunctionInterface getFunction(java.lang.String name) throws java.lang.Exception
Load a Function component Interface from the current Config.- Parameters:
name
- The name of the function.- Returns:
- The Function object
- Throws:
java.lang.Exception
-
base64Encode
public static java.lang.String base64Encode(byte[] b)
base64Encode: Obtain Base 64 encoded String from a binary Byte ArrayExample:
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
- Parameters:
b
- byte array containing binary data- Returns:
- String containing the base64 encoded representation of the data.
-
base64Encode
public static java.lang.String base64Encode(java.lang.String string, java.lang.String encoding) throws java.io.UnsupportedEncodingException
Return the base64 encoding of a String.- Parameters:
string
- The String to encode.encoding
- Encoding used to convert the String to bytes. If null, use platform specific encoding.- Returns:
- The base64 encoding of the string.
- Throws:
java.io.UnsupportedEncodingException
- If the string cannot be converted to bytes with the provided encoding.- Since:
- 7.2
-
base64Decode
public static byte[] base64Decode(java.lang.String str)
base64Decode: Obtain Byte Array from a Base 64 encoded String.Example:
var str = "B77d677d"; task.logmsg("Result: " + system.base64Decode(str)); //7,-66,-35,-21,-66,-35
- Parameters:
str
- String containing base64 Data.- Returns:
- Byte array containing the decoded binary data.
-
base64Decode
public static java.lang.String base64Decode(java.lang.String str, java.lang.String encoding) throws java.io.UnsupportedEncodingException
Converts a base64 encoded String back to a regular String.- Parameters:
str
- The base64 encoded Stringencoding
- Character encoding used to convert bytes to characters. If null, platform specific encoding is used.- Returns:
- The decoded String
- Throws:
java.io.UnsupportedEncodingException
- If the bytes cannot be converted to String= with the given encoding.- Since:
- 7.2
-
encodeToHexstring
public static java.lang.String encodeToHexstring(byte[] data)
encodeToHexstring: Obtain HexString from a byte array.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
- Parameters:
data
- byte array containing binary data- Returns:
- String containing the Hexadecimal representation of the data.
-
createCOMInstance
public static IDispatch createCOMInstance(java.lang.String progID)
Creates an IDispatch automation object. This method creates a new COMProxy object and then calls new IDispatch(progID) on it.Example:
var cominst = system.createCOMInstance("Word.Basic");
- Parameters:
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- Returns:
- IDispatch object, null if not running under Windows
-
newPipe
public static MemBufferQ newPipe(java.lang.String instName, java.lang.String pipeName, int watermark) throws java.lang.Exception
This method create a new Memory Buffer Queue if it does not already exist. If the pipe already exists with the specified instaName and pipeName then a handle to the same pipe is returned. Paging is disabled in this case.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);
- Parameters:
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- Returns:
- MemBufferQ
- Throws:
java.lang.Exception
-
newPipe
public static MemBufferQ newPipe(java.lang.String instName, java.lang.String pipeName, int watermark, int pagesize) throws java.lang.Exception
This method create a new Memory Buffer Queue if it does not already exist. If the pipe already exists with the specified instaName and pipeName then a handle to the same pipe is returned. Paging is enabled in this case.- Parameters:
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
-- Returns:
- MemBufferQ
- Throws:
java.lang.Exception
-
getPipe
public static MemBufferQ getPipe(java.lang.String instName, java.lang.String pipeName) throws java.lang.Exception
This method returns a handle to a pipe with the specified instName and pipeName (if it already exists). If the pipe does not exist, then this method throws an Exception.- Parameters:
instName
- name of the instance. Default instance will be used if this param is null.pipeName
- name of the pipe to be returned- Returns:
- MemBufferQ
- Throws:
java.lang.Exception
-
deletePipe
public static void deletePipe(java.lang.String instName, java.lang.String pipeName) throws java.lang.Exception
Deletes the specified pipe from the specified instance. Drops the associated table in System Store with the specified memory queue (if it's a persistent queue). This method throws an exception if the pipe name is invalid or does not exist.- Parameters:
instName
- name of the instance. Default instance will be used if this param is null.pipeName
- name of the pipe to be deleted- Throws:
java.lang.Exception
-
deletePipe
public static void deletePipe(java.lang.String pipeName) throws java.lang.Exception
Deletes specified pipe from default instance Drops the associated table in System Store with the specified memory queue (if it's a persistent queue). This method throws an exception if the pipe name is invalid or does not exist.- Parameters:
pipeName
- name of the pipe to be deleted- Throws:
java.lang.Exception
-
getExternalProperty
@Deprecated public java.lang.Object getExternalProperty(java.lang.String propName) throws java.lang.Exception
Deprecated.usegetTDIProperty(String)
insteadGet external property using delegator object.Note that the
getTDIProperty(String)
method is recommended over this older version.- Parameters:
propName
-- Returns:
- external property
- Throws:
java.lang.Exception
-
setExternalProperty
@Deprecated public void setExternalProperty(java.lang.String propName, java.lang.Object value) throws java.lang.Exception
Deprecated.usesetTDIProperty(String, Object)
insteadSet external property using delegator object.- Parameters:
propName
-value
-- Throws:
java.lang.Exception
-
getExternalProperty
@Deprecated public java.lang.Object getExternalProperty(java.lang.String extObj, java.lang.String propName) throws java.lang.Exception
Deprecated.usegetTDIProperty(String, String)
instead Implementation of the method is changed due to defect 12968Get external property from specific extprop object.Note that the
getTDIProperty(String, String)
method is recommended over this older version.- Parameters:
extObj
-propName
-- Returns:
- external property
- Throws:
java.lang.Exception
-
setExternalProperty
@Deprecated public void setExternalProperty(java.lang.String extObj, java.lang.String propName, java.lang.Object value) throws java.lang.Exception
Deprecated.usesetTDIProperty(String, String, Object)
insteadSet external property in a specific extprop object- Parameters:
extObj
-propName
-value
-- Throws:
java.lang.Exception
-
getExtProp
@Deprecated public ExternalPropertiesConfig getExtProp(java.lang.String name) throws java.lang.Exception
Deprecated.usegetTDIProperties()
insteadReturns a named extprop object.Note that the
getTDIProperty(String)
andgetTDIProperty(String, String)
methods are recommended over this older version.- Parameters:
name
- name of the extprop- Returns:
- ExternalPropertiesConfig object
- Throws:
java.lang.Exception
-
binaryGUIDtoString
public java.lang.String binaryGUIDtoString(byte[] binaryData)
Generates the hexadecimal String representation of an Active Directory GUID based on its 128-bit binary representation. The String representation of a GUID has the form "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}". The digits used are the hexadecimal digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F.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}
- Parameters:
binaryData
- a 16-byte byte array, holding the 128-bit binary representation of the GUID.- Returns:
- The hexadecimal String representation of the binary GUID.
-
removeInvalidXMLChars
public static java.lang.String removeInvalidXMLChars(java.lang.String aString)
Removes invalid XML chars.- Parameters:
aString
- string to clean- Returns:
- cleaned string
-
loadJarFile
public static void loadJarFile(java.lang.String path)
Dynamically add jar file containing class definitions. TDI has a loader that finds all classes in jar files in the jars directory of the installation folder. If you want to dynamically add additional jar files, you can use this method. An alternative to dynamically loading additional jar files, is to set the "com.ibm.di.loader.userjars" property in global.properties.- Parameters:
path
- The full path name of a jar file or a directory containing jar files- See Also:
IDILoader.addFiles(String)
-
getTDIProperties
public TDIProperties getTDIProperties() throws java.lang.Exception
Returns the TDIProperties object for the current configuration- Returns:
- TDIProperties object
- Throws:
java.lang.Exception
-
getTDIProperty
public java.lang.Object getTDIProperty(java.lang.String name) throws java.lang.Exception
Returns the value for a TDI property- Parameters:
name
- The name of the property- Returns:
- TDI property value
- Throws:
java.lang.Exception
-
getTDIProperty
public java.lang.Object getTDIProperty(java.lang.String propstore, java.lang.String name) throws java.lang.Exception
Returns the property value from a specific TDI property store- Parameters:
propstore
- The property store namename
- The name of the property- Returns:
- TDI property value
- Throws:
java.lang.Exception
-
setTDIProperty
public void setTDIProperty(java.lang.String name, java.lang.Object value) throws java.lang.Exception
Sets the property value for a property (store selection based on naming rules and order).- Parameters:
name
- The name of the propertyvalue
- The property value- Throws:
java.lang.Exception
-
setTDIProperty
public void setTDIProperty(java.lang.String propstore, java.lang.String name, java.lang.Object value) throws java.lang.Exception
Sets the property value in a specific TDI property store- Parameters:
propstore
- The property store namename
- The name of the propertyvalue
- The property value- Throws:
java.lang.Exception
-
startsWithIC
public static boolean startsWithIC(java.lang.String first, java.lang.String second)
Returns true if the first String starts with the second String, ignoring case. If at least one if the Strings are null, returns false. This method is case insensitive.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"); }
- Parameters:
first
- The first Stringsecond
- The second String- Returns:
- true if and only if the first String starts with the second String, ignoring case
- Since:
- 6.1.1
-
endsWithIC
public static boolean endsWithIC(java.lang.String first, java.lang.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.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"); }
- Parameters:
first
- The first Stringsecond
- The second String- Returns:
- true if and only if the first String ends with the second String, ignoring case
- Since:
- 6.1.1
-
containsIC
public static boolean containsIC(java.lang.String first, java.lang.String second)
Returns true if the second String is a substring of the first, ignoring case. If at least one if the Strings are null, returns false. Examples:Example:
system.containsIC("abcde", "BCD"); // Returns true system.containsIC("abcde", "bd"); // Returns false
- Parameters:
first
- The first Stringsecond
- The second String- Returns:
- true if and only if the first String contains the second String, ignoring case
- Since:
- 6.1.1
-
getTDIExpression
public static ParameterSubstitution getTDIExpression(java.lang.String pattern) throws java.lang.Exception
Returns a ParameterSubstitution object using the given pattern. For example if we have the following file:" 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... }
- Parameters:
pattern
- The pattern to use for substitution.- Returns:
- A ParameterSubstitution with the given pattern
- Throws:
java.lang.Exception
- See Also:
substitute(String, Map)
-
substitute
public static java.lang.String substitute(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params) throws java.lang.Exception
Performs a one-time parsing and substitution of pattern with the objects available in params. This method uses a Map object where you provide the available objects for pattern expansion.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);
- Parameters:
pattern
- The pattern string to expandparams
- The available objects (e.g. conn, work, task etc)- Returns:
- The expanded string
- Throws:
java.lang.Exception
-
substitute
public static java.lang.String substitute(java.lang.String pattern, java.lang.String[] names, java.lang.Object[] objects) throws java.lang.Exception
Performs a one-time parsing and substitution of pattern with named objects. You should at least provide "mc=MetamergeConfig" or "config=BaseConfiguration" objects, 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:
result = system.substitute("{work.cn} {property.myprop}", ["mc", "work"], [main.getMetamergeConfig(), work]);
- Parameters:
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)- Returns:
- The expanded string
- Throws:
java.lang.Exception
-
getStackTrace
public java.lang.String getStackTrace(java.lang.Throwable t)
Returns the backtrace for a throwable.- Parameters:
t
- - The Throwable- Returns:
- A string representation of the backtrace.
- Since:
- 7.2
-
readBytes
public byte[] readBytes(java.lang.String fileName) throws java.io.IOException
Returns all bytes in the file as a byte array.- Parameters:
fileName
- Name of the file to read- Returns:
- The bytes contained in the file as a byte[]
- Throws:
java.io.IOException
- If the file is not found or not readable- Since:
- SDI 7.2 FP0004
-
-