fr.cnes.sitools.util
Class RIAPUtils

java.lang.Object
  extended by fr.cnes.sitools.util.RIAPUtils

public final class RIAPUtils
extends java.lang.Object

Utils class for RIAP calls

Author:
m.gond (AKKA Technologies)

Method Summary
static boolean deleteObject(java.lang.String url, org.restlet.Context context)
          Delete a, object at the specified url
static
<T extends IResource>
boolean
deleteObject(T object, java.lang.String url, org.restlet.Context context)
          Delete a T object at the specified url
static void exhaust(org.restlet.representation.Representation representation)
          Exhaust representation properly
static void exhaust(org.restlet.Response response)
          Exhaust response properly
static
<T> java.util.List<T>
getListOfObjects(java.lang.String url, org.restlet.Context context)
          Get an Object of class with the specified id, at the specified url using the RIAP protocol.
static
<T> T
getObject(java.lang.String url, org.restlet.Context context)
          Get an Object of class with the specified id, at the specified url using the RIAP protocol.
static
<T> T
getObject(java.lang.String url, org.restlet.Context context, org.restlet.data.MediaType mediaType)
          Get an Object of class with the specified id, at the specified url using the RIAP protocol.
static
<T> T
getObject(java.lang.String id, java.lang.String url, org.restlet.Context context)
          Get an Object of class with the specified id, at the specified url using the RIAP protocol.
static
<T> T
getObject(java.lang.String id, java.lang.String url, org.restlet.Context context, org.restlet.data.MediaType mediaType)
          Get an Object of class with the specified id, at the specified url using the RIAP protocol.
static
<T> T
getObjectFromName(java.lang.String url, java.lang.String name, org.restlet.Context context)
          Get an Object of class with the specified name, at the specified url using the RIAP protocol.
static java.lang.String getRiapBase()
          Get the RIAP base URl
static org.restlet.representation.Representation handle(java.lang.String url, org.restlet.data.Method method, org.restlet.data.MediaType mediaType, org.restlet.Context context)
          Handle a call with the RIAP protocol without entity.
static org.restlet.representation.Representation handle(java.lang.String url, org.restlet.representation.Representation entity, org.restlet.data.Method method, org.restlet.data.MediaType mediaType, org.restlet.Context context)
          Handle a call with the RIAP protocol with entity.
static Response handleParseResponse(java.lang.String url, org.restlet.data.Method method, org.restlet.data.MediaType mediaType, org.restlet.Context context)
          Handle a call with the RIAP protocol without entity, parse the response and return a Response
static Response handleParseResponse(java.lang.String url, org.restlet.representation.Representation entity, org.restlet.data.Method method, org.restlet.data.MediaType mediaType, org.restlet.Context context)
          Handle a call with the RIAP protocol with entity , parse the response and return a Response object
static
<T extends java.io.Serializable>
T
persistObject(T object, java.lang.String url, org.restlet.Context context)
          Persist a given T object to the given url
static
<T extends java.io.Serializable>
T
updateObject(T object, java.lang.String url, org.restlet.Context context)
          Persist a given T object to the given url
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getObject

public static <T> T getObject(java.lang.String id,
                              java.lang.String url,
                              org.restlet.Context context)
Get an Object of class with the specified id, at the specified url using the RIAP protocol. The context is required in order to make an RIAP call

Type Parameters:
T - the class of the object
Parameters:
id - the id of the object
url - the url of the object
context - the context
Returns:
an object

getObject

public static <T> T getObject(java.lang.String id,
                              java.lang.String url,
                              org.restlet.Context context,
                              org.restlet.data.MediaType mediaType)
Get an Object of class with the specified id, at the specified url using the RIAP protocol. The context is required in order to make an RIAP call

Type Parameters:
T - the class of the object
Parameters:
id - the id of the object
url - the url of the object
context - the context
mediaType - the mediaType needed (Must be a Java object serialize media type)
Returns:
an object

getObject

public static <T> T getObject(java.lang.String url,
                              org.restlet.Context context)
Get an Object of class with the specified id, at the specified url using the RIAP protocol. The context is required in order to make an RIAP call

Type Parameters:
T - the class of the object
Parameters:
url - the url of the object
context - the context
Returns:
an object

getObject

public static <T> T getObject(java.lang.String url,
                              org.restlet.Context context,
                              org.restlet.data.MediaType mediaType)
Get an Object of class with the specified id, at the specified url using the RIAP protocol. The context is required in order to make an RIAP call

