es.ucm.look.data.remote.restful
Class RestMethod

java.lang.Object
  extended by es.ucm.look.data.remote.restful.RestMethod

public class RestMethod
extends java.lang.Object

Class to connect directly with the Server


Constructor Summary
RestMethod()
           
 
Method Summary
static java.lang.String decodeResponse(HttpResponse response)
          Translate the response server to an String
static void doDelete(java.lang.String url)
          Delete a resource in the server
static JSONObject doGet(java.lang.String url)
          Retrieve a resource from the server
static HttpResponse doPost(java.lang.String url, JSONObject c)
          Used to insert an element
static HttpResponse doPut(java.lang.String url, JSONObject c)
          To Update an element
static int getLastId()
          To know the 'number' of last id inserted in the Server
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestMethod

public RestMethod()
Method Detail

decodeResponse

public static java.lang.String decodeResponse(HttpResponse response)
Translate the response server to an String

Parameters:
response - Response of the server
Returns:
A string with the response

doDelete

public static void doDelete(java.lang.String url)
                     throws ClientProtocolException,
                            java.io.IOException
Delete a resource in the server

Parameters:
url - Element URI
Throws:
ClientProtocolException
java.io.IOException

doGet

public static JSONObject doGet(java.lang.String url)
Retrieve a resource from the server

Parameters:
url - Element URI to get
Returns:
The Element as JSON

doPost

public static HttpResponse doPost(java.lang.String url,
                                  JSONObject c)
Used to insert an element

Parameters:
url - Element URI
c - The element represented with a JSON
Returns:
The response

doPut

public static HttpResponse doPut(java.lang.String url,
                                 JSONObject c)
To Update an element

Parameters:
url - Element URI
c - The element to update represented with a JSON
Returns:
The response

getLastId

public static int getLastId()
To know the 'number' of last id inserted in the Server

Returns: