Project

General

Profile

« Previous | Next » 

Revision 2720ea2c

Added by Andreas Müller over 3 years ago

cleanup

View differences:

cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/UriUtils.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.common;
11 10

  
12 11
import java.io.File;
......
58 57
/**
59 58
 * @author n.hoffmann
60 59
 * @since Sep 23, 2010
61
 * @version 1.0
62 60
 */
63 61
public class UriUtils {
64 62
    private static final Logger logger = Logger.getLogger(UriUtils.class);
65 63

  
66 64
    protected static final String URI_IS_NOT_ABSOLUTE = "URI is not absolute (protocol is missing)";
67 65

  
68

  
69 66
    public enum HttpMethod{
70 67
        GET,
71 68
        POST
......
73 70

  
74 71
    /**
75 72
     * see {@link #getInputStream(URI, Map)}
76
     *
77
     * @param uri
78
     * @return
79
     * @throws IOException
80
     * @throws HttpException
81 73
     */
82 74
    public static InputStream getInputStream(URI uri) throws IOException, HttpException{
83 75
        return getInputStream(uri, null);
......
85 77

  
86 78
    /**
87 79
     * Retrieves an {@link InputStream input stream} of the resource located at the given uri.
88
     *
89
     * @param uri
90
     * @return
91
     * @throws IOException
92
     * @throws HttpException
93 80
     */
94 81
    public static InputStream getInputStream(URI uri, Map<String, String> requestHeaders) throws IOException, HttpException{
95 82

  
......
226 213
     */
227 214
    public static HttpResponse getResponseByType(URI uri, Map<String, String> requestHeaders, HttpMethod httpMethod, HttpEntity entity) throws IOException, ClientProtocolException {
228 215
        // Create an instance of HttpClient.
229
        HttpClient  client = new DefaultHttpClient();
216
        HttpClient client = new DefaultHttpClient();
230 217

  
231 218
        try {
232 219
            SSLContext sc = SSLContext.getInstance("SSL");
......
240 227
            throw new RuntimeException("Registration of ssl support failed", e2);
241 228
        }
242 229

  
243

  
244 230
        HttpUriRequest method;
245 231
        switch (httpMethod) {
246 232
        case GET:
......
267 253

  
268 254
        //TODO  method.setFollowRedirects(followRedirects);
269 255

  
270
        logger.debug("sending "+httpMethod+" request: " + uri);
256
        if (logger.isDebugEnabled()){logger.debug("sending "+httpMethod+" request: " + uri);}
271 257

  
272 258
        return client.execute(method);
273 259
    }
......
295 281
        }
296 282

  
297 283
        if(qparams == null){
298
            qparams = new ArrayList<NameValuePair>(0);
284
            qparams = new ArrayList<>(0);
299 285
        }
300 286
        String query = null;
301 287
        if(! qparams.isEmpty()){

Also available in: Unified diff