com.wm.app.tn.doc
Class BizDocEnvelope

java.lang.Object
  extended by com.wm.app.tn.util.TNFixedData
      extended by com.wm.app.tn.doc.BizDocEnvelope
All Implemented Interfaces:
com.wm.data.IData, java.lang.Cloneable

public final class BizDocEnvelope
extends TNFixedData

Represents business documents in the trading network system. A few notes on the fields of the documents:

In general, there are setters and getters for all the fields. None of the setters will modify the contents of the database unless explicitly stated otherwise: this means it's a bad idea to update documents after they've been saved (except maybe to add some attributes or content parts).

See Also:
BizDocContentPart

Nested Class Summary
 
Nested classes/interfaces inherited from class com.wm.app.tn.util.TNFixedData
TNFixedData.TreeCursor
 
Method Summary
 BizDocContentPart addContentPart(java.lang.String partName, java.lang.String mimeType, byte[] bytes, int partIndex)
          Add a content part to this document
 BizDocContentPart addContentPart(java.lang.String partName, java.lang.String mimeType, int partIndex, int partLength, java.lang.String storageType, java.lang.Object storageRef)
          Add a content part to this document
 void addError(ActivityLogEntry a)
          Add an error to this document.
 BizDocContentPart addLargeContentPart(java.lang.String partName, java.lang.String mimeType, int partIndex, java.io.InputStream contentStream, int contentLength)
          Adds a large content part to this document.
 void addRelationship(java.lang.String from, java.lang.String to, java.lang.String rel)
          Adds a relationship from this document to another
static com.wm.data.IData create()
          For internal use only
static BizDocEnvelope createReply(BizDocEnvelope doc)
          Create a reply of the same type as the supplied document.
static BizDocEnvelope createReply(BizDocEnvelope doc, BizDocType replyType)
          Create a reply of the supplied type.
 java.util.Enumeration getAttributeNames()
          Get the names of all the attributes this document has.
 com.wm.data.IData getAttributes()
          Get all attribute values of the document.
 java.lang.String getComments()
           
 byte[] getContent()
           
 byte[] getContentBytes()
          The envelope maintains different parts of a document.
 BizDocContentPart getContentPart(java.lang.String partName)
           
 BizDocContentPart[] getContentParts()
           
 java.lang.String getConversationId()
           
 java.sql.Timestamp[] getDateListValue(java.lang.String id)
          Accessor for DatetimeList-valued attributes.
 java.sql.Timestamp getDateValue(java.lang.String id)
          Accessor for date-valued attributes.
 java.lang.Object getDeliveryContent()
          Get delivery content of this envelope
 BizDocType getDocType()
           
 java.lang.String getDocumentId()
           
 BizDocErrorSet getErrorSet()
           
 java.lang.String getGroupId()
           
 java.lang.String getInternalId()
           
 boolean getInternalPersistOption()
          For Internal use only
 java.sql.Timestamp getLastModifiedTime()
           
 int getMaxPartIndex()
           
 java.lang.String getMonitoringAction()
           
 java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> getMonitoringDataItems()
           
 java.lang.Double[] getNumberListValue(java.lang.String id)
          Accessor for NumberList-valued attributes.
 double getNumberValue(java.lang.String id)
          Accessor for number-valued attributes.
 java.lang.String getOriginalReceiverId()
           
 java.lang.String getOriginalSenderId()
           
 java.lang.String getPersistOption()
          For Internal use only
 java.lang.String getReceiverId()
           
 java.lang.String getReceiveSvc()
          Support for resubmit: return the receive service name.
 BizDocRelationship[] getRelationships()
          Get relationships on this document (can be null if there are none)
 int getRepeatNum()
           
 java.lang.String getRoutingType()
           
 java.lang.String getSenderId()
           
 byte[] getSignature()
          Deprecated. digital signatures are now manipulated with a verification service
 byte[] getSignedBody()
          Deprecated. digital signatures are now manipulated with a verification service
 java.lang.String[] getStringListValue(java.lang.String id)
          Accessor for StringList-valued attributes.
 java.lang.String getStringValue(java.lang.String id)
          Accessor for string-valued attributes.
 java.lang.String getSystemStatus()
           
 java.sql.Timestamp getTimestamp()
           
 java.lang.String getUserStatus()
           
 boolean isLargeDocument()
           
 boolean isMonitored()
           
 boolean isPersisted()
           
