org.gcube.contentmanagement.graphtools.utils
Class HttpRequest

java.lang.Object
  extended by org.gcube.contentmanagement.graphtools.utils.HttpRequest

public class HttpRequest
extends Object


Constructor Summary
HttpRequest()
           
 
Method Summary
static String AddCDATA(String phrase)
           
static int checkUrl(String url, String username, String password)
           
static Object getJSonData(String endpoint, String requestParameters, Type outputClass)
           
static void main(String[] args)
           
static String ManageCDATA(String phrase)
           
static void postData(Reader data, URL endpoint, Writer output)
          Reads data from the data reader and posts it to a server via POST request. data - The data you want to send endpoint - The server's address output - writes the server's response to output
static Object postJSonData(String endpoint, Object obj, Type outputClass)
           
static String sendGetRequest(String endpoint, String requestParameters)
          Sends an HTTP GET request to a url
static String sendPostRequest(String endpoint, String requestParameters)
           
static String toJSon(Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequest

public HttpRequest()
Method Detail

sendGetRequest

public static String sendGetRequest(String endpoint,
                                    String requestParameters)
Sends an HTTP GET request to a url

Parameters:
endpoint - - The URL of the server. (Example: " http://www.yahoo.com/search")
requestParameters - - all the request parameters (Example: "param1=val1¶m2=val2"). Note: This method will add the question mark (?) to the request - DO NOT add it yourself
Returns:
- The response from the end point

postData

public static void postData(Reader data,
                            URL endpoint,
                            Writer output)
                     throws Exception
Reads data from the data reader and posts it to a server via POST request. data - The data you want to send endpoint - The server's address output - writes the server's response to output

Throws:
Exception

getJSonData

public static Object getJSonData(String endpoint,
                                 String requestParameters,
                                 Type outputClass)
                          throws Exception
Throws:
Exception

toJSon

public static String toJSon(Object obj)

postJSonData

public static Object postJSonData(String endpoint,
                                  Object obj,
                                  Type outputClass)
                           throws Exception
Throws:
Exception

sendPostRequest

public static String sendPostRequest(String endpoint,
                                     String requestParameters)

ManageCDATA

public static String ManageCDATA(String phrase)

AddCDATA

public static String AddCDATA(String phrase)

checkUrl

public static int checkUrl(String url,
                           String username,
                           String password)

main

public static void main(String[] args)


Copyright © 2013. All Rights Reserved.