com.jalios.rest.client
Class ClientSession

java.lang.Object
  extended by com.jalios.rest.client.ClientSession
All Implemented Interfaces:
JcmsRestConstants

public class ClientSession
extends Object
implements JcmsRestConstants

Represents a HTTP client session for calling JCMS through its REST Open API.

Since:
JCMS-6.0
Author:
dissert

Field Summary
static int DEFAULT_MAX_REDIRECT
           
static int NOFOLLOWREDIRECT_MAX_REDIRECT
           
static String REVISION
           
 
Fields inherited from interface com.jalios.rest.client.JcmsRestConstants
HTTP_HEADERS, METHOD_OVERRIDE_HTTP_HEADER, UTS_ADMIN, UTS_DATA_PARAM, UTS_DATATYPE_ITEM, UTS_DATATYPE_LIST, UTS_MEMBER_ITEM, UTS_MEMBERS_LIST, UTS_SEARCH, UTS_WORKFLOWS, UTS_WORKFLOWS_ITEM
 
Constructor Summary
ClientSession(String baseUrl)
           
 
Method Summary
 RestQuery createQuery(org.restlet.data.Reference reference)
           
 RestQuery createQuery(String resourcePath)
           
 JcmsResource findResource(org.restlet.data.Reference resourceRef)
           
 String getBaseUrl()
           
 org.restlet.data.Reference getCreatedDataRef(JcmsResource response)
          When a data is created (while using createData), the URI of the new data is given in the HTTP response header "Location".
 org.restlet.data.MediaType getDefaultMediaType()
           
 JcmsResource getJcmsResource(org.restlet.data.Reference resourceRef, Authentication forcedAuthentication)
           
 JcmsResource getJcmsResource(String resourcePath, Authentication forcedAuthentication)
           
 org.restlet.data.Reference getReference(String uriPath)
           
 org.restlet.data.Request getRequest(org.restlet.data.Reference reference, org.restlet.data.Method method)
           
 String getRestPrefix()
           
 String getUserAgent()
           
 Authentication removeAuthentication()
          Removes and returns the current authentication (null if none was added).
 org.restlet.data.Response sendRequest(org.restlet.data.Reference reference, org.restlet.data.Method method, Authentication forcedAuthentication)
           
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, Authentication forcedAuthentication)
           
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, org.restlet.data.MediaType[] mediaTypes, Authentication forcedAuthentication)
           
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, org.restlet.data.MediaType[] mediaTypes, Authentication forcedAuthentication, boolean noFollowRedirect)
           
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, org.restlet.data.MediaType[] mediaTypes, Authentication forcedAuthentication, int maxRedirect)
          In the context of a client session (same cookies, same authentication), send request to the server, including authentication and managing cookies.
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, org.restlet.data.MediaType mediaType, Authentication forcedAuthentication)
           
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, org.restlet.data.MediaType mediaType, Authentication forcedAuthentication, boolean noFollowRedirect)
           
 org.restlet.data.Response sendRequest(org.restlet.data.Request request, org.restlet.data.MediaType mediaType, Authentication forcedAuthentication, int maxRedirect)
           
 void setAuthentication(Authentication authentication)
          Add an authentication to the session
 void setCookies(org.restlet.data.Request request)
          Cookies management : set cookies relative to the current client in the given request.
 void setDefaultMediaType(org.restlet.data.MediaType defaultMediaType)
           
 void setUserAgent(String userAgent)
           
 void storeCookies(org.restlet.util.Series<org.restlet.data.CookieSetting> cookiesSettings)
          Cookies management : store cookies relative to the current client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

DEFAULT_MAX_REDIRECT

public static int DEFAULT_MAX_REDIRECT

NOFOLLOWREDIRECT_MAX_REDIRECT

public static int NOFOLLOWREDIRECT_MAX_REDIRECT
Constructor Detail

ClientSession

public ClientSession(String baseUrl)
Method Detail

getDefaultMediaType

public org.restlet.data.MediaType getDefaultMediaType()

setDefaultMediaType

public void setDefaultMediaType(org.restlet.data.MediaType defaultMediaType)

setAuthentication

public void setAuthentication(Authentication authentication)
Add an authentication to the session


removeAuthentication

public Authentication removeAuthentication()
Removes and returns the current authentication (null if none was added).

Returns:
the current authentication

storeCookies

public void storeCookies(org.restlet.util.Series<org.restlet.data.CookieSetting> cookiesSettings)
Cookies management : store cookies relative to the current client. Differienciation between session and stored cookies is done with the cookie max age.

Parameters:
cookiesSettings -

setCookies

public void setCookies(org.restlet.data.Request request)
Cookies management : set cookies relative to the current client in the given request.

Parameters:
request -

getReference

public org.restlet.data.Reference getReference(String uriPath)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             org.restlet.data.MediaType[] mediaTypes,
                                             Authentication forcedAuthentication,
                                             int maxRedirect)
In the context of a client session (same cookies, same authentication), send request to the server, including authentication and managing cookies.

Parameters:
request - the request to send (without authentication and cookies)
mediaTypes - accepted media type.
maxRedirect - the number of maximum redirection made if -1, redirect is not followed
Returns:
The final response (after redirection)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             org.restlet.data.MediaType mediaType,
                                             Authentication forcedAuthentication,
                                             int maxRedirect)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             org.restlet.data.MediaType[] mediaTypes,
                                             Authentication forcedAuthentication)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             org.restlet.data.MediaType mediaType,
                                             Authentication forcedAuthentication)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             Authentication forcedAuthentication)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Reference reference,
                                             org.restlet.data.Method method,
                                             Authentication forcedAuthentication)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             org.restlet.data.MediaType[] mediaTypes,
                                             Authentication forcedAuthentication,
                                             boolean noFollowRedirect)

sendRequest

public org.restlet.data.Response sendRequest(org.restlet.data.Request request,
                                             org.restlet.data.MediaType mediaType,
                                             Authentication forcedAuthentication,
                                             boolean noFollowRedirect)

getRequest

public org.restlet.data.Request getRequest(org.restlet.data.Reference reference,
                                           org.restlet.data.Method method)

getBaseUrl

public String getBaseUrl()

getRestPrefix

public String getRestPrefix()

findResource

public JcmsResource findResource(org.restlet.data.Reference resourceRef)

getJcmsResource

public JcmsResource getJcmsResource(String resourcePath,
                                    Authentication forcedAuthentication)
                             throws RestException
Throws:
RestException

getJcmsResource

public JcmsResource getJcmsResource(org.restlet.data.Reference resourceRef,
                                    Authentication forcedAuthentication)
                             throws RestException
Throws:
RestException

createQuery

public RestQuery createQuery(String resourcePath)

createQuery

public RestQuery createQuery(org.restlet.data.Reference reference)

getCreatedDataRef

public org.restlet.data.Reference getCreatedDataRef(JcmsResource response)
When a data is created (while using createData), the URI of the new data is given in the HTTP response header "Location". This method returns the given URI encapsulated in a Reference.

Parameters:
response - the response of the the createData request
Returns:
the URI of the new data.

getUserAgent

public String getUserAgent()

setUserAgent

public void setUserAgent(String userAgent)


Copyright © 2001-2007 Jalios SA. All Rights Reserved.