com.ibm.xcap.client
Class XcapClientRequest

java.lang.Object
  extended by com.ibm.xcap.base.BaseXcapRequest
      extended by com.ibm.xcap.client.XcapClientRequest
All Implemented Interfaces:
XcapConstants, XcapRequest

public class XcapClientRequest
extends BaseXcapRequest

XcapClientRequest is constructed to send an XCAP request to an XDMS. The XcapClientRequest supports digest authentication. If the password is empty then it will try to send an asserted identity in the headers. The default asserted identity header that is used is X-Xcap-Asserted-Identity. If another header should be used, call the setDefaultIdentityHeader(String) method.


Field Summary
static java.lang.String CLASSNAME
          Classname
static java.util.logging.Logger LOGGER
          Logger for this class
 
Fields inherited from class com.ibm.xcap.base.BaseXcapRequest
auid, documentSelector, httpMethod, nodeSelector, xcapRoot, xcapURI, xml, xmlName, xui
 
Fields inherited from interface com.ibm.xcap.XcapConstants
ANONYMOUS_USER, APPEND_CONTENT_TYPE_CHARSET_UTF8, AUID_OMA_SEARCH, AUID_PRES_RULES, AUID_PRES_RULES_ACLS, AUID_RESOURCE_LISTS, AUID_RESOURCE_LISTS_ACLS, AUID_RLS_SERVICES, AUID_RLS_SERVICES_ACLS, AUID_XCAP_CAPS, AUID_XCAP_DIRECTORY, CHARSET_UTF8, CLIENT_RESOURCE_BUNDLE, CLOSE_BRACKET, CONTENT_TYPE_APPLICATION_ERROR_XML, CONTENT_TYPE_AUTH_POLICY, CONTENT_TYPE_NAMESPACE_BINDING, CONTENT_TYPE_OMA_DIRECTORY, CONTENT_TYPE_OMA_SEARCH, CONTENT_TYPE_PRES_RULES, CONTENT_TYPE_RESOURCE_LISTS, CONTENT_TYPE_RLS_SERVICES, CONTENT_TYPE_XCAP_CAPS, CONTENT_TYPE_XCAP_DIFF, CONTENT_TYPE_XCAP_ERROR, CONTENT_TYPE_XML_ATTRIBUTE, CONTENT_TYPE_XML_ELEMENT, DOC_GLOBAL_DIRECTORY, DOC_GLOBAL_INDEX, DOC_USER_DIRECTORY, DOC_XCAP_CAPS, DOUBLE_FORWARD_SLASH, EMPTY, ENCODED_SINGLE_QUOTE, ENCODED_SLASH_CLOSE_BRACKET, ENCODED_SLASH_OPEN_BRACKET, EXTENSION_LOCAL_CONSTRAINT_FAILURE, FORWARD_SLASH, GLOBAL, GLOBAL_DOC_DIRECTORY_PREFIX, GLOBAL_DOC_DIRECTORY_SUFFIX, HEADER_ACCEPT, HEADER_ALLOW, HEADER_CONTENT_TYPE, HEADER_ETAG, HEADER_IF_MATCH, HEADER_IF_NONE_MATCH, HEADER_LAST_MODIFIED, HEADER_X_3GPP_ASSERTED_IDENTITY, HEADER_X_3GPP_INTENDED_IDENTITY, HEADER_X_XCAP_ASSERTED_IDENTITY, HTTP_METHOD_DELETE, HTTP_METHOD_GET, HTTP_METHOD_POST, HTTP_METHOD_PUT, NS_COMMON_POLICY, NS_OMA_APPUSAGE, NS_OMA_COMMON_POLICY, NS_OMA_URIUSAGE, NS_OMA_XCAP_ERROR, NS_PRES_RULES, NS_RESOURCE_LISTS, NS_RLS_SERVICES, NS_XCAP_CAPS, NS_XCAP_DIRECTORY, NS_XCAP_ERROR, OPEN_BRACKET, PATH_SEARCH, RC_100_CONTINUE, RC_101_SWITCHING_PROTOCOLS, RC_200_OK, RC_201_CREATED, RC_202_ACCEPTED, RC_203_NON_AUTHORITATIVE_INFO, RC_204_NO_CONTENT, RC_205_RESET_CONTENT, RC_206_PARTIAL_CONTENT, RC_300_MULTIPLE_CHOICES, RC_301_MOVED_PERMANANTLY, RC_302_FOUND, RC_303_SEE_OTHER, RC_304_NOT_MODIFIED, RC_305_USE_PROXY, RC_307_TEMPORARY_REDIRECT, RC_400_BAD_REQUEST, RC_401_UNAUTHORIZED, RC_402_PAYMENT_REQUIRED, RC_403_FORBIDDEN, RC_404_NOT_FOUND, RC_405_METHOD_NOT_ALLOWED, RC_406_NOT_ACCEPTABLE, RC_407_PROXY_AUTHENTICATION_REQUIRED, RC_408_REQUEST_TIMEOUT, RC_409_CONFLICT, RC_410_GONE, RC_411_LENGTH_REQUIRED, RC_412_PRECONDITION_FAILED, RC_413_REQUEST_ENTITY_TOO_LARGE, RC_414_REQUEST_URI_TOO_LONG, RC_415_UNSUPPORTED_MEDIA_TYPE, RC_416_REQUESTED_RANGE_NOT_SATISFIABLE, RC_417_EXPECTATION_FAILED, RC_500_INTERNAL_SERVER_ERROR, RC_501_NOT_IMPLEMENTED, RC_502_BAD_GATEWAY, RC_503_SERVICES_UNAVAILABLE, RC_504_GATEWAY_TIMEOUT, RC_505_HTTP_VERSION_NOT_SUPPORTED, SINGLE_QUOTE, SINGLE_SPACE, SLASH_CLOSE_BRACKET, SLASH_OPEN_BRACKET, USERS, UTF_8, UTF8_BYTE_ORDER_MARKER, XML_DECLARATION, XPATH_SEPARATOR
 