static void main(java.lang.String[] args)
           
static BizDocEnvelope newEnvelope(BizDocType type)
          Create a new envelope of the supplied type
 int replaceContentPart(java.lang.String partName, BizDocContentPart revisedPart)
          Replace a content part on this document
 void replaceInternalId(java.lang.String newId)
          For Internal use only
 void setComments(java.lang.String comment)
          Set the comments
 void setContent(byte[] content)
           
 void setContentBytes(byte[] cont)
          Set the content bytes (should only be called once).
 void setContentParts(BizDocContentPart[] parts)
          Set content parts of this document
 void setConversationId(java.lang.String id)
          Set the conversation ID
 void setDateListValue(java.lang.String name, java.sql.Timestamp[] value)
          Set a DatetimeList-valued attribute
 void setDateValue(java.lang.String name, java.sql.Timestamp value)
          Set a date-valued attribute
 void setDocType(BizDocType type)
          Set the document type (should only be called once)
 void setDocumentId(java.lang.String id)
          Set the document ID
 void setErrorSet(BizDocErrorSet set)
           
 void setGroupId(java.lang.String id)
          Set the group ID
 void setInternalId(java.lang.String id)
          Set the document ID (should only be called once)
 void setInternalPersistOption(boolean flag)
          For Internal use only
 void setLargeDocument(boolean largeDocument)
          For internal use only
 void setLastModifiedTime(java.sql.Timestamp time)
          Set the last mod time
 void setMonitoring(boolean monitoring)
          Set the Monitoring Enabled field
 void setMonitoringAction(java.lang.String action)
          Set the MonitoringAction
 void setMonitoringDataItems(java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> monitoredDataItems)
          Set the MonitoringDataItems
 void setNumberListValue(java.lang.String name, java.lang.Double[] value)
          Set a NumberList-valued attribute
 void setNumberValue(java.lang.String name, double value)
          Set a number-valued attribute
 void setOriginalReceiverId(java.lang.String id)
          Set the original receiver id
 void setOriginalSenderId(java.lang.String id)
          Set the original sender id
 void setPersisted(boolean persx)
          For internal use only
 void setPersistOption(java.lang.String po)
          For Internal use only
 void setReceiverId(java.lang.String id)
          Set the receiver ID (must be a valid partner ID)
 void setReceiveSvc(java.lang.String svc)
          Support for resubmit: set the original receive service of this document.
 void setRelationships(BizDocRelationship[] rel)
          Set relationships on this document (can be null)
 void setRepeatNum(int repeat)
          Set the repeat number
 void setRoutingType(java.lang.String routingType)
          Set the routing type
 void setSenderId(java.lang.String id)
          Set the sender ID (must be a valid partner ID)
 void setSigInfo(byte[] sig, byte[] signedBody)
          Deprecated. digital signatures are now generated with a signing service
 void setStringListValue(java.lang.String name, java.lang.String[] value)
          Set a StringList-valued attribute
 void setStringValue(java.lang.String name, java.lang.String value)
          Set a string-valued attribute
 void setSystemStatus(java.lang.String stat)
          Set the system status
 void setTimestamp(java.sql.Timestamp time)
          Set the receipt timestamp (should only be called once)
 void setUserStatus(java.lang.String stat)
          Set the user status
 
Methods inherited from class com.wm.app.tn.util.TNFixedData
clone, dataSize, get, get, getCursor, getHashCursor, getIndexCursor, getKey, getSharedCursor, getTreeCursor, indexOf, merge, set, set, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setInternalId

public void setInternalId(java.lang.String id)
Set the document ID (should only be called once)


setDocType

public void setDocType(BizDocType type)
Set the document type (should only be called once)


setTimestamp

public void setTimestamp(java.sql.Timestamp time)
Set the receipt timestamp (should only be called once)


setLastModifiedTime

public void setLastModifiedTime(java.sql.Timestamp time)
Set the last mod time


setSenderId

public void setSenderId(java.lang.String id)
Set the sender ID (must be a valid partner ID)


