com.wm.app.tn.route
Class RoutingActions

java.lang.Object
  extended by com.wm.app.tn.route.RoutingActions

public class RoutingActions
extends java.lang.Object

This class includes static methods that mimic the different actions available to processing rules in Trading Networks, so you can call them from Java services.


Constructor Summary
RoutingActions()
           
 
Method Summary
static void addError(BizDocEnvelope doc, ActivityLogEntry a)
          Adds an error to the supplied document.
static ActivityLogEntry alert(BizDocEnvelope doc, java.lang.String p_id, java.lang.String c_type, java.lang.String sub, java.lang.String msg)
          Sends email.
static void fillPipeline(com.wm.data.IData pipe, RoutingRule rule, BizDocEnvelope doc)
          For internal use only
static java.util.Stack getStack()
          For internal use only
static com.wm.data.IData invoke(BizDocEnvelope doc, java.lang.String svc_nm, com.wm.data.IData svc_in, java.lang.String type)
          Invoke a B2B service.
static com.wm.data.IData invokeWrapper(BizDocEnvelope doc, java.lang.String svc_nm, com.wm.data.IData svc_in, java.lang.String invokeType, boolean throwif)
          For internal use only
static BizDocEnvelope mapMonitoredAttributes(java.lang.String docID)
           
static boolean persist(BizDocEnvelope doc, java.lang.String uniq, boolean fail)
          Persists a document to the database.
static boolean persist(BizDocEnvelope doc, java.lang.String uniq, java.lang.String dupCheckSvc, boolean fail)
          Persists a document to the database.
static void popStack()
          For internal use only
static boolean pushStack(RoutingRule rule, BizDocEnvelope doc)
          For internal use only
static java.lang.String replaceVariables(java.lang.String text, com.wm.data.IData pipeline)
          Do variable substitution in the specified text message.
static byte[] report(java.lang.String r_tmpl, com.wm.data.IData r_in, boolean invokes)
          For internal use only
static java.lang.String send(BizDocEnvelope doc, java.lang.String proto, com.wm.data.IData pipe)
          Send a document.
static void setAborted(BizDocEnvelope doc, boolean save)
          Deprecated. use the version of setAborted that allows you to explicitly specify the new system and user status (127)
static void setAborted(BizDocEnvelope doc, java.lang.String sys, java.lang.String usr, boolean save)
          Puts a document into an "aborted" state, and (possibly) changes its status.
static boolean setResponse(java.lang.String type, byte[] data)
          Set the response to the currently running service.
static void setStack(java.util.Stack s)
          For internal use only
static void sign(BizDocEnvelope doc, com.wm.data.IData pipe)
          Sign a document using its assigned signing service.
static boolean str_eq(java.lang.String s1, java.lang.String s2)
          For internal use only
static void validate(BizDocEnvelope doc, com.wm.data.IData pipe)
          Validate the structure of a document using its assigned validation service.
static void verify(BizDocEnvelope doc, com.wm.data.IData pipe)
          Verify the signature of a document using its assigned verification service.
static void writeEventDetails(com.webmethods.common.mapi.Event evt)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoutingActions

public RoutingActions()
Method Detail

str_eq

public static boolean str_eq(java.lang.String s1,
                             java.lang.String s2)
For internal use only


pushStack

public static boolean pushStack(RoutingRule rule,
                                BizDocEnvelope doc)
For internal use only


popStack

public static void popStack()
For internal use only


setStack

public static void setStack(java.util.Stack s)
For internal use only


getStack

public static java.util.Stack getStack()
For internal use only


fillPipeline

public static void fillPipeline(com.wm.data.IData pipe,
                                RoutingRule rule,
                                BizDocEnvelope doc)
For internal use only


report

public static byte[] report(java.lang.String r_tmpl,
                            com.wm.data.IData r_in,
                            boolean invokes)
For internal use only


replaceVariables

public static java.lang.String replaceVariables(java.lang.String text,
                                                com.wm.data.IData pipeline)
Do variable substitution in the specified text message. If pipeline variables are present in the text, specified by the format '%variable%', this will be replaced by the runtime value of variable from the pipeline. If the variable is not found in pipeline, the text '%variable%' will be retained.

Parameters:
text - String that contains the text message including pipeline variables
pipeline - IData pipeline
Returns:
the text in which the pipeline variables are substituted with the corresponding runtime values.

addError

public static void addError(BizDocEnvelope doc,
                            ActivityLogEntry a)
Adds an error to the supplied document. If the document has already been persisted, this will write it to the system log.

Parameters:
doc - the document
a - the activity log entry to associate

setAborted

public static void setAborted(BizDocEnvelope doc,
                              boolean save)
Deprecated. use the version of setAborted that allows you to explicitly specify the new system and user status (127)

Puts a document into an "aborted" state. Any errors that happen in this method are logged to the server's log file at log level 3.

Parameters:
doc - the document
save - should the document be saved?

setAborted

public static void setAborted(BizDocEnvelope doc,
                              java.lang.String sys,
                              java.lang.String usr,
                              boolean save)
Puts a document into an "aborted" state, and (possibly) changes its status. Any errors that happen in this method are logged to the server's log file at log level 3.

Parameters:
doc - the document
sys - new system status for the document (null if no change)
usr - new user status for the document (null if no change)
save - should the document be saved?

