deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.framework.util
Class HttpUtils

java.lang.Object
  extended by org.deegree.framework.util.HttpUtils

public class HttpUtils
extends java.lang.Object

utility class for performing HTTP requests

Author:
Andreas Poth, last edited by: $Author: apoth $

Constructor Summary
HttpUtils()
           
 
Method Summary
static java.lang.String addAuthenticationForKVP(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String sessionID)
           
static XMLFragment addAuthenticationForXML(XMLFragment xml, java.lang.String user, java.lang.String password, java.lang.String sessionID)
           
static java.lang.String normalizeURL(java.lang.String url)
           
static java.lang.String normalizeURL(java.net.URL url)
           
static org.apache.commons.httpclient.HttpMethod performHttpGet(java.lang.String url, java.lang.String request, int timeout, java.lang.String user, java.lang.String password, java.util.Map<java.lang.String,java.lang.String> header)
           
static org.apache.commons.httpclient.HttpMethod performHttpPost(java.lang.String url, java.io.InputStream content, int timeout, java.lang.String user, java.lang.String password, java.lang.String contentType, java.lang.String encoding, java.util.Map<java.lang.String,java.lang.String> header)
           
static org.apache.commons.httpclient.HttpMethod performHttpPost(java.lang.String url, java.lang.String content, int timeout, java.lang.String user, java.lang.String password, java.lang.String contentType, java.lang.String encoding, java.util.Map<java.lang.String,java.lang.String> header)
           
static org.apache.commons.httpclient.HttpMethod performHttpPost(java.lang.String url, XMLFragment content, int timeout, java.lang.String user, java.lang.String password, java.util.Map<java.lang.String,java.lang.String> header)
           
static int validateURL(java.lang.String url)
          validates passed URL.
static int validateURL(java.lang.String url, java.lang.String user, java.lang.String password)
          validates passed URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUtils

public HttpUtils()
Method Detail

validateURL

public static int validateURL(java.lang.String url)
                       throws java.io.IOException
validates passed URL. If it is not a valid URL or a client can not connect to it an exception will be thrown

Parameters:
url -
Throws:
java.io.IOException

validateURL

public static int validateURL(java.lang.String url,
                              java.lang.String user,
                              java.lang.String password)
                       throws java.io.IOException
validates passed URL. If it is not a valid URL or a client can not connect to it an exception will be thrown

Parameters:
url -
user -
password -
Throws:
java.io.IOException

performHttpPost

public static org.apache.commons.httpclient.HttpMethod performHttpPost(java.lang.String url,
                                                                       java.io.InputStream content,
                                                                       int timeout,
                                                                       java.lang.String user,
                                                                       java.lang.String password,
                                                                       java.lang.String contentType,
                                                                       java.lang.String encoding,
                                                                       java.util.Map<java.lang.String,java.lang.String> header)
                                                                throws org.apache.commons.httpclient.HttpException,
                                                                       java.io.IOException
Parameters:
url -
content -
timeout - timeout in milliseconds
user - (can be null)
password - (can be null)
contentType - request content mime type (can be null)
encoding - request encoding (can be null)
header -
Returns:
result of http post request
Throws:
org.apache.commons.httpclient.HttpException
java.io.IOException

performHttpPost

public static org.apache.commons.httpclient.HttpMethod performHttpPost(java.lang.String url,
                                                                       java.lang.String content,
                                                                       int timeout,
                                                                       java.lang.String user,
                                                                       java.lang.String password,
                                                                       java.lang.String contentType,
                                                                       java.lang.String encoding,
                                                                       java.util.Map<java.lang.String,java.lang.String> header)
                                                                throws org.apache.commons.httpclient.HttpException,
                                                                       java.io.IOException
Parameters:
url -
content -
timeout - timeout in milliseconds
user - (can null)
password - (can null)
contentType - request content mime type (can be null)
encoding - request encoding (can be null)
header -
Returns:
result of http post request
Throws:
org.apache.commons.httpclient.HttpException
java.io.IOException

performHttpPost

public static org.apache.commons.httpclient.HttpMethod performHttpPost(java.lang.String url,
                                                                       XMLFragment content,
                                                                       int timeout,
                                                                       java.lang.String user,
                                                                       java.lang.String password,
                                                                       java.util.Map<java.lang.String,java.lang.String> header)
                                                                throws org.apache.commons.httpclient.HttpException,
                                                                       java.io.IOException
Parameters:
url -
content -
timeout - timeout in milliseconds
user - (can null)
password - (can null)
header -
Returns:
result of http post request
Throws:
org.apache.commons.httpclient.HttpException
java.io.IOException

performHttpGet

public static org.apache.commons.httpclient.HttpMethod performHttpGet(java.lang.String url,
                                                                      java.lang.String request,
                                                                      int timeout,
                                                                      java.lang.String user,
                                                                      java.lang.String password,
                                                                      java.util.Map<java.lang.String,java.lang.String> header)
                                                               throws org.apache.commons.httpclient.HttpException,
                                                                      java.io.IOException
Parameters:
url - e.g. http://localhost:8080/deegree/services
request - e.g. service=WMS&request=GetCapabilities
timeout - timeout in milliseconds
user - (can be null)
password - (can be null)
header -
Returns:
result of http get request
Throws:
org.apache.commons.httpclient.HttpException
java.io.IOException

addAuthenticationForKVP

public static java.lang.String addAuthenticationForKVP(java.lang.String url,
                                                       java.lang.String user,
                                                       java.lang.String password,
                                                       java.lang.String sessionID)
Parameters:
url -
user -
password -
sessionID -
Returns:
URL with attached authentication information (if not null)

addAuthenticationForXML

public static XMLFragment addAuthenticationForXML(XMLFragment xml,
                                                  java.lang.String user,
                                                  java.lang.String password,
                                                  java.lang.String sessionID)
Parameters:
xml -
user -
password -
sessionID -
Returns:
XML document with authentication information (if not null) as attributes of the root element

normalizeURL

public static java.lang.String normalizeURL(java.net.URL url)
Parameters:
url -
Returns:
URL as String with protocol and path but without request params
Throws:
java.net.URISyntaxException

normalizeURL

public static java.lang.String normalizeURL(java.lang.String url)
Parameters:
url -
Returns:
URL as String with protocol and path but without request params
Throws:
java.net.URISyntaxException

deegree 2.5 (2011/06/29 09:44 build-8-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org