setOriginalSenderId

public void setOriginalSenderId(java.lang.String id)
Set the original sender id


setReceiverId

public void setReceiverId(java.lang.String id)
Set the receiver ID (must be a valid partner ID)


setOriginalReceiverId

public void setOriginalReceiverId(java.lang.String id)
Set the original receiver id


setDocumentId

public void setDocumentId(java.lang.String id)
Set the document ID


setGroupId

public void setGroupId(java.lang.String id)
Set the group ID


setConversationId

public void setConversationId(java.lang.String id)
Set the conversation ID


setSystemStatus

public void setSystemStatus(java.lang.String stat)
Set the system status


setUserStatus

public void setUserStatus(java.lang.String stat)
Set the user status


setComments

public void setComments(java.lang.String comment)
Set the comments


setMonitoring

public void setMonitoring(boolean monitoring)
Set the Monitoring Enabled field


setMonitoringDataItems

public void setMonitoringDataItems(java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> monitoredDataItems)
Set the MonitoringDataItems


setMonitoringAction

public void setMonitoringAction(java.lang.String action)
Set the MonitoringAction


setRepeatNum

public void setRepeatNum(int repeat)
Set the repeat number


setRoutingType

public void setRoutingType(java.lang.String routingType)
Set the routing type


setSigInfo

public void setSigInfo(byte[] sig,
                       byte[] signedBody)
Deprecated. digital signatures are now generated with a signing service

Set info about a digital signature on this document (should only be called once).

Parameters:
sig - the signature
signedBody - the signed part of the document body

setContent

public void setContent(byte[] content)

setContentBytes

public void setContentBytes(byte[] cont)
Set the content bytes (should only be called once). The envelope maintains different parts of a document. But, it doesn't have enough knowledge about the doctype to handle this call. So, it off-loads this task to the corresponding doctype.


setPersisted

public void setPersisted(boolean persx)
For internal use only


setLargeDocument

public void setLargeDocument(boolean largeDocument)
For internal use only


getInternalId

public java.lang.String getInternalId()
Returns:
the internal ID of this document

getDocType

public BizDocType getDocType()
Returns:
the type of this document

getTimestamp

public java.sql.Timestamp getTimestamp()
Returns:
the timestamp on this document

getLastModifiedTime

public java.sql.Timestamp getLastModifiedTime()
Returns:
the time this document was last modified

getSenderId

public java.lang.String getSenderId()
Returns:
the sender of this document

getOriginalSenderId

public java.lang.String getOriginalSenderId()
Returns:
the original sender ID of this document

getReceiverId

public java.lang.String getReceiverId()
Returns:
the receiver of this document

getOriginalReceiverId

public java.lang.String getOriginalReceiverId()
Returns:
the original receiver ID of this document

getDocumentId

public java.lang.String getDocumentId()
Returns:
the document ID of this document

getGroupId

public java.lang.String getGroupId()
Returns:
the group ID of this document

getConversationId

public java.lang.String getConversationId()
Returns:
the conversation ID of this document

getSystemStatus

public java.lang.String getSystemStatus()
Returns:
the system status of this document

getUserStatus

public java.lang.String getUserStatus()
Returns:
the user-defined status of this document

getComments

public java.lang.String getComments()
Returns:
the comments of this document

getMonitoringDataItems

public java.util.Vector<java.util.HashMap<java.lang.String,java.lang.String>> getMonitoringDataItems()
Returns:
the hashMap of monitored DataItems values in a hashMap

getMonitoringAction

public java.lang.String getMonitoringAction()
Returns:
the Monitoring Action for the BAM Monitoring

getRepeatNum

public int getRepeatNum()
Returns:
the repeat number of this document

getRoutingType

public java.lang.String getRoutingType()
Returns:
the routing type of this document

getSignature

public byte[] getSignature()
Deprecated. digital signatures are now manipulated with a verification service

Returns:
the digital signature for this document

getSignedBody

public byte[] getSignedBody()
Deprecated. digital signatures are now manipulated with a verification service

Returns:
the signed body of this document

getContentBytes