verify

public static void verify(BizDocEnvelope doc,
                          com.wm.data.IData pipe)
                   throws RoutingAbortedException
Verify the signature of a document using its assigned verification service. If any verification errors occur, they are attached to the document as ActivityLogEntries.

Parameters:
doc - the document in question
pipe - pipeline to pass to verification service (may be null)
Throws:
RoutingAbortedException

sign

public static void sign(BizDocEnvelope doc,
                        com.wm.data.IData pipe)
                 throws RoutingAbortedException
Sign a document using its assigned signing service. If any signing errors occur, they are attached to the document as ActivityLogEntries.

Parameters:
doc - the document in question
pipe - pipeline to pass to signing service (may be null)
Throws:
RoutingAbortedException

validate

public static void validate(BizDocEnvelope doc,
                            com.wm.data.IData pipe)
                     throws RoutingAbortedException
Validate the structure of a document using its assigned validation service. If any validation errors occur, they are attached to the document as ActivityLogEntries.

Parameters:
doc - the document in question
pipe - pipeline to pass to validation service (may be null)
Throws:
RoutingAbortedException

persist

public static boolean persist(BizDocEnvelope doc,
                              java.lang.String uniq,
                              boolean fail)
                       throws DatastoreException
Persists a document to the database. If the document is already in the database, or there are other errors in the operation, they are attached to the document as ActivityLogEntries. To perform custom duplicate checking, use the 4-arg form of this method.

Parameters:
doc - the document in question
uniq - uniqueness criteria for this document; should be one of the UNQ_* constants (see RoutingConstants). If UNQ_CUSTOM, the method will use the duplicate checking service in the document's doctype.
fail - should the insert be aborted if the additional uniqueness criteria fail?
Returns:
was the insert successful?
Throws:
DatastoreException

persist

public static boolean persist(BizDocEnvelope doc,
                              java.lang.String uniq,
                              java.lang.String dupCheckSvc,
                              boolean fail)
                       throws DatastoreException
Persists a document to the database. If the document is already in the database, or there are other errors in the operation, they are attached to the document as ActivityLogEntries.

Parameters:
doc - the document in question
uniq - uniqueness criteria for this document; should be one of the UNQ_* constants (see RoutingConstants). If RoutingConstants.UNQ_CUSTOM, supply the name of the duplicate checking service in dupCheckSvc. doctype.
dupCheckSvc - name of the duplicate checking service to invoke to check for document uniqueness. If uniq is not RoutingConstants.UNQ_CUSTOM, this argument is ignored.
fail - should the insert be aborted if the additional uniqueness criteria fail?
Returns:
was the insert successful?
Throws:
DatastoreException

alert

public static ActivityLogEntry alert(BizDocEnvelope doc,
                                     java.lang.String p_id,
                                     java.lang.String c_type,
                                     java.lang.String sub,
                                     java.lang.String msg)
Sends email. This handles the grottier aspects of looking up email addresses and wraps the server's sendmail API.

Parameters:
doc - the document this alert pertains to (may be null)
p_id - who to send email (must be RoutingConstants.EMAIL_B2B or a valid partner ID)
c_type - if "p_id" is a partner ID, this specifies which contact of that partner to use (e.g. "Administrative")
sub - the subject of the message
msg - the message itself
Returns:
an error message about the alert (null if it sent OK)

invoke

public static com.wm.data.IData invoke(BizDocEnvelope doc,
                                       java.lang.String svc_nm,
                                       com.wm.data.IData svc_in,
                                       java.lang.String type)
                                throws RoutingAbortedException
Invoke a B2B service. The main purpose of this method is to wrap a normal B2B service invoke with appropriate logging calls. It's also useful for invoking services asynchronously.

Parameters:
doc - the document this invoke pertains to (may be null)
svc_nm - the name of the service to invoke (e.g. "wm.server:ping")
svc_in - inputs for the service
type - service invoke type (see RoutingConstants.TYPE_*)
Returns:
service outputs (or null for an async invoke)
Throws:
RoutingAbortedException

invokeWrapper

public static com.wm.data.IData invokeWrapper(BizDocEnvelope doc,
                                              java.lang.String svc_nm,
                                              com.wm.data.IData svc_in,
                                              java.lang.String invokeType,
                                              boolean throwif)
                                       throws RoutingAbortedException
For internal use only

Throws:
RoutingAbortedException

setResponse

public static boolean setResponse(java.lang.String type,
                                  byte[] data)
Set the response to the currently running service. Normal behavior is to respond with this data regardless of the client. If the client is using WM RPC, the response is simply dropped in the pipeline as "$responseType" and "$responseBytes".

Parameters:
type - MIME type of the response data (e.g. "text/plain")
data - byte data to use as response
Returns:
was the response data set?

send

public static java.lang.String send(BizDocEnvelope doc,
                                    java.lang.String proto,
                                    com.wm.data.IData pipe)
Send a document. This handles looking up the destination for the given protocol, and so forth.

Parameters:
doc - the document to send
proto - the protocol to send it on (see RoutingConstants)
Returns:
the ID of the resulting delivery job (null if there is none)

mapMonitoredAttributes

public static BizDocEnvelope mapMonitoredAttributes(java.lang.String docID)

writeEventDetails

public static void writeEventDetails(com.webmethods.common.mapi.Event evt)