Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip.xcap
Class XCapClientImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.sip.xcap.BaseHttpXCapClient
      extended by net.java.sip.communicator.impl.protocol.sip.xcap.XCapClientImpl
All Implemented Interfaces:
HttpXCapClient, PresContentClient, PresRulesClient, ResourceListsClient, XCapCapsClient, XCapClient

public class XCapClientImpl
extends BaseHttpXCapClient
implements XCapClient

XCAP client implementation.

Compliant with rfc4825, rfc4826, rfc5025 and Presence Content XDM Specification v1.0

Author:
Grigorii Balutsel

Field Summary
 
Fields inherited from class net.java.sip.communicator.impl.protocol.sip.xcap.BaseHttpXCapClient
HEADER_CONTENT_TYPE, HEADER_ETAG, HEADER_IF_NONE_MATCH, uri, userAddress, XCAP_ERROR_CONTENT_TYPE
 
Fields inherited from interface net.java.sip.communicator.impl.protocol.sip.xcap.XCapCapsClient
CONTENT_TYPE, DOCUMENT_FORMAT
 
Fields inherited from interface net.java.sip.communicator.impl.protocol.sip.xcap.ResourceListsClient
DOCUMENT_FORMAT, ELEMENT_CONTENT_TYPE, NAMESPACE, RESOURCE_LISTS_CONTENT_TYPE
 
Fields inherited from interface net.java.sip.communicator.impl.protocol.sip.xcap.PresRulesClient
CONTENT_TYPE, DOCUMENT_FORMAT, NAMESPACE
 
Fields inherited from interface net.java.sip.communicator.impl.protocol.sip.xcap.PresContentClient
CONTENT_TYPE, DOCUMENT_FORMAT, NAMESPACE
 
Constructor Summary
XCapClientImpl()
           
 
Method Summary
protected  void assertPresContentSupported()
          Utility method throwing an exception if the pres-content is not supported.
protected  void assertPresRulesSupported()
          Utility method throwing an exception if the pres-rules is not supported.
protected  void assertResourceListsSupported()
          Utility method throwing an exception if the resource-lists is not supported.
 void connect(URI uri, javax.sip.address.Address userAddress, String username, String password)
          Connects user to XCap server.
 void deletePresContent(String imageName)
          Deletes the pres-content from the server.
 void deletePresRules()
          Deletes the pres-rules from the server.
 void deleteResourceLists()
          Deletes the resource-lists from the server.
 void disconnect()
          Disconnects user from the XCAP server.
 byte[] getImage(URI imageUri)
          Gets image from the specified uri.
 ListType getList(String anchor)
          Gets the resource-lists from the server.
 ContentType getPresContent(String imageName)
          Gets the pres-content from the server.
 URI getPresContentImageUri(String imageName)
          Gets the pres-content image uri.
 RulesetType getPresRules()
          Gets the pres-rules from the server.
 ResourceListsType getResourceLists()
          Gets the resource-lists from the server.
 XCapCapsType getXCapCaps()
          Gets the xcap-caps from the server.
 boolean isPresContentSupported()
          Indicates whether or not pres-rules is supported.
 boolean isPresRulesSupported()
          Indicates whether or not pres-rules is supported.
 boolean isResourceListsSupported()
          Indicates whether or not pres-rules is supported.
 void putPresContent(ContentType content, String imageName)
          Puts the pres-content to the server.
 void putPresRules(RulesetType presRules)
          Puts the pres-rules to the server.
 void putResourceLists(ResourceListsType resourceLists)
          Puts the resource-lists to the server.
 
Methods inherited from class net.java.sip.communicator.impl.protocol.sip.xcap.BaseHttpXCapClient
assertConnected, delete, get, get, getResourceURI, getSingleHeaderValue, getTimeout, getUri, getUserName, getXCapErrorMessage, isConnected, put, setTimeout, showError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.impl.protocol.sip.xcap.HttpXCapClient
delete, get, getTimeout, getUri, getUserName, isConnected, put, setTimeout
 

Constructor Detail

XCapClientImpl

public XCapClientImpl()
Method Detail

connect

public void connect(URI uri,
                    javax.sip.address.Address userAddress,
                    String username,
                    String password)
             throws XCapException
Connects user to XCap server. Loads xcap-caps server capabilities and anaylyze if resource-lists, pres-rules, pres-content is supported.

Specified by:
connect in interface HttpXCapClient
Overrides:
connect in class BaseHttpXCapClient
Parameters:
uri - the server location.
userAddress - the URI of the user used for requests
username - the user name.
password - the user password.
Throws:
XCapException - if there is some error during operation.

disconnect

public void disconnect()
Disconnects user from the XCAP server.

Specified by:
disconnect in interface HttpXCapClient
Overrides:
disconnect in class BaseHttpXCapClient

putResourceLists

public void putResourceLists(ResourceListsType resourceLists)
                      throws XCapException
Puts the resource-lists to the server.

Specified by:
putResourceLists in interface ResourceListsClient
Parameters:
resourceLists - the resource-lists to be saved on the server.
Throws:
IllegalStateException - if the user has not been connected, or resource-lists is not supported.
XCapException - if there is some error during operation.

