Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved

Chapter 4 JavaScript Interface : Infrastructure Classes

Infrastructure Classes
These classes provide functions such as setting up the action request, creating a socket, performing an XSL transform, etc.
The classes available in this category are listed in the table below (click on the class name to link to the method descriptions for that class).
 
Class1

1
All classes are prefixed with “com.tibco.bpm.ipc”.
Each of the infrastructure classes is described in the following subsections.

Action
The com.tibco.bpm.ipc.Action class defines an object model interface to support the TIBCO Action Processor protocol. The Action Processor supports XML communication using the following example protocol:
The command consists of an Action that can support multiple requests. This class adds structure around an object model that enables developers to build these requests. The following is an example of how to use this class to construct a simple MakeWorkItemList request. The purpose of this request is to obtain the list state object to obtain the available count that the WICriteria filter expression defines:

 
var action = new com.tibco.bpm.ipc.Action();
var request = action.addRequest("MakeWorkItemList", "212");
request.addParameter(new com.tibco.bpm.ipc.XmlElement("WorkQTag", "i2tagtest|swadmin|R"));
request.addParameter(new com.tibco.bpm.ipc.vWICriteria('SW_STEPDESC = "First Step"'));
request.addParameter(new com.tibco.bpm.ipc.vWIContent());
request.addParameter(new com.tibco.bpm.ipc.XmlElement("StartIndex", 0));
request.addParameter(new com.tibco.bpm.ipc.XmlElement("ReturnCout", 0));
request.addParameter(new com.tibco.bpm.ipc.XmlElement("Keep", false));

 
Calling action.toXml() on the above Action object returns the following valid XML string:
The com.tibco.bpm.ipc.Action class contains the following public methods.
 
requests - (optional) An array of Request objects (com.tibco.bpm.ipc.RequestXml).
An instance of the com.tibco.bpm.ipc.Action class.
Adds a new Request to the Action command.
strCommand - (String) The request command.
strRequestId - (String) A unique ID for the request. This is the ID of the XML cache that will hold the XML document returned by the Action Processor.
Request object (com.tibco.bpm.ipc.RequestXml).
strRequestId - (String) Unique ID of the request.
objParameter - (com.tibco.bpm.ipc.XmlElement) XML element object to add to the request.
Outputs a valid XML string for the com.tibco.bpm.ipc.Action command.
AuthenticateRequests
The com.tibco.bpm.ipc.AuthenticateRequests class provides methods for creating server requests to log in and log out. The following examples show the execution of login and logout requests.
Login
var socket = this.getApp().newSocket('Login');
var nodeId = new com.tibco.bpm.ipc.vNodeId(name, computername, ipaddress, tcpport, director);
socket.setAsync(false);
var action = new com.tibco.bpm.ipc.Action([
   com.tibco.bpm.ipc.AuthenticateRequests.login(
   'Login', new com.tibco.bpm.ipc.NodeCtx('userId', 'password',
   nodeId))]);
socket.addParameter('action', action.toXml());
socket.execute();
Logout
var socket = this.getApp().newSocket('Logout');
socket.setAsync(false);
var action = new com.tibco.bpm.ipc.Action([   com.tibco.bpm.ipc.AuthenticateRequests.logout('Logout', true)]);
socket.addParameter('action', action.toXml());
socket.execute();
The com.tibco.bpm.ipc.AuthenticateRequests class contains the following public methods.
 
An instance of the com.tibco.bpm.ipc.AuthenticateRequests class.
id - (String) Unique ID of the request. This is the ID of the XML cache that will hold the XML document returned by the Action Processor.
nodeCtx - (com.tibco.bpm.ipc.NodeCtx) Node connection object.
Note - As there is not a data class for NodeCtx that can be created and passed into the login method, you must create one as shown in the example on page 146, for example:
The nodeId parameter provides connection information — this can be created using the vNodeId data class — see page 211.
id - (String) Unique ID of the request. This is the ID of the XML cache that will hold the XML document returned by the Action Processor.
releaseAllResources - (boolean) If true, the SAL session is closed by the resulting request.
Socket
The com.tibco.bpm.ipc.Socket class provides socket access for components.
Note that the constructor for this class is private. Use the following factory method to create an instance:
com.tibco.bpm.ipc.Application.newSocket(id)
where:
id is the unique ID assigned to the request. This is the ID of the XML cache that will hold the XML document returned by the Action Processor. The newSocket method dispatches the socketResult event when the result is returned.
For a code example showing the creation of a socket, execution of the request, and error handling, see Example Request.
The com.tibco.bpm.ipc.Socket class contains the following public methods.
 
strName - (String) The parameter name.
strValue - (String) The parameter value.
strRequestId - (String) Unique ID for the request (assigned when the socket was instanced).
A string containing an error message describing the error that occurred when isSuccess returns false, indicating a failure during socket processing.
An integer that is the number of vExceptionDetail nodes returned by iProcess Server Objects in the response message.
A jsx3.xml.Entity object, which is the sso:Exception element returned in the response message.
bAsync - (boolean) true for asynchronous communication, false for synchronous (default = true).
strUrl - (String) The base URL to access the XML data.
strPrefix - (String) Action-specific error message that will prefix any error messages generated by the action.
strType - (String) Type of request, either 'GET' or 'POST' (default = 'POST').
bShow - (boolean) If true, any errors generated by an action will be displayed to the user. This can be set to false if the calling class needs to override the message show to the user (default = true).
UtilityRequests
The com.tibco.bpm.ipc.UtilityRequests class provides general-utility Action Processor requests.
This class contains the following public methods.
 
An instance of the com.tibco.bpm.ipc.UtilityRequests class.
A Server Request object (com.tibco.bpm.ipc.ServerRequest) for issuing a ping request.
XmlElement
The com.tibco.bpm.ipc.XmlElement class provides support for creating XML elements.
This class contains the following public methods.
 
tagName - (String) The name that defines the XML element tag.
objText - (boolean, object, number, string) This is an optional argument. When passed, the constructor attempts to convert the argument to a valid string, which is the text that the XML element encloses.
An instance of the com.tibco.bpm.ipc.XmlElement class.
strName - (String) The name of the attribute.
strValue - (String) The value of the attribute.
objChild - (com.tibco.bpm.ipc.XmlElement) The child object to add to the XML element.
XslTransform
The com.tibco.bpm.ipc.XslTransform class provides support for performing XSL transforms on XML documents.
Note that the constructor for this class is private. Use the following factory method to create an instance:
com.tibco.bpm.ipc.Application.newXslTransform (xmlDoc, xslDoc)
where:
xmlDoc is the path to the XML file, XML string, cacheId or jsx3.xml.Document object for the XML document.
xslDoc is the path to the XSL file, XSL string, cacheId or jsx3.xml.Document object for the XSL document.
This class contains the following public methods.
 
strName - (String) The name of the parameter.
strValue - (String) The value of the parameter.
strName - (String) The name of the parameter to remove from the XSL transform.
strCacheId - (String) Optional. If provided, a jsx3.xml.Document containing the transform results is stored in cache under the given strCacheId.
 

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved