org.opengts.util
Class ServiceRequest

java.lang.Object
  extended by org.opengts.util.ServiceRequest
Direct Known Subclasses:
GTSServiceRequest

public class ServiceRequest
extends java.lang.Object

ServoceRequest tools


Nested Class Summary
static class ServiceRequest.Authorization
          Authorization class
static interface ServiceRequest.RequestBody
          Request Body handler class
 
Field Summary
static java.lang.String AUTH_ENCODING_PREFIX
           
protected static java.lang.String METHOD_handleRequest
           
protected static java.lang.String SRATTR_account
           
protected static java.lang.String SRATTR_auth
           
protected static java.lang.String SRATTR_code
           
protected static java.lang.String SRATTR_command
           
protected static java.lang.String SRATTR_password
           
protected static java.lang.String SRATTR_result
           
protected static java.lang.String SRATTR_user
           
protected static java.lang.String SRTAG_Authorization
           
protected static java.lang.String SRTAG_GTSRequest
           
protected static java.lang.String SRTAG_GTSResponse
           
protected static java.lang.String SRTAG_Message
           
 
Constructor Summary
ServiceRequest()
          Constructor
ServiceRequest(javax.management.remote.JMXServiceURL jmxURL, java.lang.String jmxObjName)
          Constructor
ServiceRequest(ServiceRequest other)
          Clone Constructor
ServiceRequest(java.lang.String url)
          Constructor
ServiceRequest(java.net.URL serviceURL)
          Constructor
 
Method Summary
protected  byte[] _sendRequest_HTTP(java.lang.String reqXMLStr, int timeoutMS)
          Sends the request and returns the results as an XML Document
protected  byte[] _sendRequest_JMX(java.lang.String reqXMLStr)
          Sends the request and returns the results as an XML Document
protected  org.w3c.dom.Document _sendRequest(java.lang.String reqXMLStr, int timeoutMS)
          Sends the request and returns the results as an XML Document
 java.lang.StringBuffer appendRequestBody(java.lang.StringBuffer sb, int indent)
          Appends the request body to the specified StringBuffer
 java.lang.String getAttrAccount()
           
 java.lang.String getAttrAuth()
           
 java.lang.String getAttrCommand()
           
 java.lang.String getAttrPassword()
           
 java.lang.String getAttrResult()
           
 java.lang.String getAttrUser()
           
 java.lang.String getCommand()
          Gets the command ID included in the request header
 java.lang.String getJMXObjectName()
          Gets the JMX service object name
 javax.management.remote.JMXServiceURL getJMXServiceURL()
          Gets the service URL
 java.lang.String getTagAuthorization()
           
 java.lang.String getTagRequest()
           
 java.lang.String getTagResponse()
           
 java.net.URL getURL()
          Gets the service URL
 boolean isJMX()
          Returns true if this is a JMX request
 org.w3c.dom.Document sendRequest(java.io.File reqFile)
          Sends the request and returns the results as an XML Document
 org.w3c.dom.Document sendRequest(java.lang.String command, ServiceRequest.RequestBody rb)
          Sends the request and returns the results as an XML Document
 ServiceRequest setAuthorization(ServiceRequest.Authorization auth)
          Sets the Service Authorization
 ServiceRequest setAuthorization(java.lang.String acctID, java.lang.String userID, java.lang.String passwd, java.lang.String authKey)
          Sets the Service Authorization
 ServiceRequest setCommand(java.lang.String cmd)
          Sets the command ID included in the request header
 void setJMXObjectName(java.lang.String objName)
          Sets the JMX service object name
 ServiceRequest setRequestBody(ServiceRequest.RequestBody rb)
          Sets the request body handler
 ServiceRequest setURL(javax.management.remote.JMXServiceURL url, java.lang.String jmxObjName)
          Sets the service URL
 ServiceRequest setURL(java.lang.String url)
          Sets the service URL
 ServiceRequest setURL(java.net.URL url)
          Sets the service URL
 java.lang.String toString()
          Returns a XML string representation of this instance
 java.lang.String toXML(java.lang.String command, ServiceRequest.RequestBody rb)
          Assembles and returns an XML request string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SRTAG_GTSRequest

protected static final java.lang.String SRTAG_GTSRequest
See Also:
Constant Field Values

SRTAG_GTSResponse

protected static final java.lang.String SRTAG_GTSResponse
See Also:
Constant Field Values

SRTAG_Message

protected static final java.lang.String SRTAG_Message
See Also:
Constant Field Values

SRTAG_Authorization

protected static final java.lang.String SRTAG_Authorization
See Also:
Constant Field Values

SRATTR_command

protected static final java.lang.String SRATTR_command
See Also:
Constant Field Values

SRATTR_result

protected static final java.lang.String SRATTR_result
See Also:
Constant Field Values

SRATTR_code

protected static final java.lang.String SRATTR_code
See Also:
Constant Field Values

SRATTR_account

protected static final java.lang.String SRATTR_account
See Also:
Constant Field Values

SRATTR_user

protected static final java.lang.String SRATTR_user
See Also:
Constant Field Values

SRATTR_password

protected static final java.lang.String SRATTR_password
See Also:
Constant Field Values

SRATTR_auth

protected static final java.lang.String SRATTR_auth
See Also:
Constant Field Values

METHOD_handleRequest

protected static final java.lang.String METHOD_handleRequest
See Also:
Constant Field Values

AUTH_ENCODING_PREFIX

public static final java.lang.String AUTH_ENCODING_PREFIX
See Also:
Constant Field Values
Constructor Detail

ServiceRequest

public ServiceRequest()
Constructor


ServiceRequest

public ServiceRequest(ServiceRequest other)
Clone Constructor


ServiceRequest

public ServiceRequest(java.lang.String url)
               throws java.net.MalformedURLException
Constructor

Parameters:
url - The Service URL
Throws:
java.net.MalformedURLException

ServiceRequest

public ServiceRequest(java.net.URL serviceURL)
Constructor

Parameters:
serviceURL - The Service URL

ServiceRequest

public ServiceRequest(javax.management.remote.JMXServiceURL jmxURL,
                      java.lang.String jmxObjName)
Constructor

Parameters:
jmxURL - The JMX Service URL
Method Detail

setURL

public ServiceRequest setURL(java.lang.String url)
                      throws java.net.MalformedURLException
Sets the service URL

Parameters:
url - The Service URL
Returns:
This ServiceRequest
Throws:
java.net.MalformedURLException

setURL

public ServiceRequest setURL(java.net.URL url)
Sets the service URL

Parameters:
url - The Service URL
Returns:
This ServiceRequest

getURL

public java.net.URL getURL()
Gets the service URL

Returns:
url The Service URL

setURL

public ServiceRequest setURL(javax.management.remote.JMXServiceURL url,
                             java.lang.String jmxObjName)
Sets the service URL

Parameters:
url - The Service URL
Returns:
This ServiceRequest

getJMXServiceURL

public javax.management.remote.JMXServiceURL getJMXServiceURL()
Gets the service URL

Returns:
url The Service URL

isJMX

public boolean isJMX()
Returns true if this is a JMX request

Returns:
True if this is a JMX request

setJMXObjectName

public void setJMXObjectName(java.lang.String objName)
Sets the JMX service object name

Parameters:
objName - The JMX service object name

getJMXObjectName

public java.lang.String getJMXObjectName()
Gets the JMX service object name

Returns:
The JMX service object name

setAuthorization

public ServiceRequest setAuthorization(java.lang.String acctID,
                                       java.lang.String userID,
                                       java.lang.String passwd,
                                       java.lang.String authKey)
Sets the Service Authorization

Parameters:
acctID - The Authorization account ID
userID - The Authorization user ID
passwd - The Authorization password
Returns:
This ServiceRequest

setAuthorization

public ServiceRequest setAuthorization(ServiceRequest.Authorization auth)
Sets the Service Authorization

Parameters:
auth - The Authorization wrapper
Returns:
This ServiceRequest

setCommand

public ServiceRequest setCommand(java.lang.String cmd)
Sets the command ID included in the request header

Parameters:
cmd - The command ID
Returns:
This ServiceRequest

getCommand

public java.lang.String getCommand()
Gets the command ID included in the request header

Returns:
The command ID

setRequestBody

public ServiceRequest setRequestBody(ServiceRequest.RequestBody rb)
Sets the request body handler

Parameters:
rb - The RequestBody handler
Returns:
This ServiceRequest

appendRequestBody

public java.lang.StringBuffer appendRequestBody(java.lang.StringBuffer sb,
                                                int indent)
Appends the request body to the specified StringBuffer

Parameters:
sb - The StringBuffer
indent - The prefixing spaces to include
Returns:
The StringBuffer

toXML

public java.lang.String toXML(java.lang.String command,
                              ServiceRequest.RequestBody rb)
Assembles and returns an XML request string

Parameters:
command - The command ID to include in the header
rb - The RequestBody handler
Returns:
The XML request

toString

public java.lang.String toString()
Returns a XML string representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
An XML string representation

sendRequest

public org.w3c.dom.Document sendRequest(java.lang.String command,
                                        ServiceRequest.RequestBody rb)
                                 throws java.io.IOException
Sends the request and returns the results as an XML Document

Throws:
java.io.IOException

sendRequest

public org.w3c.dom.Document sendRequest(java.io.File reqFile)
                                 throws java.io.IOException
Sends the request and returns the results as an XML Document

Throws:
java.io.IOException

_sendRequest

protected org.w3c.dom.Document _sendRequest(java.lang.String reqXMLStr,
                                            int timeoutMS)
                                     throws java.io.IOException
Sends the request and returns the results as an XML Document

Throws:
java.io.IOException

_sendRequest_JMX

protected byte[] _sendRequest_JMX(java.lang.String reqXMLStr)
                           throws java.io.IOException
Sends the request and returns the results as an XML Document

Throws:
java.io.IOException

_sendRequest_HTTP

protected byte[] _sendRequest_HTTP(java.lang.String reqXMLStr,
                                   int timeoutMS)
                            throws java.io.IOException
Sends the request and returns the results as an XML Document

Throws:
java.io.IOException

getTagResponse

public java.lang.String getTagResponse()

getTagRequest

public java.lang.String getTagRequest()

getTagAuthorization

public java.lang.String getTagAuthorization()

getAttrCommand

public java.lang.String getAttrCommand()

getAttrResult

public java.lang.String getAttrResult()

getAttrAccount

public java.lang.String getAttrAccount()

getAttrUser

public java.lang.String getAttrUser()

getAttrPassword

public java.lang.String getAttrPassword()

getAttrAuth

public java.lang.String getAttrAuth()