Revision 5512
Added by berkley about 14 years ago
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java | ||
---|---|---|
351 | 351 |
|
352 | 352 |
} else if (httpVerb == PUT) { |
353 | 353 |
//Earthgrid API > Identifier Service > addLSID Function |
354 |
response.setStatus(501); |
|
354 | 355 |
printError( |
355 | 356 |
"This method is not supported by metacat. To " |
356 | 357 |
+ "add a new LSID, add a document to metacat.", |
... | ... | |
368 | 369 |
else |
369 | 370 |
{ |
370 | 371 |
//change to D1 spec for specifying which http methods are allowed for a resource |
372 |
response.setStatus(501); |
|
371 | 373 |
printError("POST, PUT, DELETE is not supported for logs.", response); |
372 | 374 |
status = true; |
373 | 375 |
} |
... | ... | |
375 | 377 |
} |
376 | 378 |
|
377 | 379 |
if (!status) |
380 |
{ |
|
381 |
response.setStatus(400); |
|
378 | 382 |
printError("Incorrect parameters!", response); |
383 |
} |
|
379 | 384 |
} else { |
385 |
response.setStatus(400); |
|
380 | 386 |
printError("Incorrect resource!", response); |
381 | 387 |
} |
382 | 388 |
} catch (Exception e) { |
... | ... | |
605 | 611 |
|
606 | 612 |
} catch (Exception e) { |
607 | 613 |
// Handle exception |
614 |
response.setStatus(500); |
|
608 | 615 |
out.println("<?xml version=\"1.0\"?>"); |
609 | 616 |
out.println("<error>"); |
610 | 617 |
out.println(e.getMessage()); |
... | ... | |
959 | 966 |
e.printStackTrace(); |
960 | 967 |
}*/ |
961 | 968 |
response.setContentType("text/xml"); |
969 |
response.setStatus(501); |
|
962 | 970 |
PrintWriter out = response.getWriter(); |
963 | 971 |
out.print("<error>Query operation not yet supported by Metacat.</error>"); |
964 | 972 |
out.close(); |
... | ... | |
1209 | 1217 |
} |
1210 | 1218 |
catch(Exception e) |
1211 | 1219 |
{ |
1220 |
response.setStatus(500); |
|
1212 | 1221 |
printError("Error setting access in ResourceHandler: " + e.getMessage(), response); |
1213 | 1222 |
throw e; |
1214 | 1223 |
} |
... | ... | |
1245 | 1254 |
* */ |
1246 | 1255 |
private void printError(String message, HttpServletResponse response) { |
1247 | 1256 |
try { |
1257 |
logMetacat.error("ResourceHandler: Printing error to servlet response: " + message); |
|
1248 | 1258 |
PrintWriter out = response.getWriter(); |
1249 | 1259 |
response.setContentType("text/xml"); |
1250 | 1260 |
out.println("<?xml version=\"1.0\"?>"); |
... | ... | |
1261 | 1271 |
// TODO: Use content negotiation to determine which return format to use |
1262 | 1272 |
response.setContentType("text/xml"); |
1263 | 1273 |
response.setStatus(e.getCode()); |
1274 |
|
|
1275 |
logMetacat.error("ResourceHandler: Serializing exception with code " + e.getCode() + ": " + e.getMessage()); |
|
1276 |
e.printStackTrace(); |
|
1277 |
|
|
1264 | 1278 |
try { |
1265 | 1279 |
IOUtils.write(e.serialize(BaseException.FMT_XML), out); |
1266 | 1280 |
} catch (IOException e1) { |
Also available in: Unified diff
added better logging and http code setting