net.kwfgrid.gwes.restfulclient
Class RestfulClient

java.lang.Object
  extended by net.kwfgrid.gwes.restfulclient.RestfulClient
Direct Known Subclasses:
RestfulGWES

public class RestfulClient
extends Object

Class for generating REST requests.

Version:
$Id: RestfulClient.java 1529 2011-06-22 16:37:19Z hoheisel $
Author:
Andreas Hoheisel (www.andreas-hoheisel.de)

Nested Class Summary
static class RestfulClient.Method
          HTTP RESTful method.
 
Constructor Summary
RestfulClient()
           
 
Method Summary
static String getMethodAsString(RestfulClient.Method method)
          Get HTTP REST method as String.
 String[] httpDELETE(String url)
          Invoke a RESTful DELETE request and return the response as list of strings.
 String[] httpGET(String url)
          Invoke a RESTful GET request and return the response as list of strings.
 String[][] httpGETArray(String url)
          Invoke a RESTful GET request and return the response as list of strings.
 String[] httpPOST(String url, String payload)
          Invoke a RESTful POST request and return the response as list of strings.
 String[] httpPUT(String url, String payload)
          Invoke a RESTful PUT request and return the response as list of strings.
static List<String> request(URL url, RestfulClient.Method method, InputStream payload)
          Invoke a restful request and return the response as list of strings.
static List<List<String>> requestArray(URL url, RestfulClient.Method method, InputStream payload)
          Invoke a restful request and return the response as list of list of strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestfulClient

public RestfulClient()
Method Detail

httpGET

public String[] httpGET(String url)
                 throws RemoteException
Invoke a RESTful GET request and return the response as list of strings.

Parameters:
url - The target URL
Returns:
A list of Strings containing the TEXT values of the XML response message.
Throws:
RemoteException - If a parsing or IO exception of the response message occurrs.

httpGETArray

public String[][] httpGETArray(String url)
                        throws RemoteException
Invoke a RESTful GET request and return the response as list of strings.

Parameters:
url - The target URL
Returns:
A list of Strings containing the TEXT values of the XML response message.
Throws:
RemoteException - If a parsing or IO exception of the response message occurrs.

httpPUT

public String[] httpPUT(String url,
                        String payload)
                 throws RemoteException
Invoke a RESTful PUT request and return the response as list of strings.

Parameters:
url - The target URL
Returns:
A list of Strings containing the TEXT values of the XML response message.
Throws:
RemoteException - If a parsing or IO exception of the response message occurrs.

httpPOST

public String[] httpPOST(String url,
                         String payload)
                  throws RemoteException
Invoke a RESTful POST request and return the response as list of strings.

Parameters:
url - The target URL
Returns:
A list of Strings containing the TEXT values of the XML response message.
Throws:
RemoteException - If a parsing or IO exception of the response message occurs.

httpDELETE

public String[] httpDELETE(String url)
                    throws RemoteException
Invoke a RESTful DELETE request and return the response as list of strings.

Parameters:
url - The target URL
Returns:
A list of Strings containing the TEXT values of the XML response message.
Throws:
RemoteException - If a parsing or IO exception of the response message occurs.

request

public static List<String> request(URL url,
                                   RestfulClient.Method method,
                                   InputStream payload)
                            throws org.xmlpull.v1.XmlPullParserException,
                                   IOException
Invoke a restful request and return the response as list of strings.

Parameters:
url - The target URL.
method - The method (GET, PUT, ...).
payload - The payload body used with POST and PUT
Returns:
A list of Strings containing the TEXT values of the XML response message.
Throws:
IOException
org.xmlpull.v1.XmlPullParserException

requestArray

public static List<List<String>> requestArray(URL url,
                                              RestfulClient.Method method,
                                              InputStream payload)
                                       throws org.xmlpull.v1.XmlPullParserException,
                                              IOException
Invoke a restful request and return the response as list of list of strings.

Parameters:
url - The target URL.
method - The method (GET, PUT, ...).
payload - The payload body used with POST and PUT
Returns:
A list of list of Strings containing the TEXT values of the XML response message array.
Throws:
IOException
org.xmlpull.v1.XmlPullParserException

getMethodAsString

public static String getMethodAsString(RestfulClient.Method method)
Get HTTP REST method as String.

Parameters:
method - The REST method.
Returns:
A String representing the REST method, e.g., "GET", "PUT", ....


Copyright © 2005-2011 Fraunhofer FIRST. All Rights Reserved.