Type Parameters:
T - the class of the object
Parameters:
url - the url of the object
context - the context
mediaType - the mediaType needed (Must be a Java object serialize media type)
Returns:
an object

getObjectFromName

public static <T> T getObjectFromName(java.lang.String url,
                                      java.lang.String name,
                                      org.restlet.Context context)
Get an Object of class with the specified name, at the specified url using the RIAP protocol. The context is required in order to make an RIAP call Return null if there is no or multiple Object found

Type Parameters:
T - the class of the object
Parameters:
url - the url of the object
name - the name of the object
context - the context
Returns:
an object

getListOfObjects

public static <T> java.util.List<T> getListOfObjects(java.lang.String url,
                                                     org.restlet.Context context)
Get an Object of class with the specified id, at the specified url using the RIAP protocol. The context is required in order to make an RIAP call

Type Parameters:
T - the class of the object
Parameters:
url - the url of the object
context - the context
Returns:
an List object

persistObject

public static <T extends java.io.Serializable> T persistObject(T object,
                                                               java.lang.String url,
                                                               org.restlet.Context context)
Persist a given T object to the given url

Type Parameters:
T - the type of object to persist, must implements Serializable
Parameters:
object - the object to persist
url - the url
context - the Context
Returns:
the persisted object

updateObject

public static <T extends java.io.Serializable> T updateObject(T object,
                                                              java.lang.String url,
                                                              org.restlet.Context context)
Persist a given T object to the given url

Type Parameters:
T - the type of object to persist, must implements Serializable
Parameters:
object - the object to persist
url - the url
context - the Context
Returns:
the persisted object

deleteObject

public static <T extends IResource> boolean deleteObject(T object,
                                                         java.lang.String url,
                                                         org.restlet.Context context)
Delete a T object at the specified url

Type Parameters:
T - object implementing IResource
Parameters:
object - the object to delete
url - the url where to delete the object, without the object id
context - the Context
Returns:
true if the object was correctly deleted, false otherwise

deleteObject

public static boolean deleteObject(java.lang.String url,
                                   org.restlet.Context context)
Delete a, object at the specified url

Parameters:
url - the url of the object, with the id of the object
context - the Context
Returns:
true if the object was correctly deleted, false otherwise

handle

public static org.restlet.representation.Representation handle(java.lang.String url,
                                                               org.restlet.data.Method method,
                                                               org.restlet.data.MediaType mediaType,
                                                               org.restlet.Context context)
Handle a call with the RIAP protocol without entity.

Parameters:
url - the url
method - the Method to perform
mediaType - the accepted mediaType
context - the Context
Returns:
the returned Representation

handle

public static org.restlet.representation.Representation handle(java.lang.String url,
                                                               org.restlet.representation.Representation entity,
                                                               org.restlet.data.Method method,
                                                               org.restlet.data.MediaType mediaType,
                                                               org.restlet.Context context)
Handle a call with the RIAP protocol with entity.

Parameters:
url - the url
entity - the entity of the request
method - the Method to perform
mediaType - the accepted mediaType
context - the Context
Returns:
the returned Representation

handleParseResponse

public static Response handleParseResponse(java.lang.String url,
                                           org.restlet.data.Method method,
                                           org.restlet.data.MediaType mediaType,
                                           org.restlet.Context context)
Handle a call with the RIAP protocol without entity, parse the response and return a Response

Parameters:
url - the url
method - the Method to perform
mediaType - the accepted mediaType
context - the Context
Returns:
the returned Representation

handleParseResponse

public static Response handleParseResponse(java.lang.String url,
                                           org.restlet.representation.Representation entity,
                                           org.restlet.data.Method method,
                                           org.restlet.data.MediaType mediaType,
                                           org.restlet.Context context)
Handle a call with the RIAP protocol with entity , parse the response and return a Response object

Parameters:
url - the url
entity - the entity of the request
method - the Method to perform
mediaType - the accepted mediaType
context - the Context
Returns:
the returned Representation

exhaust

public static void exhaust(org.restlet.Response response)
Exhaust response properly

Parameters:
response - the response to exhaust
Throws:
java.lang.Exception

exhaust

public static void exhaust(org.restlet.representation.Representation representation)
Exhaust representation properly

Parameters:
representation - the representation to exhaust
Throws:
java.lang.Exception

getRiapBase

public static java.lang.String getRiapBase()
Get the RIAP base URl

Returns:
the RIAP base url


Copyright © 2010-2013 CNES. All Rights Reserved.