Revision 2252
Added by sgarg over 20 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
293 | 293 |
|
294 | 294 |
//if the user clicked on the input images, decode which image |
295 | 295 |
//was clicked then set the action. |
296 |
if(params.get("action") == null){ |
|
297 |
PrintWriter out = response.getWriter(); |
|
298 |
response.setContentType("text/xml"); |
|
299 |
out.println("<?xml version=\"1.0\"?>"); |
|
300 |
out.println("<error>"); |
|
301 |
out.println("Action not specified"); |
|
302 |
out.println("</error>"); |
|
303 |
out.close(); |
|
304 |
return; |
|
305 |
} |
|
306 |
|
|
296 | 307 |
String action = ((String[]) params.get("action"))[0]; |
297 | 308 |
MetaCatUtil.debugMessage("Line 230: Action is: " + action, 1); |
298 | 309 |
|
... | ... | |
426 | 437 |
handleInsertOrUpdateAction(request, response, |
427 | 438 |
out, params, username, groupnames); |
428 | 439 |
} else { |
440 |
response.setContentType("text/xml"); |
|
441 |
out.println("<?xml version=\"1.0\"?>"); |
|
442 |
out.println("<error>"); |
|
429 | 443 |
out.println("Permission denied for user " + username + " " |
430 | 444 |
+ action); |
445 |
out.println("</error>"); |
|
431 | 446 |
} |
432 | 447 |
out.close(); |
433 | 448 |
} else if (action.equals("delete")) { |
... | ... | |
436 | 451 |
handleDeleteAction(out, params, request, response, username, |
437 | 452 |
groupnames); |
438 | 453 |
} else { |
454 |
response.setContentType("text/xml"); |
|
455 |
out.println("<?xml version=\"1.0\"?>"); |
|
456 |
out.println("<error>"); |
|
439 | 457 |
out.println("Permission denied for " + action); |
458 |
out.println("</error>"); |
|
440 | 459 |
} |
441 | 460 |
out.close(); |
442 | 461 |
} else if (action.equals("validate")) { |
... | ... | |
551 | 570 |
{ |
552 | 571 |
|
553 | 572 |
AuthSession sess = null; |
573 |
|
|
574 |
if(params.get("username") == null){ |
|
575 |
response.setContentType("text/xml"); |
|
576 |
out.println("<?xml version=\"1.0\"?>"); |
|
577 |
out.println("<error>"); |
|
578 |
out.println("Username not specified"); |
|
579 |
out.println("</error>"); |
|
580 |
return; |
|
581 |
} |
|
582 |
|
|
583 |
if(params.get("password") == null){ |
|
584 |
response.setContentType("text/xml"); |
|
585 |
out.println("<?xml version=\"1.0\"?>"); |
|
586 |
out.println("<error>"); |
|
587 |
out.println("Password not specified"); |
|
588 |
out.println("</error>"); |
|
589 |
return; |
|
590 |
} |
|
591 |
|
|
554 | 592 |
String un = ((String[]) params.get("username"))[0]; |
555 | 593 |
MetaCatUtil.debugMessage("user " + un + " try to login", 20); |
556 | 594 |
String pw = ((String[]) params.get("password"))[0]; |
557 |
String action = ((String[]) params.get("action"))[0]; |
|
558 |
String qformat = ((String[]) params.get("qformat"))[0]; |
|
559 | 595 |
|
596 |
String qformat = "xml"; |
|
597 |
if(params.get("qformat") != null){ |
|
598 |
qformat = ((String[]) params.get("qformat"))[0]; |
|
599 |
} |
|
600 |
|
|
560 | 601 |
try { |
561 | 602 |
sess = new AuthSession(); |
562 | 603 |
} catch (Exception e) { |
... | ... | |
604 | 645 |
HttpServletRequest request, HttpServletResponse response) |
605 | 646 |
{ |
606 | 647 |
|
607 |
String qformat = ((String[]) params.get("qformat"))[0]; |
|
648 |
String qformat = "xml"; |
|
649 |
if(params.get("qformat") != null){ |
|
650 |
qformat = ((String[]) params.get("qformat"))[0]; |
|
651 |
} |
|
608 | 652 |
|
609 | 653 |
// close the connection |
610 | 654 |
HttpSession sess = request.getSession(false); |
... | ... | |
1426 | 1470 |
DBConnection dbConn = null; |
1427 | 1471 |
int serialNumber = -1; |
1428 | 1472 |
|
1473 |
if(params.get("docid") == null){ |
|
1474 |
out.println("<?xml version=\"1.0\"?>"); |
|
1475 |
out.println("<error>"); |
|
1476 |
out.println("Docid not specified"); |
|
1477 |
out.println("</error>"); |
|
1478 |
return; |
|
1479 |
} |
|
1480 |
|
|
1429 | 1481 |
try { |
1430 | 1482 |
// Get the document indicated |
1431 | 1483 |
String[] doctext = (String[]) params.get("doctext"); |
... | ... | |
1759 | 1811 |
response.setContentType("text/xml"); |
1760 | 1812 |
out.println("<?xml version=\"1.0\"?>"); |
1761 | 1813 |
out.println("<error>"); |
1762 |
out.println("No docid specified.");
|
|
1814 |
out.println("Docid not specified.");
|
|
1763 | 1815 |
out.println("</error>"); |
1764 | 1816 |
} else { |
1765 | 1817 |
|
Also available in: Unified diff
Code added to handle errors resulting from following urls:
http://metacat.nceas.ucsb.edu/knb/metacat?action2 - no action specified
http://metacat.nceas.ucsb.edu/knb/metacat?action=insert - no docid specified
http://metacat.nceas.ucsb.edu/knb/metacat?action=login - no username specified
http://metacat.nceas.ucsb.edu/knb/metacat?action=login&username=uid=sgarg - no password specified
http://metacat.nceas.ucsb.edu/knb/metacat?action=login&username=uid=sgarg&password=random - no qformat specified
http://metacat.nceas.ucsb.edu/knb/metacat?action=logout - no qformat specified
http://metacat.nceas.ucsb.edu/knb/metacat?action=delete with login