Constructor Summary
XcapClientRequest(java.lang.String httpMethod, java.lang.String userName, java.lang.String password, java.lang.String xcapRoot, java.lang.String auid, java.lang.String xui, java.lang.String xmlName, java.lang.String nodeSelector, java.lang.String xml)
          Constructs the XcapClientRequest.
XcapClientRequest(java.lang.String httpMethod, java.lang.String userName, java.lang.String password, java.net.URL xcapURI, java.lang.String xml)
          Constructs the XcapClientRequest.
 
Method Summary
 void addHeader(java.lang.String header, java.lang.String value)
          Adds the header value.
 java.lang.String getHeader(java.lang.String header)
          Get the value associated with a header name.
 java.util.Enumeration getHeaderNames()
          Returns an Enumeration of request header names that has been set.
 java.util.Enumeration getHeaders(java.lang.String header)
          Returns an Enumeration if there are multiple headers with the same name.
 java.lang.String getPassword()
          Returns the password associated with the user.
 java.lang.String getUserName()
          Returns the current user name to authenticate with.
 XcapClientResponse send()
          Sends the XCAP request to the XDMS.
 void send(ThreadedRequestHandler requestHandler)
          Send an XDMS Request via a threaded handler using the callers own thread to process the request.
 void sendAsync(ThreadedRequestHandler requestHandler)
          Send an XDMS Request via a threaded handler attempting to use a thread on the threadpool to support multithreaded requests.
static void setDefaultIdentityHeader(java.lang.String identityHeader)
          Sets the default identity header used if no password is specified.
 void setHeader(java.lang.String header, java.lang.String value)
          Adds the header if it does not exist or replaces an existing header.
 void setPassword(java.lang.String password)
          Sets the password associated with the user.
 void setUserName(java.lang.String userName)
          Sets the current user name to authenticate with.
 java.lang.String toString()
           
 
Methods inherited from class com.ibm.xcap.base.BaseXcapRequest
getAuid, getContentType, getDocumentSelector, getHttpMethod, getNodeSelector, getXcapRoot, getXcapURI, getXml, getXmlName, getXui, isGlobalDocument, setHttpMethod, setXcapURI, setXcapURI, setXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASSNAME

public static final java.lang.String CLASSNAME
Classname


LOGGER

public static final java.util.logging.Logger LOGGER
Logger for this class

Constructor Detail

XcapClientRequest

public XcapClientRequest(java.lang.String httpMethod,
                         java.lang.String userName,
                         java.lang.String password,
                         java.net.URL xcapURI,
                         java.lang.String xml)
                  throws java.net.MalformedURLException
Constructs the XcapClientRequest.

Parameters:
httpMethod - The HTTP METHOD type.
userName - The username to authenticate with.
password - The password to authenticate with. If null, then assume that the identity will be asserted.
xcapURI - The full XCAP URI of the form http(s)://hostname:hostport/contextRoot/AUID/xcapDocSelector/~~/xcapNodeSelector
xml - The XML document if sending a PUT or POST.
Throws:
java.net.MalformedURLException
See Also:
XcapConstants.HTTP_METHOD_GET, XcapConstants.HTTP_METHOD_PUT, XcapConstants.HTTP_METHOD_DELETE

