com.altair.hwm.fileserver.soap
Class HWMSOAPUtil

java.lang.Object
  extended by com.altair.hwm.fileserver.soap.HWMSOAPUtil

public class HWMSOAPUtil
extends java.lang.Object

Title: HWMSOAPUtil

Description: A utility class for SOAP related functions

Company: Altair Engineering, Inc.


Constructor Summary
HWMSOAPUtil()
          Constructor
 
Method Summary
static void CheckForErrors(javax.xml.soap.SOAPEnvelope soapEnv, javax.xml.soap.SOAPElement soapElemReply, java.lang.String strCmd)
          Checks for the error section in the reply.
static void FillSOAPMsg(javax.xml.soap.SOAPMessage soapMsg, javax.xml.soap.SOAPElement soapElem, HWMFileInfo hwmFileInfo, boolean bZip)
          Given the HWMFileInfo command, fills in the SOAP msg
static void FormatErrorReply(javax.xml.soap.SOAPMessage soapMsg, java.lang.String strCmd, java.lang.String strErr, java.lang.Throwable th)
          Fill the reply SOAP message
static javax.xml.soap.SOAPBodyElement FormatReplyBody(javax.xml.soap.SOAPMessage soapMsg, java.lang.String strCmd)
          Fills te soap message with the element
static javax.xml.soap.AttachmentPart GetAttachment(javax.xml.soap.SOAPMessage soapMsg, java.lang.String strContentID)
          Returns the attachment part with the given content id
static javax.xml.soap.SOAPElement GetChildElement(javax.xml.soap.SOAPElement soapElemParent, javax.xml.soap.Name name)
          Gets the required child element with the given name.
static void GetFileInfo(javax.xml.soap.SOAPMessage soapMsgReply, javax.xml.soap.SOAPElement soapElemParams, java.lang.String strCmd, HWMFileInfo hwmFileInfo, boolean bUnCompress)
          Given the parameter element, it parses it and returns the information about the file encapsulated in the parameter section.
static HWMFileInfo ParseReplyForFileInfo(javax.xml.soap.SOAPMessage soapMsgReply, javax.xml.soap.SOAPElement soapElemReply, java.lang.String strCmd, boolean bUnCompress)
          Given the reply element, it parses it and returns the information about the file.
static void WriteToFile(java.io.InputStream in, java.lang.String strFile)
          Writes the data from the stream onto the given file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HWMSOAPUtil

public HWMSOAPUtil()
Constructor

Method Detail

FormatErrorReply

public static void FormatErrorReply(javax.xml.soap.SOAPMessage soapMsg,
                                    java.lang.String strCmd,
                                    java.lang.String strErr,
                                    java.lang.Throwable th)
                             throws javax.xml.soap.SOAPException
Fill the reply SOAP message

Parameters:
soapMsg - the reply SOAP message
strCmd - The command name which failed
strErr - The error string
th - The throwable class which represents either an exception or error which occurred.
Throws:
javax.xml.soap.SOAPException

FormatReplyBody

public static javax.xml.soap.SOAPBodyElement FormatReplyBody(javax.xml.soap.SOAPMessage soapMsg,
                                                             java.lang.String strCmd)
                                                      throws javax.xml.soap.SOAPException
Fills te soap message with the element

Parameters:
soapMsg - The SOAP reply message
strCmd - The command name
Returns:
SOAPBodyElement The reply element
Throws:
javax.xml.soap.SOAPException

GetChildElement

public static javax.xml.soap.SOAPElement GetChildElement(javax.xml.soap.SOAPElement soapElemParent,
                                                         javax.xml.soap.Name name)
Gets the required child element with the given name. If there are more than one, it returns the first one.

Parameters:
soapElemParent - The parent SOAP element from which the child element with given name should be returned
name - The name of the child element
Returns:
SOAPElement The child element with given name

GetAttachment

public static javax.xml.soap.AttachmentPart GetAttachment(javax.xml.soap.SOAPMessage soapMsg,
                                                          java.lang.String strContentID)
                                                   throws javax.xml.soap.SOAPException
Returns the attachment part with the given content id

Parameters:
soapMsg - The SOAP message which contains the attachments
strContentID - The content id of the required attachment
Returns:
AttachmentPart The attachment part
Throws:
javax.xml.soap.SOAPException

FillSOAPMsg

public static void FillSOAPMsg(javax.xml.soap.SOAPMessage soapMsg,
                               javax.xml.soap.SOAPElement soapElem,
                               HWMFileInfo hwmFileInfo,
                               boolean bZip)
                        throws javax.xml.soap.SOAPException
Given the HWMFileInfo command, fills in the SOAP msg

Parameters:
soapMsg - The SOAP reply
soapElem - The reply or cmd element
hwmFileInfo - The file info object
bZip - If true, the file (if present) is zipped.
Throws:
javax.xml.soap.SOAPException

CheckForErrors

public static void CheckForErrors(javax.xml.soap.SOAPEnvelope soapEnv,
                                  javax.xml.soap.SOAPElement soapElemReply,
                                  java.lang.String strCmd)
                           throws java.lang.Exception
Checks for the error section in the reply. If the error section is present, this will throw an exception to inform about the error.

Parameters:
soapEnv - The SOAP envelope of the reply message
soapElemReply - The reply element
strCmd - The command name for which this reply is received
Throws:
java.lang.Exception

ParseReplyForFileInfo

public static HWMFileInfo ParseReplyForFileInfo(javax.xml.soap.SOAPMessage soapMsgReply,
                                                javax.xml.soap.SOAPElement soapElemReply,
                                                java.lang.String strCmd,
                                                boolean bUnCompress)
                                         throws java.lang.Exception
Given the reply element, it parses it and returns the information about the file.

Parameters:
soapMsgReply - The SOAP reply message
soapElemReply - The reply element
strCmd - The command name for which this reply is received
bUnCompress - Uncompress the file or not. if true - uncompression will be done.
Returns:
HWMFileInfo The file info object
Throws:
java.lang.Exception

GetFileInfo

public static void GetFileInfo(javax.xml.soap.SOAPMessage soapMsgReply,
                               javax.xml.soap.SOAPElement soapElemParams,
                               java.lang.String strCmd,
                               HWMFileInfo hwmFileInfo,
                               boolean bUnCompress)
                        throws java.lang.Exception
Given the parameter element, it parses it and returns the information about the file encapsulated in the parameter section.

Parameters:
soapMsgReply - The SOAP reply message
soapElemParam - The parameter section of the reply
strCmd - The command name for which this reply is received
hwmFileInfo - The file info object that needs to be filled
bUnCompress - Uncompress the file or not. if true - uncompression will be done.
Throws:
java.lang.Exception

WriteToFile

public static void WriteToFile(java.io.InputStream in,
                               java.lang.String strFile)
                        throws java.lang.Exception
Writes the data from the stream onto the given file

Parameters:
in - The InputStream
strFile - The file name (complete path)
Throws:
java.lang.Exception