public byte[] getContentBytes()
The envelope maintains different parts of a document. But, the envelope doesn't have enough knowledge to re-construct the document as a single byte[] from its parts. So, it off-loads this task to the corresponding doctype so that the doctype can do a better job of re-constructing the original document as a byte[] using its parts.

Returns:
the content of this document

getDeliveryContent

public java.lang.Object getDeliveryContent()
                                    throws java.io.IOException
Get delivery content of this envelope

Returns:
the content of this BizDocEnvelope as a java Object for small documents, the return value will be byte[] for large document, the return value will be InputStream
Throws:
java.io.IOException

getContent

public byte[] getContent()

isPersisted

public boolean isPersisted()
Returns:
has this document been written to the database?

isLargeDocument

public boolean isLargeDocument()
Returns:
is this a Large Document? (i.e. does it have one or more large content parts?)

isMonitored

public boolean isMonitored()
Returns:
is this document being monitored?

getErrorSet

public BizDocErrorSet getErrorSet()
Returns:
errors associated with this document

addError

public void addError(ActivityLogEntry a)
Add an error to this document. If the doc has been written to the DB, the errors is logged by this method; otherwise it's simply held in memory until the document is written


setNumberValue

public void setNumberValue(java.lang.String name,
                           double value)
Set a number-valued attribute


setDateValue

public void setDateValue(java.lang.String name,
                         java.sql.Timestamp value)
Set a date-valued attribute


setStringValue

public void setStringValue(java.lang.String name,
                           java.lang.String value)
Set a string-valued attribute


getDateValue

public java.sql.Timestamp getDateValue(java.lang.String id)
Accessor for date-valued attributes.