XcapClientRequest

public XcapClientRequest(java.lang.String httpMethod,
                         java.lang.String userName,
                         java.lang.String password,
                         java.lang.String xcapRoot,
                         java.lang.String auid,
                         java.lang.String xui,
                         java.lang.String xmlName,
                         java.lang.String nodeSelector,
                         java.lang.String xml)
                  throws java.net.MalformedURLException
Constructs the XcapClientRequest.

Parameters:
httpMethod - The HTTP METHOD type.
userName - The username to authenticate with.
password - The password to authenticate with. If null, then assume that the identity will be asserted.
xcapRoot - The xcap root of the form http(s)://hostname:hostport/contextRoot
auid - The AUID of the XCAP URI.
xui - The XML User Identifier. If not specified, then assumes a GLOBAL document.
xmlName - The name used to identify the XML document.
nodeSelector - The nodeSelector that does NOT include the ~~ separator.
xml - The XML document if sending a PUT or POST.
Throws:
java.net.MalformedURLException
See Also:
XcapConstants.HTTP_METHOD_GET, XcapConstants.HTTP_METHOD_PUT, XcapConstants.HTTP_METHOD_DELETE
Method Detail

setDefaultIdentityHeader

public static void setDefaultIdentityHeader(java.lang.String identityHeader)
Sets the default identity header used if no password is specified.

Parameters:
identityHeader - The default is HEADER_X_XCAP_ASSERTED_IDENTITY
See Also:
XcapConstants.HEADER_X_3GPP_ASSERTED_IDENTITY, XcapConstants.HEADER_X_3GPP_INTENDED_IDENTITY, XcapConstants.HEADER_X_XCAP_ASSERTED_IDENTITY

getHeaderNames

public java.util.Enumeration getHeaderNames()
Returns an Enumeration of request header names that has been set.

Returns:
Returns an Enumeration of request header names that has been set.

getHeader

public java.lang.String getHeader(java.lang.String header)
Get the value associated with a header name. If the header has multiple values, the first header value is returned.

Parameters:
header - The name of the header.
Returns:
Returns the first header value.

getHeaders

public java.util.Enumeration getHeaders(java.lang.String header)
Returns an Enumeration if there are multiple headers with the same name.

Parameters:
header - The name of the header.
Returns:
Returns an Enumeration if there are multiple headers with the same name.

setHeader

public void setHeader(java.lang.String header,
                      java.lang.String value)
Adds the header if it does not exist or replaces an existing header. If needing to add multiple header values, then use the addHeader(String, String) method.

Parameters:
header - The name of the header.
value - The value to replace all existing values.
See Also:
addHeader(String, String)

addHeader

public void addHeader(java.lang.String header,
                      java.lang.String value)
Adds the header value. This method will not replace existing header values.

Parameters:
header - The name of the header.
value - The value of the header to add.

getPassword

public java.lang.String getPassword()
Returns the password associated with the user. If using asserted identity header, then specify null.

Returns:
Returns the password associated with the user. If using asserted identity header, then specify null.

setPassword

public void setPassword(java.lang.String password)
Sets the password associated with the user. If using asserted identity header, then specify null.

Parameters:
password - The password associated with the user. If using asserted identity header, then specify null.

getUserName

public java.lang.String getUserName()
Returns the current user name to authenticate with.

Returns:
Returns the current user name to authenticate with.

setUserName

public void setUserName(java.lang.String userName)
Sets the current user name to authenticate with.

Parameters:
userName - The current user name to authenticate with.

send

public XcapClientResponse send()
                        throws java.io.IOException
Sends the XCAP request to the XDMS.

Returns:
Returns the XcapClientResponse.
Throws:
java.io.IOException

send

public void send(ThreadedRequestHandler requestHandler)
Send an XDMS Request via a threaded handler using the callers own thread to process the request. Catches exceptions internally and returns response objects in the response Vector with a status code equal to -1 when errors occur with requests. If the status code is equal to -1, then the XcapClientResponse.getException() will return the thrown exception that occured during the request.

See Also:
XcapClientResponse.getException()

sendAsync

public void sendAsync(ThreadedRequestHandler requestHandler)
Send an XDMS Request via a threaded handler attempting to use a thread on the threadpool to support multithreaded requests. If no thread is available in the threadpool, the handler will use the calling thread to handle the request. Catches exceptions internally and returns response objects in the response Vector with a status code equal to -1 when errors occur with requests. If the status code is equal to -1, then the XcapClientResponse.getException() will return the thrown exception that occured during the request.

See Also:
XcapClientResponse.getException()

toString

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