Skip to main content
summaryrefslogtreecommitdiffstats
blob: c424c359a016d23ed5d5ef8e53332b7818e76ba3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20070413   176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable
 *******************************************************************************/
package org.eclipse.wst.ws.internal.explorer.transport;

import java.util.Map;

/**
 * A type of TransportException that can be thrown when the transport protocol
 * is HTTP.  The status code of the HTTP response is captured in this
 * exception and passed up to the Web Services Explorer.
 */
public class HTTPTransportException extends TransportException {

	private static final long serialVersionUID = 8277180731798858877L;
	
	private int statusCode;
	private Map headers;
	
	/**
	 * Constructor.
	 * 
	 * @param statusCode The HTTP status code.
	 * @param message A message about the problem that occurred.
	 * @param headers A map of the HTTP headers.
	 */
	public HTTPTransportException(int statusCode, String message, Map headers) {
		super(message);
		this.statusCode = statusCode;
		this.headers = headers;
	}
	
	/**
	 * Returns the HTTP status code used to create this exception.
	 * 
	 * @return The HTTP status code.
	 */
	public int getStatusCode() {
		return statusCode;
	}
	
	/**
	 * Retrieve the HTTP header for the given key
	 * 
	 * @param key The key value.
	 * @return The HTTP header value for key, or null if there is no such header.
	 */
	public String getHeader(String key) {
	    Object value = headers.get(key);
	    if (value != null)
	    	return value.toString();
	    else
	    	return null;
	}
}

Back to the top