com.edustructures.sifworks
Class SIFMessageInfo

java.lang.Object
  extended by com.edustructures.sifworks.SIFMessageInfo
All Implemented Interfaces:
MessageInfo

public class SIFMessageInfo
extends java.lang.Object
implements MessageInfo

Encapsulates information about a SIF_Message, including its payload type, header fields, and raw XML message content.

An instance of this class is passed to the MessageInfo parameter of all ADK message handlers like Subscriber.onEvent, Publisher.onQuery, and QueryResults.onQueryResults so that implementations of those methods can access header fields or XML content associated with an incoming message. Callers should cast the MessageInfo object to a SIFMessageInfo type in order to call the methods of this class that are specific to the Schools Interoperability Framework.

Note that raw XML content is only retained if the "adk.messaging.keepMessageContent" agent property is enabled. Otherwise, the getMessage method returns a null value. Refer to the AgentProperties class for a description of all agent and zone properties.

To use SIFMessageInfo, cast the MessageInfo parameter as shown below.

    public void onEvent( Event event, Zone zone, MessageInfo info )
    {
        SIFMessageInfo inf = (SIFMessageInfo)info;
        String sourceId = inf.getSourceId();
        String msgId = inf.getMsgId();
        SIFVersion version = inf.getSIFVersion();

        // Display some information about this SIF_Event...
        System.out.println( "SIF_Event message with ID " + msgId +
            " received from agent " + sourceId +
            " in zone " + zone.getZoneId() + "."
            " This is a SIF " + version.toString() + " message." );

        ...

Version:
ADK 1.0

Constructor Summary
SIFMessageInfo()
          Called by the ADK to construct a SIFMessageInfo instance
SIFMessageInfo(SIFMessagePayload msg, Zone zone)
          Called by the ADK to construct a SIFMessageInfo
 
Method Summary
 java.lang.String getAttribute(java.lang.String attr)
          Gets the value of an attribute.
 java.lang.String[] getAttributeNames()
          Gets the names of all attributes.
 int getAuthenticationLevel()
          Gets the value of the optional SIF_Security/SIF_SecureChannel/SIF_AuthenticationLevel header element
 java.lang.String getDestinationId()
          Gets the value of the SIF_DestinationId header element
 int getEncryptionLevel()
          Gets the value of the optional SIF_Security/SIF_SecureChannel/SIF_EncryptionLevel header element
 SIFVersion getLatestSIFRequestVersion()
          For SIF_Request messages, gets the latest SIF version that was requested by the requestor and is supported by the ADK
 int getMaxBufferSize()
          For SIF_Request messages, gets the maximum packet size of result packets
 java.lang.String getMessage()
          Gets the content of the raw XML message
 java.lang.Boolean getMorePackets()
          For SIF_Response messages, determines if more packets are to be expected
 java.lang.String getMsgId()
          Gets the value of the SIF_MsgId header element
 java.lang.Integer getPacketNumber()
          For SIF_Response messages, gets the packet number
 java.lang.String getPayloadTag()
          Gets the SIF payload message element tag.
 byte getPayloadType()
          Gets the SIF payload message type.
 SIFContext[] getSIFContexts()
          Gets the SIFContexts that this message applies to
 SIF_Header getSIFHeader()
          Gets the SIF_Header encapsulated by this object.
 RequestInfo getSIFRequestInfo()
          For SIF_Responze messages, returns information about the original SIF_Request, including any custom user data that was assigned to the Query.setUserData(Serializable) member.
 java.lang.String getSIFRequestMsgId()
          For SIF_Response messages, gets the SIF_MsgId of the associated SIF_Request.
 ElementDef getSIFRequestObjectType()
          For SIF_Request messages, identifies the type of object requested
 SIFVersion[] getSIFRequestVersions()
          For SIF_Request messages, gets the SIF versions responses should conform to.
 SIFVersion getSIFVersion()
          Gets the version of SIF associated with the message.
 java.lang.String getSourceId()
          Gets the value of the SIF_SourceId header element
 java.util.Calendar getTimestamp()
          Gets the SIF_Message header timestamp.
 Zone getZone()
          Gets the zone from which the message originated.
 SIFMessageInfo parse(org.xml.sax.InputSource is, boolean keepMessage, Zone zone)
          Preparses a raw SIF_Message to extract its header information and payload element type.
 void setAttribute(java.lang.String attr, java.lang.String value)
          Sets the value of an attribute.
 void setSIFHeader(SIF_Header header)
          Assigns a SIF_Header to this message info.
 void setSIFRequestInfo(RequestInfo requestInfo)
          For SIF_Responze messages, returns information about the original SIF_Request, including any custom user data that was assigned to the Query.setUserData(Serializable) member.
 void setSIFRequestMsgId(java.lang.String msgId)
          For SIF_Response messages, sets the SIF_MsgId of the associated SIF_Request message.
 void setSIFRequestObjectType(ElementDef objType)
          For SIF_Request messages, identifies the type of object requested
 void setSIFRequestVersion(SIFVersion... versions)
          For SIF_Request messages, sets the SIF version that responses should conform to.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SIFMessageInfo

public SIFMessageInfo()
Called by the ADK to construct a SIFMessageInfo instance


SIFMessageInfo

public SIFMessageInfo(SIFMessagePayload msg,
                      Zone zone)
Called by the ADK to construct a SIFMessageInfo

Parameters:
msg - The SIF_Message
zone - The associated zone
Method Detail

setSIFHeader

public void setSIFHeader(SIF_Header header)
Assigns a SIF_Header to this message info. The SIF_Header element is usually extracted from the message by the constructor. When the default constructor is called, SIF_Header can be assigned separately by calling this method. Note this method is intended to be called internally by the class framework.

Parameters:
header - a SIF_Header instance
See Also:
getSIFHeader()

getSIFHeader

public SIF_Header getSIFHeader()
Gets the SIF_Header encapsulated by this object.

Returns:
The SIF_Header instance extracted from the message passed to the constructor or assigned via the setSIFHeader method.
See Also:
setSIFHeader(com.edustructures.sifworks.infra.SIF_Header)

getZone

public Zone getZone()
Gets the zone from which the message originated.

Specified by:
getZone in interface MessageInfo
Returns:
The Zone instance from which the message originated

getPayloadType

public byte getPayloadType()
Gets the SIF payload message type.

Specified by:
getPayloadType in interface MessageInfo
Returns:
A MSGTYP_ constant from the SIFDTD class (e.g. SIFDTD.MSGTYPE_REQUEST)

getPayloadTag

public java.lang.String getPayloadTag()
Gets the SIF payload message element tag.

Specified by:
getPayloadTag in interface MessageInfo
Returns:
The element tag of the message (e.g. "SIF_Request")

getTimestamp

public java.util.Calendar getTimestamp()
Gets the SIF_Message header timestamp.

Returns:
The SIF_Header/SIF_Date and SIF_Header/SIF_Time element values as a Date instance, identifying the time and date the message was sent
See Also:
#getTimeZone

getMsgId

public java.lang.String getMsgId()
Gets the value of the SIF_MsgId header element

Returns:
The value of the SIF_Header/SIF_MsgId element, the unique GUID assigned to the message by its sender

getSourceId

public java.lang.String getSourceId()
Gets the value of the SIF_SourceId header element

Returns:
The value of the SIF_Header/SIF_SourceId element, which identifies the agent that originated the message

getDestinationId

public java.lang.String getDestinationId()
Gets the value of the SIF_DestinationId header element

Returns:
The value of the optional SIF_Header/SIF_SourceId element. When present, it identifies the agent to which the message should be routed by the zone integration server.

getAuthenticationLevel

public int getAuthenticationLevel()
Gets the value of the optional SIF_Security/SIF_SecureChannel/SIF_AuthenticationLevel header element

Returns:
The authentication level or zero if not specified

getEncryptionLevel

public int getEncryptionLevel()
Gets the value of the optional SIF_Security/SIF_SecureChannel/SIF_EncryptionLevel header element

Returns:
The encryption level or zero if not specified

getMessage

public java.lang.String getMessage()
Gets the content of the raw XML message

Specified by:
getMessage in interface MessageInfo
Returns:
The raw XML message content as it was received by the ADK. If the adk.keepMessageContent agent or zone property has a value of "false" (the default), null is returned.

getSIFVersion

public SIFVersion getSIFVersion()
Gets the version of SIF associated with the message. The version is determined by inspecting the xmlns attribute of the SIF_Message envelope.

Returns:
A SIFVersion object identifying the version of SIF associated with the message
See Also:
#getSIFRequestVersion

setSIFRequestMsgId

public void setSIFRequestMsgId(java.lang.String msgId)
For SIF_Response messages, sets the SIF_MsgId of the associated SIF_Request message. This method is called internally by the class framework.

Parameters:
msgId - The value to assign to the SIF_Header/SIF_RequestMsgId element

getSIFRequestMsgId

public java.lang.String getSIFRequestMsgId()
For SIF_Response messages, gets the SIF_MsgId of the associated SIF_Request.

Returns:
The value of the SIF_Header/SIF_RequestMsgId element, or null if the message encapsulated by this SIFMessageInfo instance is not a SIF_Response message

setSIFRequestVersion

public void setSIFRequestVersion(SIFVersion... versions)
For SIF_Request messages, sets the SIF version that responses should conform to. This method is called internally by the class framework.

Parameters:
version - A SIFVersion instance identifying the version of the specification that SIF_Responses should conform to.
See Also:
getSIFVersion()

getSIFRequestVersions

public SIFVersion[] getSIFRequestVersions()
For SIF_Request messages, gets the SIF versions responses should conform to.

Returns:
The value of the SIF_Request/SIF_Version element or null if the message is not a SIF_Request message

getLatestSIFRequestVersion

public SIFVersion getLatestSIFRequestVersion()
For SIF_Request messages, gets the latest SIF version that was requested by the requestor and is supported by the ADK

Returns:
The value of the SIF_Request/SIF_Version element or null if the message is not a SIF_Request message

setSIFRequestInfo

public void setSIFRequestInfo(RequestInfo requestInfo)
For SIF_Responze messages, returns information about the original SIF_Request, including any custom user data that was assigned to the Query.setUserData(Serializable) member.

Parameters:
requestInfo - a RequestInfo object representing the SIF_Request
See Also:
getSIFRequestInfo()

getSIFRequestInfo

public RequestInfo getSIFRequestInfo()
For SIF_Responze messages, returns information about the original SIF_Request, including any custom user data that was assigned to the Query.setUserData(Serializable) member.

Returns:
a RequestInfo object representing the request.
See Also:
setSIFRequestInfo(RequestInfo)

setSIFRequestObjectType

public void setSIFRequestObjectType(ElementDef objType)
For SIF_Request messages, identifies the type of object requested

Parameters:
objType - An ElementDef constant from the SIFDTD class

getSIFRequestObjectType

public ElementDef getSIFRequestObjectType()
For SIF_Request messages, identifies the type of object requested

Returns:
An ElementDef constant from the SIFDTD class

getPacketNumber

public java.lang.Integer getPacketNumber()
For SIF_Response messages, gets the packet number

Returns:
The Integer value of the SIF_Response/SIF_PacketNumber element or null if the message is not a SIF_Response message

getMorePackets

public java.lang.Boolean getMorePackets()
For SIF_Response messages, determines if more packets are to be expected

Returns:
The string value of the SIF_Response/SIF_MorePackets element or null if the message is not a SIF_Response message or the element is missing.

getMaxBufferSize

public int getMaxBufferSize()
For SIF_Request messages, gets the maximum packet size of result packets

Returns:
The value of the SIF_Request/SIF_MaxBufferSize element or zero if the message is not a SIF_Request message or the buffer size could not be converted to an integer

getAttribute

public java.lang.String getAttribute(java.lang.String attr)
Description copied from interface: MessageInfo
Gets the value of an attribute. Implementations of this interface may define attributes to hold values specific to the messaging protocol.

Specified by:
getAttribute in interface MessageInfo
Parameters:
attr - The name of the attribute
Returns:
The value of the attribute, or null if not defined
See Also:
MessageInfo.setAttribute(java.lang.String, java.lang.String), MessageInfo.getAttributeNames()

setAttribute

public void setAttribute(java.lang.String attr,
                         java.lang.String value)
Description copied from interface: MessageInfo
Sets the value of an attribute. Implementations of this interface may define attributes to hold values specific to the messaging protocol.

Specified by:
setAttribute in interface MessageInfo
Parameters:
attr - The attribute name
value - The attribute value
See Also:
MessageInfo.getAttributeNames(), MessageInfo.getAttribute(java.lang.String)

getAttributeNames

public java.lang.String[] getAttributeNames()
Description copied from interface: MessageInfo
Gets the names of all attributes. Implementations of this interface may define attributes to hold values specific to the messaging protocol.

Specified by:
getAttributeNames in interface MessageInfo
Returns:
An array of the attribute names that can be individually queried by the getAttribute method
See Also:
MessageInfo.getAttribute(java.lang.String), MessageInfo.setAttribute(java.lang.String, java.lang.String)

parse

public SIFMessageInfo parse(org.xml.sax.InputSource is,
                            boolean keepMessage,
                            Zone zone)
                     throws java.io.IOException,
                            ADKMessagingException
Preparses a raw SIF_Message to extract its header information and payload element type. Applications that do not wish to fully parse a message but need to know its header information can call this method and defer full parsing to a later stage. When keepContent is true, the message content is preserved as-is in the returned SIFMessageInfo object and can be retrieved by calling getMessage on that object.

For SIF_Ack messages, the value of <SIF_OriginalMsgId> and <SIF_OriginalSourceId> are parsed and stored in the SIFMessageInfo object. These are the only non-header elements that are parsed.

Parameters:
is - The source of the SIF_Message to preparse
Returns:
A SIFMessageInfo object containing information about the message
Throws:
java.io.IOException
ADKMessagingException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSIFContexts

public SIFContext[] getSIFContexts()
Gets the SIFContexts that this message applies to

Returns:


Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.