1
+ //
2
+ // Copyright (c) 2016 by The President and Fellows of Harvard College
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License. You may obtain a copy of the License at:
5
+ // http://www.apache.org/licenses/LICENSE-2.0
6
+ // Unless required by applicable law or agreed to in writing, software distributed under the License is
7
+ // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8
+ // See the License for the specific language governing permission and limitations under the License.
9
+ //
10
+
1
11
package edu .harvard .hul .ois .fits .service .common ;
2
12
3
13
import static javax .servlet .http .HttpServletResponse .*;
@@ -25,11 +35,11 @@ public class ErrorMessage {
25
35
26
36
public ErrorMessage () {
27
37
super ();
28
- }
29
-
38
+ }
39
+
30
40
/**
31
41
* Full constructor
32
- *
42
+ *
33
43
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html for status code and reason phrase
34
44
* @param statusCode - the http status code as a String
35
45
* @param message - the detailed error message
@@ -45,8 +55,8 @@ public ErrorMessage(int statusCode, String message, String request, String suppo
45
55
46
56
/**
47
57
* minimal constructor
48
- * This constructor sets the status to an internal error
49
- *
58
+ * This constructor sets the status to an internal error
59
+ *
50
60
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html for status code and reason phrase
51
61
* @param statusCode - the http status code as a String
52
62
* @param reasonPhrase - the http status line reasonPhrase
@@ -58,7 +68,7 @@ public ErrorMessage(String message, String request){
58
68
this .message = message ;
59
69
this .request = request ;
60
70
}
61
-
71
+
62
72
/**
63
73
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html for status code and reason phrase
64
74
* @param statusCode - the http status code as a String
@@ -72,8 +82,8 @@ public ErrorMessage(int statusCode, String message, String request){
72
82
}
73
83
74
84
/**
75
- * This constructor sets the status to an internal error
76
- *
85
+ * This constructor sets the status to an internal error
86
+ *
77
87
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html for status code and reason phrase
78
88
* @param message - the detailed error message
79
89
* @param request - the request URL
@@ -86,7 +96,7 @@ public ErrorMessage(String message, String request, String support){
86
96
this .support = support ;
87
97
}
88
98
89
-
99
+
90
100
public String getMessage () {
91
101
return message ;
92
102
}
@@ -121,16 +131,16 @@ public String getSupport() {
121
131
122
132
public void setSupport (String support ) {
123
133
this .support = support ;
124
- }
125
-
126
-
134
+ }
135
+
136
+
127
137
/**
128
138
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html
129
139
* @param statusCode
130
140
* @return
131
141
*/
132
142
public String getReasonPhrase (int statusCode ){
133
- switch (statusCode ) {
143
+ switch (statusCode ) {
134
144
case SC_CONTINUE : return "Continue" ;
135
145
case SC_SWITCHING_PROTOCOLS : return "Switching Protocols" ;
136
146
case SC_OK : return "OK" ;
@@ -174,9 +184,9 @@ public String getReasonPhrase(int statusCode){
174
184
default : return "Internal Server Error" ;
175
185
}
176
186
}
177
-
178
-
179
-
187
+
188
+
189
+
180
190
/**
181
191
* A convenience in case jaxb marshalling is not available
182
192
*/
@@ -187,17 +197,16 @@ public String toString(){
187
197
.append (statusCode )
188
198
.append ("</statusCode>" )
189
199
.append ("<message>" )
190
- .append (message != null ? message : "" )
200
+ .append (message != null ? message : "" )
191
201
.append ("</message>" )
192
202
.append ("<request>" )
193
- .append (request != null ? request : "" )
203
+ .append (request != null ? request : "" )
194
204
.append ("</request>" )
195
205
.append ("<support>" )
196
- .append ("[toString version]" + (support != null ? support : "" ))
206
+ .append ("[toString version]" + (support != null ? support : "" ))
197
207
.append ("</support>" )
198
208
.append ("</error>" );
199
209
return sb .toString ();
200
210
}
201
-
202
- }
203
211
212
+ }
0 commit comments