getResourceLists

public ResourceListsType getResourceLists()
                                   throws XCapException
Gets the resource-lists from the server.

Specified by:
getResourceLists in interface ResourceListsClient
Returns:
the resource-lists.
Throws:
IllegalStateException - if the user has not been connected, or resource-lists is not supported.
XCapException - if there is some error during operation.

deleteResourceLists

public void deleteResourceLists()
                         throws XCapException
Deletes the resource-lists from the server.

Specified by:
deleteResourceLists in interface ResourceListsClient
Throws:
IllegalStateException - if the user has not been connected, or resource-lists is not supported.
XCapException - if there is some error during operation.

getList

public ListType getList(String anchor)
                 throws XCapException
Gets the resource-lists from the server.

Specified by:
getList in interface ResourceListsClient
Parameters:
anchor - reference to the list.
Returns:
the list.
Throws:
IllegalStateException - if the user has not been connected, or resource-lists is not supported.
XCapException - if there is some error during operation.

getXCapCaps

public XCapCapsType getXCapCaps()
                         throws XCapException
Gets the xcap-caps from the server.

Specified by:
getXCapCaps in interface XCapCapsClient
Returns:
the xcap-caps.
Throws:
IllegalStateException - if the user has not been connected.
XCapException - if there is some error during operation.

getPresRules

public RulesetType getPresRules()
                         throws XCapException
Gets the pres-rules from the server.

Specified by:
getPresRules in interface PresRulesClient
Returns:
the pres-rules.
Throws:
IllegalStateException - if the user has not been connected, or pres-rules is not supported.
XCapException - if there is some error during operation.

putPresRules

public void putPresRules(RulesetType presRules)
                  throws XCapException
Puts the pres-rules to the server.

Specified by:
putPresRules in interface PresRulesClient
Parameters:
presRules - the pres-rules to be saved on the server.
Throws:
IllegalStateException - if the user has not been connected, or pres-rules is not supported.
XCapException - if there is some error during operation.

deletePresRules

public void deletePresRules()
                     throws XCapException
Deletes the pres-rules from the server.

Specified by:
deletePresRules in interface PresRulesClient
Throws:
IllegalStateException - if the user has not been connected, or pres-rules is not supported.
XCapException - if there is some error during operation.

putPresContent

public void putPresContent(ContentType content,
                           String imageName)
                    throws XCapException
Puts the pres-content to the server.

Specified by:
putPresContent in interface PresContentClient
Parameters:
content - the pres-content to be saved on the server.
imageName - the image name under which pres-content would be saved.
Throws:
IllegalStateException - if the user has not been connected, or pres-content is not supported.
XCapException - if there is some error during operation.

getPresContent

public ContentType getPresContent(String imageName)
                           throws XCapException
Gets the pres-content from the server.

Specified by:
getPresContent in interface PresContentClient
Parameters:
imageName - the image name under which pres-content is saved.
Returns:
the pres-content or null if there is no pres-content on the server.
Throws:
IllegalStateException - if the user has not been connected, or pres-content is not supported.
XCapException - if there is some error during operation.

deletePresContent

public void deletePresContent(String imageName)
                       throws XCapException
Deletes the pres-content from the server.

Specified by:
deletePresContent in interface PresContentClient
Parameters:
imageName - the image name under which pres-content is saved.
Throws:
IllegalStateException - if the user has not been connected, or pres-content is not supported.
XCapException - if there is some error during operation.

getPresContentImageUri

public URI getPresContentImageUri(String imageName)
Gets the pres-content image uri.

Specified by:
getPresContentImageUri in interface PresContentClient
Parameters:
imageName - the image name under which pres-content is saved.
Returns:
the pres-content image uri.
Throws:
IllegalStateException - if the user has not been connected.

getImage

public byte[] getImage(URI imageUri)
                throws XCapException
Gets image from the specified uri.

Specified by:
getImage in interface PresContentClient
Parameters:
imageUri - the image uri.
Returns:
the image.
Throws:
XCapException - if there is some error during operation.

assertResourceListsSupported

protected void assertResourceListsSupported()
Utility method throwing an exception if the resource-lists is not supported.

Throws:
IllegalStateException - if the user is not connected.

assertPresRulesSupported

protected void assertPresRulesSupported()
Utility method throwing an exception if the pres-rules is not supported.

Throws:
IllegalStateException - if the user is not connected.

assertPresContentSupported

protected void assertPresContentSupported()
Utility method throwing an exception if the pres-content is not supported.

Throws:
IllegalStateException - if the user is not connected.

isResourceListsSupported

public boolean isResourceListsSupported()
Indicates whether or not pres-rules is supported.

Specified by:
isResourceListsSupported in interface XCapClient
Returns:
true if resource-lists is supported.

isPresRulesSupported

public boolean isPresRulesSupported()
Indicates whether or not pres-rules is supported.

Specified by:
isPresRulesSupported in interface XCapClient
Returns:
true if pres-rules is supported.

isPresContentSupported

public boolean isPresContentSupported()
Indicates whether or not pres-rules is supported.

Specified by:
isPresContentSupported in interface XCapClient
Returns:
true if pres-content is supported.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.