public abstract class BaseHttpXCapClient extends java.lang.Object implements HttpXCapClient
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HEADER_CONTENT_TYPE
HTTP Content-Type header.
|
static java.lang.String |
HEADER_ETAG
HTTP ETag header.
|
static java.lang.String |
HEADER_IF_NONE_MATCH
HTTP If-None-Match header.
|
protected java.net.URI |
uri
Current server uri.
|
protected javax.sip.address.Address |
userAddress
Current user.
|
static java.lang.String |
XCAP_ERROR_CONTENT_TYPE
XCap-error content type.
|
Constructor and Description |
---|
BaseHttpXCapClient()
Creates an instance of this XCAP client.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertConnected()
Utility method throwing an exception if the user is not connected.
|
void |
connect(java.net.URI uri,
javax.sip.address.Address userAddress,
java.lang.String username,
java.lang.String password)
Connects user to XCap server.
|
XCapHttpResponse |
delete(XCapResourceId resourceId)
Deletes the resource from the server.
|
void |
disconnect()
Disconnects user from the XCAP server.
|
protected XCapHttpResponse |
get(java.net.URI uri)
Gets resource from the server.
|
XCapHttpResponse |
get(XCapResourceId resourceId)
Gets the resource from the server.
|
protected java.net.URI |
getResourceURI(XCapResourceId resourceId)
Gets resource uri from XCAP resource identifier.
|
protected static java.lang.String |
getSingleHeaderValue(org.apache.http.HttpResponse response,
java.lang.String headerName)
Gets HTTP header value.
|
java.net.URI |
getUri()
Gets server uri.
|
java.lang.String |
getUserName()
Gets user name.
|
protected java.lang.String |
getXCapErrorMessage(XCapHttpResponse response)
Analyzes the response and returns xcap error or null
if response doesn't have it.
|
boolean |
isConnected()
Checks if user is connected to the XCAP server.
|
XCapHttpResponse |
put(XCapResource resource)
Puts the resource to the server.
|
(package private) static void |
showError(java.lang.Exception ex,
java.lang.String title,
java.lang.String message)
Shows an error and a short description.
|
public static final java.lang.String HEADER_CONTENT_TYPE
public static final java.lang.String HEADER_ETAG
public static final java.lang.String HEADER_IF_NONE_MATCH
public static final java.lang.String XCAP_ERROR_CONTENT_TYPE
protected java.net.URI uri
protected javax.sip.address.Address userAddress
public BaseHttpXCapClient()
public void connect(java.net.URI uri, javax.sip.address.Address userAddress, java.lang.String username, java.lang.String password) throws XCapException
connect
in interface HttpXCapClient
uri
- the server location.userAddress
- the URI of the user used for requestsusername
- the user name.password
- the user password.XCapException
- if there is some error during operation.public boolean isConnected()
isConnected
in interface HttpXCapClient
public void disconnect()
disconnect
in interface HttpXCapClient
public XCapHttpResponse get(XCapResourceId resourceId) throws XCapException
get
in interface HttpXCapClient
resourceId
- resource identifier.java.lang.IllegalStateException
- if the user has not been connected.XCapException
- if there is some error during operation.protected XCapHttpResponse get(java.net.URI uri) throws XCapException
uri
- the resource uri.XCapException
- if there is error during reading the resource's
content.static void showError(java.lang.Exception ex, java.lang.String title, java.lang.String message)
ex
- the exceptionpublic XCapHttpResponse put(XCapResource resource) throws XCapException
put
in interface HttpXCapClient
resource
- the resource to be saved on the server.java.lang.IllegalStateException
- if the user has not been connected.XCapException
- if there is some error during operation.public XCapHttpResponse delete(XCapResourceId resourceId) throws XCapException
delete
in interface HttpXCapClient
resourceId
- resource identifier.java.lang.IllegalStateException
- if the user has not been connected.XCapException
- if there is some error during operation.public java.lang.String getUserName()
getUserName
in interface HttpXCapClient
public java.net.URI getUri()
getUri
in interface HttpXCapClient
protected void assertConnected()
java.lang.IllegalStateException
- if the user is not connected.protected java.net.URI getResourceURI(XCapResourceId resourceId)
resourceId
- the resource identifier.protected static java.lang.String getSingleHeaderValue(org.apache.http.HttpResponse response, java.lang.String headerName)
response
- the HTTP response.headerName
- the header name.protected java.lang.String getXCapErrorMessage(XCapHttpResponse response)
response
- the server response.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.