com.wm.app.tn.delivery
Class DeliveryUtils

java.lang.Object
  extended by com.wm.app.tn.delivery.DeliveryUtils

public class DeliveryUtils
extends java.lang.Object

Provides utility methods for guaranteed document delivery. Used by both server-side guaranteed delivery and WmTN transport services.


Constructor Summary
DeliveryUtils()
           
 
Method Summary
static void addToResponse(com.wm.data.IData pipeline, java.lang.Object data)
          Adds the response data from WebService to bizdoc, as a new content part.
static DeliveryJob createQueuedJob(BizDocEnvelope doc, java.lang.String qname)
          For internal use only.
static com.wm.data.IData createServiceData(BizDocEnvelope env, boolean primary, java.lang.String protocol, java.lang.String username, java.lang.String password)
          Creates service data needed for wm.tn.transport services.
static com.wm.data.IData createServiceData(BizDocEnvelope env, boolean primary, java.lang.String protocol, java.lang.String service, java.lang.String username, java.lang.String password)
          Creates service data needed for wm.tn.transport services.
static com.wm.data.IData createTNDoc(java.lang.Object data)
          Creates a TN document and invoke wm.tn.receive using the object data provided
static boolean getCertificateInfo(com.wm.data.IData in, java.lang.String partnerId)
          Deprecated. For Internal Use Only!
static Destination getDestination(java.lang.String partnerId, java.lang.String protocol, boolean primary)
          Retrieves the Destination info for the partner based upon the protocol.
static java.lang.Object getIDataValue(com.wm.data.IData pipeline, java.lang.String node)
          Get the value corresponding to an IData key
static long getMinTtw()
          Searches the partner profiles to find the lowest time-to-wait amongst all the profiles who have a retry limit greater than 0.
static com.wm.data.IData getPartnerContext(BizDocEnvelope bd, java.lang.String protocol)
          Attempts to get a com.wm.b2b.client.Context to a partner server if possible.
static com.wm.data.IData getProfileLimits(BizDocEnvelope env)
          Retrieves the default values from the Partner Profile for delivery retry limit and time to wait for the receiver.
static java.lang.Object getWSErrors(com.wm.data.IData svcOut)
          Check for fault messages in the response IData from WSC If there is any fault message, returns SOAP-FAULT element.
static java.lang.String getWSErrorString(com.wm.data.IData svcOut)
          Check for fault messages in the response IData from WSC If there is any fault message, convert SOAP-FAULT to an XML message.
static void init()
          Performs necessary initialization needed by other methods (mainly, getting the profile store).
static com.wm.data.IData invokeService(DeliveryService service, com.wm.data.IData svcInput)
          Invoke a B2B delivery service.
static void notifyJobs(BizDocEnvelope doc)
          For internal use only.
static void notifyTaskFailure(GuaranteedJob job)
          For internal use only
static void setIDataValue(com.wm.data.IData pipeline, java.lang.String node, java.lang.Object value)
          TODO complete doc
static void setKeyAndChain(com.wm.data.IData in)
          Deprecated. For Internal Use Only! Use setSslKeyAndChain instead.
static void setSslKeyAndChain(java.lang.String serverID)
          Sets the private key and certificate chain for ssl connection establishment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeliveryUtils

public DeliveryUtils()
Method Detail

init

public static void init()
                 throws DeliveryException
Performs necessary initialization needed by other methods (mainly, getting the profile store).

Throws:
DeliveryException

createServiceData

public static com.wm.data.IData createServiceData(BizDocEnvelope env,
                                                  boolean primary,
                                                  java.lang.String protocol,
                                                  java.lang.String username,
                                                  java.lang.String password)
                                           throws DeliveryException
Creates service data needed for wm.tn.transport services. If protocol is https or ftps, then the ssl certificate info is set by invoking wm.tn.security:setSSLKeyAndChain.

Parameters:
env - BizDocEnvelope data needed in order to get the sender info
primary - use the primary address?
protocol - transport protocol (eg, Constants.DEST_PROTOCOL_HTTP, Constants.DEST_PROTOCOL_HTTPS, Constants.DEST_PROTOCOL_SMTP)
username - optional username to override the partner profile username
password - optional password to override the partner profile password
Throws:
DeliveryException

createServiceData

public static com.wm.data.IData createServiceData(BizDocEnvelope env,
                                                  boolean primary,
                                                  java.lang.String protocol,
                                                  java.lang.String service,
                                                  java.lang.String username,
                                                  java.lang.String password)
                                           throws DeliveryException
Creates service data needed for wm.tn.transport services. If protocol is https or ftps, then the ssl certificate info is set by invoking wm.tn.security:setSSLKeyAndChain.

Parameters:
env - BizDocEnvelope data needed in order to get the sender info
primary - use the primary address?
protocol - transport protocol (eg, Constants.DEST_PROTOCOL_HTTP, Constants.DEST_PROTOCOL_HTTPS, Constants.DEST_PROTOCOL_SMTP)
service - delivery service name. This can be null, if the protocol is not custom delivery service.
username - optional username to override the partner profile username
password - optional password to override the partner profile password
Throws:
DeliveryException

getDestination

public static Destination getDestination(java.lang.String partnerId,
                                         java.lang.String protocol,
                                         boolean primary)
                                  throws DeliveryException
Retrieves the Destination info for the partner based upon the protocol. A null value may be returned if the protocol does not match any of the the protocols of the parter profile.