Parameters:
id - the ID of the attribute to fetch
Returns:
the Timestamp value of the attribute in question (null if it doesn't exist)

getNumberValue

public double getNumberValue(java.lang.String id)
Accessor for number-valued attributes.

Parameters:
id - the ID of the attribute to fetch
Returns:
the double value of the attribute in question (Double.NaN if it doesn't exist)

getStringValue

public java.lang.String getStringValue(java.lang.String id)
Accessor for string-valued attributes.

Parameters:
id - the ID of the attribute to fetch
Returns:
the String value of the attribute in question (null if it doesn't exist)

setNumberListValue

public void setNumberListValue(java.lang.String name,
                               java.lang.Double[] value)
Set a NumberList-valued attribute


setDateListValue

public void setDateListValue(java.lang.String name,
                             java.sql.Timestamp[] value)
Set a DatetimeList-valued attribute


setStringListValue

public void setStringListValue(java.lang.String name,
                               java.lang.String[] value)
Set a StringList-valued attribute


getDateListValue

public java.sql.Timestamp[] getDateListValue(java.lang.String id)
Accessor for DatetimeList-valued attributes.

Parameters:
id - the ID of the attribute to fetch
Returns:
the Timestamp[] value of the attribute in question (null if it doesn't exist)

getNumberListValue

public java.lang.Double[] getNumberListValue(java.lang.String id)
Accessor for NumberList-valued attributes.

Parameters:
id - the ID of the attribute to fetch
Returns:
the Double[] value of the attribute in question (null if it doesn't exist)

getStringListValue

public java.lang.String[] getStringListValue(java.lang.String id)
Accessor for StringList-valued attributes.

Parameters:
id - the ID of the attribute to fetch
Returns:
the String[] value of the attribute in question (null if it doesn't exist)

getAttributeNames

public java.util.Enumeration getAttributeNames()
Get the names of all the attributes this document has.

Returns:
an Enumeration of attribute names (possibly null)

getAttributes

public com.wm.data.IData getAttributes()
Get all attribute values of the document.

Returns:
a IData object with all attributes of the document (key is attribute name)

getRelationships

public BizDocRelationship[] getRelationships()
Get relationships on this document (can be null if there are none)


setRelationships

public void setRelationships(BizDocRelationship[] rel)
Set relationships on this document (can be null)


setErrorSet

public void setErrorSet(BizDocErrorSet set)

addRelationship

public void addRelationship(java.lang.String from,
                            java.lang.String to,
                            java.lang.String rel)
Adds a relationship from this document to another


getMaxPartIndex

public int getMaxPartIndex()
Returns:
maximum index of a content part on this document (-1 if there are no content parts)

getContentParts

public BizDocContentPart[] getContentParts()
Returns:
content parts of this document

setContentParts

public void setContentParts(BizDocContentPart[] parts)
Set content parts of this document


getContentPart

public BizDocContentPart getContentPart(java.lang.String partName)
Returns:
part by name (null if no such part)

addContentPart

public BizDocContentPart addContentPart(java.lang.String partName,
                                        java.lang.String mimeType,
                                        byte[] bytes,
                                        int partIndex)
Add a content part to this document

Parameters:
partName - name of the part
mimeType - mimeType of the part
bytes - content of part in byte[] format
partIndex - index of this part; if not specified takes next highest index
Returns:
the constructed BizDocContentPart object

addContentPart

public BizDocContentPart addContentPart(java.lang.String partName,
                                        java.lang.String mimeType,
                                        int partIndex,
                                        int partLength,
                                        java.lang.String storageType,
                                        java.lang.Object storageRef)
Add a content part to this document

Parameters:
partName - name of the part
mimeType - mimeType of the part
partIndex - index of this part; if not specified, takes next highest index
partLength - size of this content part
storageType - the type of storage in which the part is currently stored storageType should be one of STORAGE_TYPE constants from BizDocContentPart
storageRef - the storage reference on the associated storageType
Returns:
the constructed BizDocContentPart object

addLargeContentPart

public BizDocContentPart addLargeContentPart(java.lang.String partName,
                                             java.lang.String mimeType,
                                             int partIndex,
                                             java.io.InputStream contentStream,
                                             int contentLength)
                                      throws java.lang.Exception
Adds a large content part to this document. This method writes the given content stream to TSpace storage system and adds a content part to this document with a reference to that TSpace object. If this document is already persisted then this method will persist this part to the database. If this document is not persisted then this content part will be added to this document and this part will get persisted whenever the document is persisted to the database. If there is an error when adding this part to the TSpace, an error type AcitivityLogEntry is added to the associated document and the actual exception is thrown from this method as well.

Parameters:
partName - the name of the new content part
mimeType - the MIME type of the content part you are adding
partIndex - the position of the content part in the document's existing array of parts
contentStream - an InputStream representing the content of the part you are adding
contentLength - size of this part in bytes. Specify -1 if you want the length to be calculated from the stream.
Throws:
java.lang.Exception - when there is an error

replaceContentPart

public int replaceContentPart(java.lang.String partName,
                              BizDocContentPart revisedPart)
Replace a content part on this document

Parameters:
partName - name of the part to be replaced
revisedPart - the part that replaces the existing part
Returns:
updateCount the updateCount of this operation returns 0 if there is no such part otherwise returns updatedCount

replaceInternalId

public void replaceInternalId(java.lang.String newId)
For Internal use only


create

public static com.wm.data.IData create()
For internal use only


newEnvelope

public static BizDocEnvelope newEnvelope(BizDocType type)
Create a new envelope of the supplied type


createReply

public static BizDocEnvelope createReply(BizDocEnvelope doc)
Create a reply of the same type as the supplied document. Replies have sender and receiver reversed, but have the same group and conversation ID


createReply

public static BizDocEnvelope createReply(BizDocEnvelope doc,
                                         BizDocType replyType)
Create a reply of the supplied type. Replies have sender and receiver reversed, but have the same group and conversation ID


setPersistOption

public void setPersistOption(java.lang.String po)
For Internal use only


getPersistOption

public java.lang.String getPersistOption()
For Internal use only


setInternalPersistOption

public void setInternalPersistOption(boolean flag)
For Internal use only


getInternalPersistOption

public boolean getInternalPersistOption()
For Internal use only


setReceiveSvc

public void setReceiveSvc(java.lang.String svc)
Support for resubmit: set the original receive service of this document. The service is used for "resubmit" operation later.

Parameters:
svc - - nsname for the original receiver service

getReceiveSvc

public java.lang.String getReceiveSvc()
Support for resubmit: return the receive service name. The service is used for "resubmit" operation.

Parameters:
none -
Returns:
the nsname of the original receive service name

main

public static void main(java.lang.String[] args)