Parameters:
partnerId - Internal ID of partner to retrieve destination fields
protocol - protocol to search for (eg, http)
primary - is it the primary protocol?
Returns:
the Destination for the partner with the associated protocol
Throws:
DeliveryException

getPartnerContext

public static com.wm.data.IData getPartnerContext(BizDocEnvelope bd,
                                                  java.lang.String protocol)
                                           throws DeliveryException
Attempts to get a com.wm.b2b.client.Context to a partner server if possible. (Partner must be registered as a TNServer or TNPartner). If using https then the certificate info will be retrieved and set. Also retrieves the B2B interface and service to invoke by parsing info from the location field of the destination.

Parameters:
bd - BizDocEnvelope data needed in order to get the sender info
protocol - protocol to use for the connection (should use the RoutingConstants)
Returns:
an IData containing key/values of "context"/Context (a Context to the partner (possibly null)), "interface"/String (possibly null) and "service"/String" (possibly null)
Throws:
DeliveryException

getMinTtw

public static long getMinTtw()
Searches the partner profiles to find the lowest time-to-wait amongst all the profiles who have a retry limit greater than 0. If there are no partner profiles then -1 is returned.

Returns:
the smallest time-to-wait

getProfileLimits

public static com.wm.data.IData getProfileLimits(BizDocEnvelope env)
                                          throws DeliveryException
Retrieves the default values from the Partner Profile for delivery retry limit and time to wait for the receiver.

Parameters:
env - BizDocEnvelope data needed in order to get the sender info
Returns:
IData with keys of retryLimit, ttw, and retryFactor
Throws:
DeliveryException

invokeService

public static com.wm.data.IData invokeService(DeliveryService service,
                                              com.wm.data.IData svcInput)
                                       throws java.lang.Exception
Invoke a B2B delivery service.

Parameters:
service - delivery service to invoke
svcInput - delivery service inputs including document to deliver
Returns:
output from the delivery service
Throws:
java.lang.Exception

setSslKeyAndChain

public static void setSslKeyAndChain(java.lang.String serverID)
                              throws DeliveryException
Sets the private key and certificate chain for ssl connection establishment. It will set TN alternative or default ssl cert info (in the order for overriding) for the ssl client and server pair by calling wm.tn.security:setSSLKeyAndChain, which eventually calls pub.security:setKeyAndChainFromBytes. No action taken if neither one is defined. Will use underlying IS server's ssl certs. The SSL connection is always established between the current host (my enterprise) and the server of the partner specified in serverID.

Parameters:
serverID - The internal ID of the partner whose SSL server TN will connect to.
Throws:
DeliveryException

notifyJobs

public static void notifyJobs(BizDocEnvelope doc)
For internal use only.


createQueuedJob

public static DeliveryJob createQueuedJob(BizDocEnvelope doc,
                                          java.lang.String qname)
                                   throws java.lang.Exception
For internal use only.

Throws:
java.lang.Exception

notifyTaskFailure

public static void notifyTaskFailure(GuaranteedJob job)
For internal use only


createTNDoc

public static com.wm.data.IData createTNDoc(java.lang.Object data)
                                     throws java.lang.Exception
Creates a TN document and invoke wm.tn.receive using the object data provided

Parameters:
output - Object which contains the data for invoking wm.tn.receive
convertResponseToXML - whether to convert the data (specified in output param) to XML node. If not, the data will be passed to wm.tn.receive as FFData.
Throws:
java.lang.Exception

addToResponse

public static void addToResponse(com.wm.data.IData pipeline,
                                 java.lang.Object data)
Adds the response data from WebService to bizdoc, as a new content part. The input IData should contain the bizdoc and data should be xml format. Changes made to bizdoc will be persisted.

Parameters:
pipeline - IData containing bizdoc
data - data to be added to bizdoc. This objects should contain the data in xml format.

setIDataValue

public static void setIDataValue(com.wm.data.IData pipeline,
                                 java.lang.String node,
                                 java.lang.Object value)
TODO complete doc

Parameters:
pipeline - IData in which the key-value needs to be put
node - key in the format /root/child1/child2
value - Value to be set in the pipeline for the key

getIDataValue

public static java.lang.Object getIDataValue(com.wm.data.IData pipeline,
                                             java.lang.String node)
Get the value corresponding to an IData key

Parameters:
pipeline - IData in which the key-value needs to be put
node - key in the format /root/child1/child2
Returns:
value

getWSErrorString

public static java.lang.String getWSErrorString(com.wm.data.IData svcOut)
                                         throws java.lang.Exception
Check for fault messages in the response IData from WSC If there is any fault message, convert SOAP-FAULT to an XML message.

Parameters:
svcOut -
Returns:
fault message as an XML String. Returns null if no fault message is present.
Throws:
java.lang.Exception

getWSErrors

public static java.lang.Object getWSErrors(com.wm.data.IData svcOut)
                                    throws java.lang.Exception
Check for fault messages in the response IData from WSC If there is any fault message, returns SOAP-FAULT element.

Parameters:
svcOut -
Returns:
fault message as an XML String. Returns null if no fault message is present.
Throws:
java.lang.Exception

setKeyAndChain

public static void setKeyAndChain(com.wm.data.IData in)
                           throws DeliveryException
Deprecated. For Internal Use Only! Use setSslKeyAndChain instead.

Throws:
DeliveryException

getCertificateInfo

public static boolean getCertificateInfo(com.wm.data.IData in,
                                         java.lang.String partnerId)
                                  throws DeliveryException
Deprecated. For Internal Use Only!

Throws:
DeliveryException