Revision 6048
Added by Chris Jones over 13 years ago
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
274 | 274 |
String username, String[] groupnames, |
275 | 275 |
String sess_id) throws PropertyNotFoundException, HandlerException { |
276 | 276 |
|
277 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
277 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
278 | 278 |
|
279 | 279 |
if ( !PropertyService.getProperty("spatial.runSpatialOption").equals("true") ) { |
280 | 280 |
response.setContentType("text/html"); |
... | ... | |
326 | 326 |
} catch (java.lang.NullPointerException e) { |
327 | 327 |
// should be "default" but keep this for backwards compatibility |
328 | 328 |
// with knp site |
329 |
logMetacat.warn("MetaCatServlet.handleSpatialQuery - No SKIN specified for metacat actions=spatial_query... defaulting to 'knp' skin !\n");
|
|
329 |
logMetacat.warn("MetacatHandler.handleSpatialQuery - No SKIN specified for metacat actions=spatial_query... defaulting to 'knp' skin !\n");
|
|
330 | 330 |
qformatArray[0] = "knp"; |
331 | 331 |
} |
332 | 332 |
params.put("qformat", qformatArray); |
... | ... | |
357 | 357 |
*/ |
358 | 358 |
public void handleLoginAction(PrintWriter out, Hashtable<String, String[]> params, |
359 | 359 |
HttpServletRequest request, HttpServletResponse response) { |
360 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
360 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
361 | 361 |
AuthSession sess = null; |
362 | 362 |
|
363 | 363 |
if(params.get("username") == null){ |
... | ... | |
381 | 381 |
} |
382 | 382 |
|
383 | 383 |
String un = (params.get("username"))[0]; |
384 |
logMetacat.info("MetaCatServlet.handleLoginAction - user " + un + " is trying to login");
|
|
384 |
logMetacat.info("MetacatHandler.handleLoginAction - user " + un + " is trying to login");
|
|
385 | 385 |
String pw = (params.get("password"))[0]; |
386 | 386 |
|
387 | 387 |
String qformat = "xml"; |
... | ... | |
406 | 406 |
HttpSession session = sess.getSessions(); |
407 | 407 |
String id = session.getId(); |
408 | 408 |
|
409 |
logMetacat.debug("MetaCatServlet.handleLoginAction - Store session id " + id
|
|
409 |
logMetacat.debug("MetacatHandler.handleLoginAction - Store session id " + id
|
|
410 | 410 |
+ " which has username" + session.getAttribute("username") |
411 | 411 |
+ " into hash in login method"); |
412 | 412 |
try { |
... | ... | |
422 | 422 |
} catch (ServiceException se) { |
423 | 423 |
String errorMsg = "MetacatServlet.handleLoginAction - service problem registering session: " |
424 | 424 |
+ se.getMessage(); |
425 |
logMetacat.error("MetaCatServlet.handleLoginAction - " + errorMsg);
|
|
425 |
logMetacat.error("MetacatHandler.handleLoginAction - " + errorMsg);
|
|
426 | 426 |
out.println(errorMsg); |
427 | 427 |
se.printStackTrace(System.out); |
428 | 428 |
return; |
... | ... | |
441 | 441 |
"-//NCEAS//login//EN", "-//W3C//HTML//EN", qformat, |
442 | 442 |
out, null, null); |
443 | 443 |
} catch (Exception e) { |
444 |
logMetacat.error("MetaCatServlet.handleLoginAction - General error"
|
|
444 |
logMetacat.error("MetacatHandler.handleLoginAction - General error"
|
|
445 | 445 |
+ e.getMessage()); |
446 | 446 |
e.printStackTrace(System.out); |
447 | 447 |
} |
... | ... | |
453 | 453 |
*/ |
454 | 454 |
public void handleLogoutAction(PrintWriter out, Hashtable<String, String[]> params, |
455 | 455 |
HttpServletRequest request, HttpServletResponse response) { |
456 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
456 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
457 | 457 |
String qformat = "xml"; |
458 | 458 |
if(params.get("qformat") != null){ |
459 | 459 |
qformat = params.get("qformat")[0]; |
... | ... | |
461 | 461 |
|
462 | 462 |
// close the connection |
463 | 463 |
HttpSession sess = request.getSession(false); |
464 |
logMetacat.info("MetaCatServlet.handleLogoutAction - After get session in logout request");
|
|
464 |
logMetacat.info("MetacatHandler.handleLogoutAction - After get session in logout request");
|
|
465 | 465 |
if (sess != null) { |
466 |
logMetacat.info("MetaCatServlet.handleLogoutAction - The session id " + sess.getId()
|
|
466 |
logMetacat.info("MetacatHandler.handleLogoutAction - The session id " + sess.getId()
|
|
467 | 467 |
+ " will be invalidate in logout action"); |
468 |
logMetacat.info("MetaCatServlet.handleLogoutAction - The session contains user "
|
|
468 |
logMetacat.info("MetacatHandler.handleLogoutAction - The session contains user "
|
|
469 | 469 |
+ sess.getAttribute("username") |
470 | 470 |
+ " will be invalidate in logout action"); |
471 | 471 |
sess.invalidate(); |
... | ... | |
492 | 492 |
out, null, null); |
493 | 493 |
} catch (Exception e) { |
494 | 494 |
logMetacat.error( |
495 |
"MetaCatServlet.handleLogoutAction - General error: "
|
|
495 |
"MetacatHandler.handleLogoutAction - General error: "
|
|
496 | 496 |
+ e.getMessage()); |
497 | 497 |
e.printStackTrace(System.out); |
498 | 498 |
} |
... | ... | |
514 | 514 |
protected void handleSQuery(Writer out, Hashtable<String, String[]> params, |
515 | 515 |
HttpServletResponse response, String user, String[] groups, |
516 | 516 |
String sessionid) throws PropertyNotFoundException { |
517 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
517 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
518 | 518 |
long squeryWarnLimit = Long.parseLong(PropertyService.getProperty("database.squeryTimeWarnLimit")); |
519 | 519 |
|
520 | 520 |
long startTime = System.currentTimeMillis(); |
... | ... | |
524 | 524 |
long runTime = outPutTime - startTime; |
525 | 525 |
|
526 | 526 |
if (runTime > squeryWarnLimit) { |
527 |
logMetacat.warn("MetaCatServlet.handleSQuery - Long running squery. Total time: " + runTime +
|
|
527 |
logMetacat.warn("MetacatHandler.handleSQuery - Long running squery. Total time: " + runTime +
|
|
528 | 528 |
" ms, squery: " + ((String[])params.get("query"))[0]); |
529 | 529 |
} |
530 |
logMetacat.debug("MetaCatServlet.handleSQuery - squery: " + ((String[])params.get("query"))[0] +
|
|
530 |
logMetacat.debug("MetacatHandler.handleSQuery - squery: " + ((String[])params.get("query"))[0] +
|
|
531 | 531 |
" ran in " + runTime + " ms"); |
532 | 532 |
} |
533 | 533 |
|
... | ... | |
544 | 544 |
protected void handleQuery(Writer out, Hashtable<String, String[]> params, |
545 | 545 |
HttpServletResponse response, String user, String[] groups, |
546 | 546 |
String sessionid) throws PropertyNotFoundException, UnsupportedEncodingException, IOException { |
547 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
547 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
548 | 548 |
long queryWarnLimit = Long.parseLong(PropertyService.getProperty("database.queryTimeWarnLimit")); |
549 | 549 |
|
550 | 550 |
//create the query and run it |
... | ... | |
559 | 559 |
long runTime = outPutTime -startTime; |
560 | 560 |
|
561 | 561 |
if (runTime > queryWarnLimit) { |
562 |
logMetacat.warn("MetaCatServlet.handleQuery - Long running squery. Total time: " + runTime +
|
|
562 |
logMetacat.warn("MetacatHandler.handleQuery - Long running squery. Total time: " + runTime +
|
|
563 | 563 |
" ms, squery: " + ((String[])params.get("query"))[0]); |
564 | 564 |
} |
565 |
logMetacat.debug("MetaCatServlet.handleQuery - query: " + ((String[])params.get("query"))[0] +
|
|
565 |
logMetacat.debug("MetacatHandler.handleQuery - query: " + ((String[])params.get("query"))[0] +
|
|
566 | 566 |
" ran in " + runTime + " ms"); |
567 | 567 |
} |
568 | 568 |
|
... | ... | |
580 | 580 |
protected void handleExportAction(Hashtable<String, String[]> params, |
581 | 581 |
HttpServletResponse response, |
582 | 582 |
String user, String[] groups, String passWord) { |
583 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
583 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
584 | 584 |
// Output stream |
585 | 585 |
ServletOutputStream out = null; |
586 | 586 |
// Zip output stream |
... | ... | |
646 | 646 |
zOut.close(); |
647 | 647 |
} |
648 | 648 |
} catch (IOException ioe) { |
649 |
logMetacat.error("MetaCatServlet.handleExportAction - Problem with the servlet output: "
|
|
649 |
logMetacat.error("MetacatHandler.handleExportAction - Problem with the servlet output: "
|
|
650 | 650 |
+ ioe.getMessage()); |
651 | 651 |
e.printStackTrace(System.out); |
652 | 652 |
} |
653 | 653 |
|
654 |
logMetacat.error("MetaCatServlet.handleExportAction - General error: "
|
|
654 |
logMetacat.error("MetacatHandler.handleExportAction - General error: "
|
|
655 | 655 |
+ e.getMessage()); |
656 | 656 |
e.printStackTrace(System.out); |
657 | 657 |
|
... | ... | |
672 | 672 |
protected void handleReadInlineDataAction(Hashtable<String, String[]> params, |
673 | 673 |
HttpServletRequest request, HttpServletResponse response, |
674 | 674 |
String user, String passWord, String[] groups) { |
675 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
675 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
676 | 676 |
String[] docs = new String[10]; |
677 | 677 |
String inlineDataId = null; |
678 | 678 |
String docId = ""; |
... | ... | |
754 | 754 |
out.close(); |
755 | 755 |
} |
756 | 756 |
} catch (IOException ioe) { |
757 |
logMetacat.error("MetaCatServlet.handleReadInlineDataAction - Problem with the servlet output: "
|
|
757 |
logMetacat.error("MetacatHandler.handleReadInlineDataAction - Problem with the servlet output: "
|
|
758 | 758 |
+ ioe.getMessage()); |
759 | 759 |
e.printStackTrace(System.out); |
760 | 760 |
} |
761 |
logMetacat.error("MetaCatServlet.handleReadInlineDataAction - General error: "
|
|
761 |
logMetacat.error("MetacatHandler.handleReadInlineDataAction - General error: "
|
|
762 | 762 |
+ e.getMessage()); |
763 | 763 |
e.printStackTrace(System.out); |
764 | 764 |
} |
... | ... | |
778 | 778 |
public void handleReadAction(Hashtable<String, String[]> params, HttpServletRequest request, |
779 | 779 |
HttpServletResponse response, String user, String passWord, |
780 | 780 |
String[] groups) { |
781 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
781 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
782 | 782 |
ServletOutputStream out = null; |
783 | 783 |
ZipOutputStream zout = null; |
784 | 784 |
PrintWriter pw = null; |
... | ... | |
869 | 869 |
// the docid which didn't be found |
870 | 870 |
String notFoundDocId = notFoundE.getUnfoundDocId(); |
871 | 871 |
String notFoundRevision = notFoundE.getUnfoundRevision(); |
872 |
logMetacat.warn("MetaCatServlet.handleReadAction - Missed id: " + notFoundDocId);
|
|
873 |
logMetacat.warn("MetaCatServlet.handleReadAction - Missed rev: " + notFoundRevision);
|
|
872 |
logMetacat.warn("MetacatHandler.handleReadAction - Missed id: " + notFoundDocId);
|
|
873 |
logMetacat.warn("MetacatHandler.handleReadAction - Missed rev: " + notFoundRevision);
|
|
874 | 874 |
try { |
875 | 875 |
// read docid from remote server |
876 | 876 |
readFromRemoteMetaCat(response, notFoundDocId, |
... | ... | |
885 | 885 |
} |
886 | 886 |
|
887 | 887 |
} catch (Exception exc) { |
888 |
logMetacat.error("MetaCatServlet.handleReadAction - General error: "
|
|
888 |
logMetacat.error("MetacatHandler.handleReadAction - General error: "
|
|
889 | 889 |
+ exc.getMessage()); |
890 | 890 |
exc.printStackTrace(System.out); |
891 | 891 |
try { |
... | ... | |
918 | 918 |
zout.close(); |
919 | 919 |
} |
920 | 920 |
} catch (IOException ie) { |
921 |
logMetacat.error("MetaCatServlet.handleReadAction - Problem with the servlet output: "
|
|
921 |
logMetacat.error("MetacatHandler.handleReadAction - Problem with the servlet output: "
|
|
922 | 922 |
+ ie.getMessage()); |
923 | 923 |
ie.printStackTrace(System.out); |
924 | 924 |
} |
... | ... | |
954 | 954 |
} |
955 | 955 |
|
956 | 956 |
} catch (Exception e2) { |
957 |
logMetacat.error("MetaCatServlet.handleReadAction - Problem with the servlet output: " |
|
958 |
+ e2.getMessage()); |
|
957 |
logMetacat.error("MetacatHandler.handleReadAction - " + |
|
958 |
"Problem with the servlet output: "+ |
|
959 |
e2.getMessage()); |
|
959 | 960 |
e2.printStackTrace(System.out); |
960 | 961 |
|
961 | 962 |
} |
962 | 963 |
|
963 |
logMetacat.error("MetaCatServlet.handleReadAction - General error: "
|
|
964 |
logMetacat.error("MetacatHandler.handleReadAction - General error: "
|
|
964 | 965 |
+ e.getMessage()); |
965 | 966 |
e.printStackTrace(System.out); |
966 | 967 |
} |
... | ... | |
1000 | 1001 |
params.put("permOrder", new String[] {permissionOrder}); |
1001 | 1002 |
params.put("docid", new String[]{docid}); |
1002 | 1003 |
|
1003 |
//System.out.println("permission in MetacatHandler.setAccess: " + params.get("permission")[0]); |
|
1004 |
//System.out.println("permission in MetacatHandler.setAccess: " + |
|
1005 |
// params.get("permission")[0]); |
|
1004 | 1006 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
1005 | 1007 |
PrintWriter out = new PrintWriter(baos); |
1006 | 1008 |
handleSetAccessAction(out, params, username, null, null); |
... | ... | |
1104 | 1106 |
} catch (McdbException e) { |
1105 | 1107 |
// any exceptions in reading the xml from disc, and we go back to the |
1106 | 1108 |
// old way of creating the xml directly. |
1107 |
logMetacat.error("MetaCatServlet.readFromMetacat() " +
|
|
1109 |
logMetacat.error("MetacatHandler.readFromMetacat() " +
|
|
1108 | 1110 |
"- could not read from document file " + |
1109 | 1111 |
docid + ": " + e.getMessage()); |
1110 | 1112 |
e.printStackTrace(System.out); |
... | ... | |
1189 | 1191 |
out.println(this.SUCCESS); |
1190 | 1192 |
out.println("Document deleted."); |
1191 | 1193 |
out.println(this.SUCCESSCLOSE); |
1192 |
logMetacat.info("MetaCatServlet.handleDeleteAction - " +
|
|
1194 |
logMetacat.info("MetacatHandler.handleDeleteAction - " +
|
|
1193 | 1195 |
"Document deleted."); |
1194 | 1196 |
|
1195 | 1197 |
try { |
... | ... | |
1293 | 1295 |
//check the permission for read |
1294 | 1296 |
if (!DocumentImpl.hasReadPermission(user, groups, docid)) { |
1295 | 1297 |
|
1296 |
InsufficientKarmaException e = new InsufficientKarmaException("User " + user |
|
1298 |
InsufficientKarmaException e = |
|
1299 |
new InsufficientKarmaException("User " + user |
|
1297 | 1300 |
+ " does not have permission" |
1298 | 1301 |
+ " to read the document with the docid " + docid); |
1299 | 1302 |
throw e; |
... | ... | |
1317 | 1320 |
ContentTypeProvider provider = new ContentTypeProvider( |
1318 | 1321 |
docid); |
1319 | 1322 |
contentType = provider.getContentType(); |
1320 |
logMetacat.info("MetaCatServlet.readFromMetacat - Final contenttype is: "
|
|
1323 |
logMetacat.info("MetacatHandler.readFromMetacat - Final contenttype is: "
|
|
1321 | 1324 |
+ contentType); |
1322 | 1325 |
} |
1323 | 1326 |
response.setContentType(contentType); |
... | ... | |
1360 | 1363 |
} catch (McdbException e) { |
1361 | 1364 |
// any exceptions in reading the xml from disc, and we go back to the |
1362 | 1365 |
// old way of creating the xml directly. |
1363 |
logMetacat.error("MetaCatServlet.readFromMetacat - could not read from document file " + docid |
|
1364 |
+ ": " + e.getMessage()); |
|
1366 |
logMetacat.error("MetacatHandler.readFromMetacat - " + |
|
1367 |
"could not read from document file " + |
|
1368 |
docid + |
|
1369 |
": " + |
|
1370 |
e.getMessage()); |
|
1365 | 1371 |
e.printStackTrace(System.out); |
1366 | 1372 |
doc.toXmlFromDb(out, user, groups, withInlineData); |
1367 | 1373 |
} |
... | ... | |
1383 | 1389 |
|
1384 | 1390 |
// detect actual encoding |
1385 | 1391 |
String docString = doc.toString(user, groups, withInlineData); |
1386 |
XmlStreamReader xsr = new XmlStreamReader(new ByteArrayInputStream(doc.getBytes())); |
|
1392 |
XmlStreamReader xsr = |
|
1393 |
new XmlStreamReader(new ByteArrayInputStream(doc.getBytes())); |
|
1387 | 1394 |
String encoding = xsr.getEncoding(); |
1388 | 1395 |
Writer w = null; |
1389 | 1396 |
if (encoding != null) { |
... | ... | |
1694 | 1701 |
out.println(msg); |
1695 | 1702 |
} |
1696 | 1703 |
|
1697 |
logMetacat.error("MetaCatServlet.handleInsertOrUpdateAction - User '" + user + "' not allowed to insert and update"); |
|
1704 |
logMetacat.error("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1705 |
"User '" + |
|
1706 |
user + |
|
1707 |
"' not allowed to insert and update"); |
|
1698 | 1708 |
return msg; |
1699 | 1709 |
} |
1700 | 1710 |
} catch (MetacatUtilException ue) { |
1701 |
logMetacat.error("MetaCatServlet.handleInsertOrUpdateAction - Could not determine if user could insert or update: " |
|
1702 |
+ ue.getMessage()); |
|
1711 |
logMetacat.error("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1712 |
"Could not determine if user could insert or update: " + |
|
1713 |
ue.getMessage()); |
|
1703 | 1714 |
ue.printStackTrace(System.out); |
1704 | 1715 |
// TODO: This is a bug, as it allows one to bypass the access check -- need to throw an exception |
1705 | 1716 |
} |
1706 | 1717 |
|
1707 | 1718 |
try { |
1708 | 1719 |
// Get the document indicated |
1709 |
logMetacat.debug("MetacatHandler.handleInsertOrUpdateAction - params: " + params.toString()); |
|
1720 |
logMetacat.debug("MetacatHandler.handleInsertOrUpdateAction - params: " + |
|
1721 |
params.toString()); |
|
1710 | 1722 |
|
1711 | 1723 |
String[] doctext = params.get("doctext"); |
1712 | 1724 |
String pub = null; |
... | ... | |
1739 | 1751 |
return msg; |
1740 | 1752 |
} |
1741 | 1753 |
|
1742 |
logMetacat.debug("MetacatHandler.handleInsertOrUpdateAction - the xml document in metacat servlet (before parsing):\n" + doctext[0]); |
|
1754 |
logMetacat.debug("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1755 |
"the xml document in metacat servlet (before parsing):\n" + |
|
1756 |
doctext[0]); |
|
1743 | 1757 |
StringReader xmlReader = new StringReader(doctext[0]); |
1744 | 1758 |
boolean validate = false; |
1745 | 1759 |
DocumentImplWrapper documentWrapper = null; |
... | ... | |
1808 | 1822 |
|
1809 | 1823 |
// write the document to the database and disk |
1810 | 1824 |
String accNumber = docid[0]; |
1811 |
logMetacat.debug("MetaCatServlet.handleInsertOrUpdateAction - " +
|
|
1825 |
logMetacat.debug("MetacatHandler.handleInsertOrUpdateAction - " +
|
|
1812 | 1826 |
doAction + " " + accNumber + "..."); |
1813 | 1827 |
|
1814 | 1828 |
if (accNumber == null || accNumber.equals("")) { |
1815 |
logMetacat.warn("MetacatHandler.handleInsertOrUpdateAction - writing with null acnumber"); |
|
1829 |
logMetacat.warn("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1830 |
"writing with null acnumber"); |
|
1816 | 1831 |
newdocid = documentWrapper.write(dbConn, doctext[0], pub, dtd, |
1817 | 1832 |
doAction, null, user, groups); |
1818 | 1833 |
EventLog.getInstance().log(ipAddress, user, "", action[0]); |
... | ... | |
1906 | 1921 |
output += this.ERROR; |
1907 | 1922 |
output += npe.getMessage(); |
1908 | 1923 |
output += this.ERRORCLOSE; |
1909 |
logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - Null pointer error when writing eml document to the database: " + npe.getMessage()); |
|
1924 |
logMetacat.warn("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1925 |
"Null pointer error when writing eml " + |
|
1926 |
"document to the database: " + |
|
1927 |
npe.getMessage()); |
|
1910 | 1928 |
npe.printStackTrace(); |
1911 | 1929 |
} |
1912 | 1930 |
} catch (Exception e) { |
... | ... | |
1915 | 1933 |
output += this.ERROR; |
1916 | 1934 |
output += e.getMessage(); |
1917 | 1935 |
output += this.ERRORCLOSE; |
1918 |
logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - General error when writing eml document to the database: " + e.getMessage()); |
|
1936 |
logMetacat.warn("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1937 |
"General error when writing eml " + |
|
1938 |
"document to the database: " + |
|
1939 |
e.getMessage()); |
|
1919 | 1940 |
e.printStackTrace(); |
1920 | 1941 |
} |
1921 | 1942 |
|
... | ... | |
1935 | 1956 |
out, null, null); |
1936 | 1957 |
} catch (Exception e) { |
1937 | 1958 |
|
1938 |
logMetacat.error("MetaCatServlet.handleInsertOrUpdateAction - General error: " |
|
1939 |
+ e.getMessage()); |
|
1959 |
logMetacat.error("MetacatHandler.handleInsertOrUpdateAction - " + |
|
1960 |
"General error: " + |
|
1961 |
e.getMessage()); |
|
1940 | 1962 |
e.printStackTrace(System.out); |
1941 | 1963 |
} |
1942 | 1964 |
} |
... | ... | |
1949 | 1971 |
*/ |
1950 | 1972 |
private static boolean needDTDValidation(StringReader xmlreader) |
1951 | 1973 |
throws IOException { |
1952 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
1974 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
1953 | 1975 |
StringBuffer cbuff = new StringBuffer(); |
1954 | 1976 |
java.util.Stack<String> st = new java.util.Stack<String>(); |
1955 | 1977 |
boolean validate = false; |
... | ... | |
2002 | 2024 |
} |
2003 | 2025 |
} |
2004 | 2026 |
|
2005 |
logMetacat.info("MetaCatServlet.needDTDValidation - Validation for dtd is " + validate); |
|
2027 |
logMetacat.info("MetacatHandler.needDTDValidation - Validation for dtd is " + |
|
2028 |
validate); |
|
2006 | 2029 |
return validate; |
2007 | 2030 |
} |
2008 | 2031 |
|
... | ... | |
2016 | 2039 |
HttpServletRequest request, HttpServletResponse response, |
2017 | 2040 |
String user, String[] groups) { |
2018 | 2041 |
|
2019 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
2042 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
2020 | 2043 |
String[] docid = params.get("docid"); |
2021 | 2044 |
|
2022 | 2045 |
if(docid == null){ |
... | ... | |
2025 | 2048 |
out.println(this.ERROR); |
2026 | 2049 |
out.println("Docid not specified."); |
2027 | 2050 |
out.println(this.ERRORCLOSE); |
2028 |
logMetacat.error("MetaCatServlet.handleDeleteAction - " +
|
|
2051 |
logMetacat.error("MetacatHandler.handleDeleteAction - " +
|
|
2029 | 2052 |
"Docid not specified for the document to be deleted."); |
2030 | 2053 |
|
2031 | 2054 |
} else { |
... | ... | |
2056 | 2079 |
//out.println("Error deleting document!!!"); |
2057 | 2080 |
out.println(dnfe.getMessage()); |
2058 | 2081 |
out.println(this.ERRORCLOSE); |
2059 |
logMetacat.error("MetaCatServlet.handleDeleteAction - " +
|
|
2082 |
logMetacat.error("MetacatHandler.handleDeleteAction - " +
|
|
2060 | 2083 |
"Document could not be deleted: " |
2061 | 2084 |
+ dnfe.getMessage()); |
2062 | 2085 |
dnfe.printStackTrace(System.out); |
... | ... | |
2116 | 2139 |
try { |
2117 | 2140 |
// get a connection from the pool |
2118 | 2141 |
dbConn = DBConnectionPool |
2119 |
.getDBConnection("MetaCatServlet.handleValidateAction");
|
|
2142 |
.getDBConnection("MetacatHandler.handleValidateAction");
|
|
2120 | 2143 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
2121 | 2144 |
DBValidate valobj = new DBValidate(dbConn); |
2122 | 2145 |
// boolean valid = valobj.validateString(valtext); |
... | ... | |
2186 | 2209 |
Hashtable<String,String[]> params, HttpServletResponse response, String username, |
2187 | 2210 |
String[] groupnames) { |
2188 | 2211 |
|
2189 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
2212 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
2190 | 2213 |
|
2191 | 2214 |
String docid = params.get("docid")[0]; |
2192 | 2215 |
if (docid.startsWith("urn:")) { |
... | ... | |
2194 | 2217 |
String actualDocId = LSIDUtil.getDocId(docid, false); |
2195 | 2218 |
docid = actualDocId; |
2196 | 2219 |
} catch (ParseLSIDException ple) { |
2197 |
logMetacat.error("MetaCatServlet.handleGetAccessControlAction - MetaCatServlet.handleGetAccessControlAction - " + |
|
2198 |
"could not parse lsid: " + docid + " : " + ple.getMessage()); |
|
2220 |
logMetacat.error("MetacatHandler.handleGetAccessControlAction - " + |
|
2221 |
"could not parse lsid: " + |
|
2222 |
docid + " : " + ple.getMessage()); |
|
2199 | 2223 |
ple.printStackTrace(System.out); |
2200 | 2224 |
} |
2201 | 2225 |
} |
... | ... | |
2252 | 2276 |
* Handle "getdoctypes" action. Read all doctypes from db connection in XML |
2253 | 2277 |
* format |
2254 | 2278 |
*/ |
2255 |
protected void handleGetDoctypesAction(PrintWriter out, Hashtable<String, String[]> params,
|
|
2256 |
HttpServletResponse response) {
|
|
2279 |
protected void handleGetDoctypesAction(PrintWriter out, Hashtable<String, |
|
2280 |
String[]> params, HttpServletResponse response) {
|
|
2257 | 2281 |
try { |
2258 | 2282 |
DBUtil dbutil = new DBUtil(); |
2259 | 2283 |
String doctypes = dbutil.readDoctypes(); |
... | ... | |
2270 | 2294 |
* Handle the "getdtdschema" action. Read DTD or Schema file for a given |
2271 | 2295 |
* doctype from Metacat catalog system |
2272 | 2296 |
*/ |
2273 |
protected void handleGetDTDSchemaAction(PrintWriter out, Hashtable<String, String[]> params,
|
|
2274 |
HttpServletResponse response) {
|
|
2297 |
protected void handleGetDTDSchemaAction(PrintWriter out, Hashtable<String, |
|
2298 |
String[]> params, HttpServletResponse response) {
|
|
2275 | 2299 |
|
2276 | 2300 |
String doctype = null; |
2277 | 2301 |
String[] doctypeArr = params.get("doctype"); |
... | ... | |
2302 | 2326 |
* @param params request parameters |
2303 | 2327 |
* @param response the http servlet response |
2304 | 2328 |
*/ |
2305 |
public void handleIdIsRegisteredAction(PrintWriter out, Hashtable<String, String[]> params,
|
|
2306 |
HttpServletResponse response) {
|
|
2329 |
public void handleIdIsRegisteredAction(PrintWriter out, Hashtable<String, |
|
2330 |
String[]> params, HttpServletResponse response) {
|
|
2307 | 2331 |
String id = null; |
2308 | 2332 |
boolean exists = false; |
2309 | 2333 |
if(params.get("docid") != null) { |
... | ... | |
2331 | 2355 |
* Handle the "getalldocids" action. return a list of all docids registered |
2332 | 2356 |
* in the system |
2333 | 2357 |
*/ |
2334 |
public void handleGetAllDocidsAction(PrintWriter out, Hashtable<String, String[]> params,
|
|
2335 |
HttpServletResponse response) {
|
|
2358 |
public void handleGetAllDocidsAction(PrintWriter out, Hashtable<String, |
|
2359 |
String[]> params, HttpServletResponse response) {
|
|
2336 | 2360 |
String scope = null; |
2337 | 2361 |
if(params.get("scope") != null) { |
2338 | 2362 |
scope = params.get("scope")[0]; |
... | ... | |
2362 | 2386 |
* Handle the "getlastdocid" action. Get the latest docid with rev number |
2363 | 2387 |
* from db connection in XML format |
2364 | 2388 |
*/ |
2365 |
public void handleGetMaxDocidAction(PrintWriter out, Hashtable<String, String[]> params,
|
|
2366 |
HttpServletResponse response) {
|
|
2389 |
public void handleGetMaxDocidAction(PrintWriter out, Hashtable<String, |
|
2390 |
String[]> params, HttpServletResponse response) {
|
|
2367 | 2391 |
|
2368 | 2392 |
String scope = params.get("scope")[0]; |
2369 | 2393 |
if (scope == null) { |
... | ... | |
2396 | 2420 |
* @param request the http request object for getting request details |
2397 | 2421 |
* @param response the http response object for writing output |
2398 | 2422 |
*/ |
2399 |
protected void handleGetLogAction(Hashtable<String, String[]> params, HttpServletRequest request, |
|
2400 |
HttpServletResponse response, String username, String[] groups) { |
|
2401 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
|
2423 |
protected void handleGetLogAction(Hashtable<String, String[]> params, |
|
2424 |
HttpServletRequest request, HttpServletResponse response, |
|
2425 |
String username, String[] groups) { |
|
2426 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class); |
|
2402 | 2427 |
try { |
2403 | 2428 |
// figure out the output as part of the action |
2404 | 2429 |
PrintWriter out = null; |
... | ... | |
2435 | 2460 |
endDate = new Timestamp((format.parse(end)).getTime()); |
2436 | 2461 |
} |
2437 | 2462 |
} catch (ParseException e) { |
2438 |
logMetacat.error("MetaCatServlet.handleGetLogAction - Failed to created Timestamp from input."); |
|
2463 |
logMetacat.error("MetacatHandler.handleGetLogAction - " + |
|
2464 |
"Failed to created Timestamp from input."); |
|
2439 | 2465 |
e.printStackTrace(System.out); |
2440 | 2466 |
} |
2441 | 2467 |
|
... | ... | |
2481 | 2507 |
null, |
2482 | 2508 |
null); |
2483 | 2509 |
} catch (Exception e) { |
2484 |
logMetacat.error("MetaCatServlet.handleGetLogAction - General error"
|
|
2510 |
logMetacat.error("MetacatHandler.handleGetLogAction - General error"
|
|
2485 | 2511 |
+ e.getMessage()); |
2486 | 2512 |
e.printStackTrace(System.out); |
2487 | 2513 |
} |
... | ... | |
2494 | 2520 |
} |
2495 | 2521 |
|
2496 | 2522 |
} catch (IOException e) { |
2497 |
logMetacat.error("MetaCatServlet.handleGetLogAction - Could not open http response for writing: " |
|
2498 |
+ e.getMessage()); |
|
2523 |
logMetacat.error("MetacatHandler.handleGetLogAction - " + |
|
2524 |
"Could not open http response for writing: " + |
|
2525 |
e.getMessage()); |
|
2499 | 2526 |
e.printStackTrace(System.out); |
2500 | 2527 |
} catch (MetacatUtilException ue) { |
2501 |
logMetacat.error("MetaCatServlet.handleGetLogAction - Could not determine if user is administrator: " |
|
2502 |
+ ue.getMessage()); |
|
2528 |
logMetacat.error("MetacatHandler.handleGetLogAction - " + |
|
2529 |
"Could not determine if user is administrator: " + |
|
2530 |
ue.getMessage()); |
|
2503 | 2531 |
ue.printStackTrace(System.out); |
2504 | 2532 |
} |
2505 | 2533 |
} |
... | ... | |
2521 | 2549 |
protected void handleBuildIndexAction(Hashtable<String, String[]> params, |
2522 | 2550 |
HttpServletRequest request, HttpServletResponse response, |
2523 | 2551 |
String username, String[] groups) { |
2524 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
2552 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
2525 | 2553 |
|
2526 | 2554 |
// Get all of the parameters in the correct formats |
2527 | 2555 |
String[] docid = params.get("docid"); |
... | ... | |
2569 | 2597 |
out.println("</success>"); |
2570 | 2598 |
out.close(); |
2571 | 2599 |
} catch (IOException e) { |
2572 |
logMetacat.error("MetaCatServlet.handleBuildIndexAction - Could not open http response for writing: " |
|
2573 |
+ e.getMessage()); |
|
2600 |
logMetacat.error("MetacatHandler.handleBuildIndexAction - " + |
|
2601 |
"Could not open http response for writing: " + |
|
2602 |
e.getMessage()); |
|
2574 | 2603 |
e.printStackTrace(System.out); |
2575 | 2604 |
} catch (MetacatUtilException ue) { |
2576 |
logMetacat.error("MetaCatServlet.handleBuildIndexAction - Could not determine if user is administrator: " |
|
2577 |
+ ue.getMessage()); |
|
2605 |
logMetacat.error("MetacatHandler.handleBuildIndexAction - " + |
|
2606 |
"Could not determine if user is administrator: " + |
|
2607 |
ue.getMessage()); |
|
2578 | 2608 |
ue.printStackTrace(System.out); |
2579 | 2609 |
} |
2580 | 2610 |
} |
... | ... | |
2606 | 2636 |
*/ |
2607 | 2637 |
protected void handleMultipartForm(HttpServletRequest request, |
2608 | 2638 |
HttpServletResponse response) { |
2609 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
2639 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
2610 | 2640 |
PrintWriter out = null; |
2611 | 2641 |
String action = null; |
2612 | 2642 |
|
... | ... | |
2620 | 2650 |
sizeLimit = |
2621 | 2651 |
(new Integer(PropertyService.getProperty("replication.datafilesizelimit"))).intValue(); |
2622 | 2652 |
} catch (PropertyNotFoundException pnfe) { |
2623 |
logMetacat.error("MetaCatServlet.handleMultipartForm - Could not determine data file size limit. Using 1000. " |
|
2624 |
+ pnfe.getMessage()); |
|
2653 |
logMetacat.error("MetacatHandler.handleMultipartForm - " + |
|
2654 |
"Could not determine data file size limit. Using 1000. " + |
|
2655 |
pnfe.getMessage()); |
|
2625 | 2656 |
pnfe.printStackTrace(System.out); |
2626 | 2657 |
} |
2627 |
logMetacat.debug("MetaCatServlet.handleMultipartForm - The size limit of uploaded data files is: " + sizeLimit); |
|
2658 |
logMetacat.debug("MetacatHandler.handleMultipartForm - " + |
|
2659 |
"The size limit of uploaded data files is: " + |
|
2660 |
sizeLimit); |
|
2628 | 2661 |
|
2629 | 2662 |
try { |
2630 | 2663 |
MultipartParser mp = new MultipartParser(request, |
... | ... | |
2655 | 2688 |
fileList.put("filename", fileName); |
2656 | 2689 |
fileList.put("name", fileTempLocation); |
2657 | 2690 |
} else { |
2658 |
logMetacat.info("MetaCatServlet.handleMultipartForm - Upload name '" + name + "' was empty."); |
|
2691 |
logMetacat.info("MetacatHandler.handleMultipartForm - " + |
|
2692 |
"Upload name '" + name + "' was empty."); |
|
2659 | 2693 |
} |
2660 | 2694 |
} |
2661 | 2695 |
} catch (IOException ioe) { |
2662 | 2696 |
try { |
2663 | 2697 |
out = response.getWriter(); |
2664 | 2698 |
} catch (IOException ioe2) { |
2665 |
logMetacat.fatal("MetaCatServlet.handleMultipartForm - Fatal Error: couldn't get response output stream."); |
|
2699 |
logMetacat.fatal("MetacatHandler.handleMultipartForm - " + |
|
2700 |
"Fatal Error: couldn't get response output stream."); |
|
2666 | 2701 |
} |
2667 | 2702 |
out.println("<?xml version=\"1.0\"?>"); |
2668 | 2703 |
out.println("<error>"); |
... | ... | |
2702 | 2737 |
try { |
2703 | 2738 |
out = response.getWriter(); |
2704 | 2739 |
} catch (IOException ioe2) { |
2705 |
logMetacat.error("MetaCatServlet.handleMultipartForm - Fatal Error: couldn't get response " |
|
2706 |
+ "output stream."); |
|
2740 |
logMetacat.error("MetacatHandler.handleMultipartForm - " + |
|
2741 |
"Fatal Error: couldn't get response " + |
|
2742 |
"output stream."); |
|
2707 | 2743 |
ioe2.printStackTrace(System.out); |
2708 | 2744 |
} |
2709 | 2745 |
|
... | ... | |
2719 | 2755 |
} |
2720 | 2756 |
} else if(action.equals("insertmultipart")) { |
2721 | 2757 |
if (username != null && !username.equals("public")) { |
2722 |
logMetacat.debug("MetaCatServlet.handleMultipartForm - handling multipart insert");
|
|
2758 |
logMetacat.debug("MetacatHandler.handleMultipartForm - handling multipart insert");
|
|
2723 | 2759 |
handleInsertMultipartAction(request, response, |
2724 | 2760 |
out, params, fileList, username, groupnames); |
2725 | 2761 |
} else { |
... | ... | |
2751 | 2787 |
PrintWriter out, Hashtable<String,String[]> params, Hashtable<String,String> fileList, |
2752 | 2788 |
String username, String[] groupnames) |
2753 | 2789 |
{ |
2754 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
2790 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
2755 | 2791 |
String action = null; |
2756 | 2792 |
String docid = null; |
2757 | 2793 |
String qformat = null; |
... | ... | |
2777 | 2813 |
// Make sure we have a docid and datafile |
2778 | 2814 |
if (docid != null && fileList.containsKey("datafile")) |
2779 | 2815 |
{ |
2780 |
logMetacat.info("MetaCatServlet.handleInsertMultipartAction - Uploading data docid: " + docid); |
|
2816 |
logMetacat.info("MetacatHandler.handleInsertMultipartAction - " + |
|
2817 |
"Uploading data docid: " + docid); |
|
2781 | 2818 |
// Get a reference to the file part of the form |
2782 | 2819 |
//FilePart filePart = (FilePart) fileList.get("datafile"); |
2783 | 2820 |
String fileName = fileList.get("filename"); |
2784 |
logMetacat.debug("MetaCatServlet.handleInsertMultipartAction - Uploading filename: " + fileName); |
|
2821 |
logMetacat.debug("MetacatHandler.handleInsertMultipartAction - " + |
|
2822 |
"Uploading filename: " + fileName); |
|
2785 | 2823 |
// Check if the right file existed in the uploaded data |
2786 | 2824 |
if (fileName != null) |
2787 | 2825 |
{ |
... | ... | |
2808 | 2846 |
{ |
2809 | 2847 |
newFile = new File(newFileName); |
2810 | 2848 |
fileExists = newFile.exists(); |
2811 |
logMetacat.info("MetaCatServlet.handleInsertMultipartAction - new file status is: " + fileExists); |
|
2849 |
logMetacat.info("MetacatHandler.handleInsertMultipartAction - " + |
|
2850 |
"new file status is: " + fileExists); |
|
2812 | 2851 |
if(fileExists) |
2813 | 2852 |
{ |
2814 | 2853 |
newFile.delete(); |
... | ... | |
2825 | 2864 |
} |
2826 | 2865 |
catch (IOException ioe) |
2827 | 2866 |
{ |
2828 |
logMetacat.error("MetaCatServlet.handleInsertMultipartAction - IO Exception copying file: " + |
|
2829 |
ioe.getMessage()); |
|
2867 |
logMetacat.error("MetacatHandler.handleInsertMultipartAction - " + |
|
2868 |
"IO Exception copying file: " + |
|
2869 |
ioe.getMessage()); |
|
2830 | 2870 |
ioe.printStackTrace(System.out); |
2831 | 2871 |
} |
2832 | 2872 |
size = newFile.length(); |
2833 | 2873 |
if (size == 0) |
2834 | 2874 |
{ |
2835 |
throw new IOException("MetaCatServlet.handleInsertMultipartAction - Uploaded file is 0 bytes!"); |
|
2875 |
throw new IOException("MetacatHandler.handleInsertMultipartAction - " + |
|
2876 |
"Uploaded file is 0 bytes!"); |
|
2836 | 2877 |
} |
2837 | 2878 |
} |
2838 |
logMetacat.info("MetaCatServlet.handleInsertMultipartAction - Uploading the following to Metacat:" + |
|
2839 |
fileName + ", " + docid + ", " + |
|
2840 |
username + ", " + groupnames); |
|
2879 |
logMetacat.info("MetacatHandler.handleInsertMultipartAction - " + |
|
2880 |
"Uploading the following to Metacat:" + |
|
2881 |
fileName + ", " + docid + ", " + |
|
2882 |
username + ", " + groupnames); |
|
2841 | 2883 |
|
2842 | 2884 |
// Read the file with appropriate encoding |
2843 | 2885 |
XmlStreamReader xsr = new XmlStreamReader(new FileInputStream(newFile)); |
... | ... | |
2879 | 2921 |
} |
2880 | 2922 |
catch(Exception e) |
2881 | 2923 |
{ |
2882 |
logMetacat.error("MetaCatServlet.handleInsertMultipartAction - error uploading text file via multipart: " + e.getMessage()); |
|
2924 |
logMetacat.error("MetacatHandler.handleInsertMultipartAction - " + |
|
2925 |
"error uploading text file via multipart: " + |
|
2926 |
e.getMessage()); |
|
2883 | 2927 |
e.printStackTrace(System.out);; |
2884 | 2928 |
} |
2885 | 2929 |
} |
... | ... | |
2891 | 2935 |
* registering it in the Metacat db |
2892 | 2936 |
*/ |
2893 | 2937 |
private void handleUploadAction(HttpServletRequest request, |
2894 |
PrintWriter out, Hashtable<String, String[]> params, Hashtable<String,String> fileList, |
|
2895 |
String username, String[] groupnames, HttpServletResponse response) { |
|
2896 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class); |
|
2938 |
PrintWriter out, Hashtable<String, String[]> params, |
|
2939 |
Hashtable<String,String> fileList, String username, String[] groupnames, |
|
2940 |
HttpServletResponse response) { |
|
2941 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class); |
|
2897 | 2942 |
//PrintWriter out = null; |
2898 | 2943 |
//Connection conn = null; |
2899 | 2944 |
// String action = null; |
... | ... | |
2918 | 2963 |
|
2919 | 2964 |
// Make sure we have a docid and datafile |
2920 | 2965 |
if (docid != null && fileList.containsKey("datafile")) { |
2921 |
logMetacat.info("MetaCatServlet.handleUploadAction - Uploading data docid: " + docid); |
|
2966 |
logMetacat.info("MetacatHandler.handleUploadAction - " + |
|
2967 |
"Uploading data docid: " + docid); |
|
2922 | 2968 |
// Get a reference to the file part of the form |
2923 | 2969 |
//FilePart filePart = (FilePart) fileList.get("datafile"); |
2924 | 2970 |
String fileName = fileList.get("filename"); |
2925 |
logMetacat.info("MetaCatServlet.handleUploadAction - Uploading filename: " + fileName); |
|
2971 |
logMetacat.info("MetacatHandler.handleUploadAction - " + |
|
2972 |
"Uploading filename: " + fileName); |
|
2926 | 2973 |
// Check if the right file existed in the uploaded data |
2927 | 2974 |
if (fileName != null) { |
2928 | 2975 |
|
... | ... | |
2945 | 2992 |
try { |
2946 | 2993 |
newFile = new File(newFileName); |
2947 | 2994 |
fileExists = newFile.exists(); |
2948 |
logMetacat.info("MetaCatServlet.handleUploadAction - new file status is: " + fileExists); |
|
2995 |
logMetacat.info("MetacatHandler.handleUploadAction - " + |
|
2996 |
"new file status is: " + fileExists); |
|
2949 | 2997 |
if ( fileExists == false ) { |
2950 | 2998 |
// copy file to desired output location |
2951 | 2999 |
try { |
... | ... | |
2962 | 3010 |
} // Latent bug here if the file already exists, then the |
2963 | 3011 |
// conditional fails but the document is still registered. |
2964 | 3012 |
// maybe this never happens because we already requested a lock? |
2965 |
logMetacat.info("MetaCatServlet.handleUploadAction - Uploading the following to Metacat:" + |
|
2966 |
fileName + ", " + docid + ", " + |
|
2967 |
username + ", " + groupnames); |
|
3013 |
logMetacat.info("MetacatHandler.handleUploadAction - " + |
|
3014 |
"Uploading the following to Metacat:" + |
|
3015 |
fileName + ", " + docid + ", " + |
|
3016 |
username + ", " + groupnames); |
|
2968 | 3017 |
//register the file in the database (which generates |
2969 | 3018 |
// an exception |
2970 | 3019 |
//if the docid is not acceptable or other untoward |
... | ... | |
2984 | 3033 |
newFile.delete(); |
2985 | 3034 |
} |
2986 | 3035 |
|
2987 |
logMetacat.info("MetaCatServlet.handleUploadAction - in Exception: fileExists is " + fileExists); |
|
2988 |
logMetacat.error("MetaCatServlet.handleUploadAction - Upload Error: " + ee.getMessage()); |
|
3036 |
logMetacat.info("MetacatHandler.handleUploadAction - " + |
|
3037 |
"in Exception: fileExists is " + fileExists); |
|
3038 |
logMetacat.error("MetacatHandler.handleUploadAction - " + |
|
3039 |
"Upload Error: " + ee.getMessage()); |
|
2989 | 3040 |
throw ee; |
2990 | 3041 |
} |
2991 | 3042 |
|
... | ... | |
3000 | 3051 |
// not get force replication info from another metacat |
3001 | 3052 |
ForceReplicationHandler frh = new ForceReplicationHandler( |
3002 | 3053 |
docid, "insert", false, null); |
3003 |
logMetacat.debug("MetaCatServlet.handleUploadAction - ForceReplicationHandler created: " + frh.toString()); |
|
3054 |
logMetacat.debug("MetacatHandler.handleUploadAction - " + |
|
3055 |
"ForceReplicationHandler created: " + |
|
3056 |
frh.toString()); |
|
3004 | 3057 |
|
3005 | 3058 |
// set content type and other response header fields |
3006 | 3059 |
// first |
... | ... | |
3046 | 3099 |
out, null, null); |
3047 | 3100 |
} catch (Exception e) { |
3048 | 3101 |
|
3049 |
logMetacat.error("MetaCatServlet.handleUploadAction - General error: "
|
|
3102 |
logMetacat.error("MetacatHandler.handleUploadAction - General error: "
|
|
3050 | 3103 |
+ e.getMessage()); |
3051 | 3104 |
e.printStackTrace(System.out); |
3052 | 3105 |
} |
... | ... | |
3077 | 3130 |
String[] accessBlock = params.get("accessBlock"); |
3078 | 3131 |
if(accessBlock != null) { |
3079 | 3132 |
if (docList == null) { |
3080 |
errorList.addElement("MetaCatServlet.handleSetAccessAction - Doc id missing. Please check your parameter list, it should look like: " |
|
3081 |
+ "?action=setaccess&docid=<doc_id>&accessBlock=<access_section>"); |
|
3133 |
errorList.addElement("MetacatHandler.handleSetAccessAction - " + |
|
3134 |
"Doc id missing. Please check your " + |
|
3135 |
"parameter list, it should look like: " + |
|
3136 |
"?action=setaccess&docid=<doc_id>&accessBlock=<access_section>"); |
|
3082 | 3137 |
outputResponse(successList, errorList, out); |
3083 | 3138 |
return; |
3084 | 3139 |
} |
... | ... | |
3086 | 3141 |
AccessControlForSingleFile accessControl = |
3087 | 3142 |
new AccessControlForSingleFile(docList[0]); |
3088 | 3143 |
accessControl.insertPermissions(accessBlock[0]); |
3089 |
successList.addElement("MetaCatServlet.handleSetAccessAction - successfully replaced access block for doc id: " + docList[0]); |
|
3144 |
successList.addElement("MetacatHandler.handleSetAccessAction - " + |
|
3145 |
"successfully replaced access block for doc id: " + |
|
3146 |
docList[0]); |
|
3090 | 3147 |
} catch(AccessControlException ace) { |
3091 |
errorList.addElement("MetaCatServlet.handleSetAccessAction - access control error when setting " + |
|
3092 |
"access block: " + ace.getMessage()); |
|
3148 |
errorList.addElement("MetacatHandler.handleSetAccessAction - " + |
|
3149 |
"access control error when setting " + |
|
3150 |
"access block: " + ace.getMessage()); |
|
3093 | 3151 |
} |
3094 | 3152 |
outputResponse(successList, errorList, out); |
3095 | 3153 |
return; |
... | ... | |
3098 | 3156 |
// Make sure the parameter is not null |
3099 | 3157 |
if (docList == null || principalList == null || permTypeList == null |
3100 | 3158 |
|| permissionList == null) { |
3101 |
error = "MetaCatServlet.handleSetAccessAction - Please check your parameter list, it should look like: " |
|
3159 |
error = "MetacatHandler.handleSetAccessAction - Please check " + |
|
3160 |
"your parameter list, it should look like: " |
|
3102 | 3161 |
+ "?action=setaccess&docid=pipeline.1.1&principal=public" |
3103 | 3162 |
+ "&permission=read&permType=allow&permOrder=allowFirst"; |
3104 | 3163 |
errorList.addElement(error); |
... | ... | |
3121 | 3180 |
packageSet = |
3122 | 3181 |
MetacatUtil.getOptionList(PropertyService.getProperty("xml.packagedoctypeset")); |
3123 | 3182 |
} catch (PropertyNotFoundException pnfe) { |
3124 |
logMetacat.error("MetaCatServlet.handleSetAccessAction - Could not find package doctype set. Setting to null: " |
|
3183 |
logMetacat.error("MetacatHandler.handleSetAccessAction - " + |
|
3184 |
"Could not find package doctype set. Setting to null: " |
|
3125 | 3185 |
+ pnfe.getMessage()); |
3126 | 3186 |
} |
3127 | 3187 |
//debug |
3128 | 3188 |
if (packageSet != null) { |
3129 | 3189 |
for (int i = 0; i < packageSet.size(); i++) { |
3130 |
logMetacat.debug("MetaCatServlet.handleSetAccessAction - doctype in package set: " |
|
3131 |
+ packageSet.elementAt(i)); |
|
3190 |
logMetacat.debug("MetacatHandler.handleSetAccessAction - " + |
|
3191 |
"doctype in package set: " + |
|
3192 |
packageSet.elementAt(i)); |
|
3132 | 3193 |
} |
3133 | 3194 |
} |
3134 | 3195 |
|
... | ... | |
3140 | 3201 |
String actualDocId = LSIDUtil.getDocId(docid, false); |
3141 | 3202 |
docid = actualDocId; |
3142 | 3203 |
} catch (ParseLSIDException ple) { |
3143 |
logMetacat.error("MetaCatServlet.handleSetAccessAction - " +
|
|
3204 |
logMetacat.error("MetacatHandler.handleSetAccessAction - " +
|
|
3144 | 3205 |
"could not parse lsid: " + docid + " : " + ple.getMessage()); |
3145 | 3206 |
ple.printStackTrace(System.out); |
3146 | 3207 |
} |
... | ... | |
3153 | 3214 |
owner = getFieldValueForDoc(accessionNumber, "user_owner"); |
3154 | 3215 |
publicId = getFieldValueForDoc(accessionNumber, "doctype"); |
3155 | 3216 |
} catch (Exception e) { |
3156 |
logMetacat.error("MetaCatServlet.handleSetAccessAction - Error in handleSetAccessAction: " |
|
3157 |
+ e.getMessage()); |
|
3217 |
logMetacat.error("MetacatHandler.handleSetAccessAction - " + |
|
3218 |
"Error in handleSetAccessAction: " + |
|
3219 |
e.getMessage()); |
|
3158 | 3220 |
e.printStackTrace(System.out); |
3159 |
error = "Error in set access control for document - " + accessionNumber + e.getMessage(); |
|
3221 |
error = "Error in set access control for document - " + |
|
3222 |
accessionNumber + e.getMessage(); |
|
3160 | 3223 |
errorList.addElement(error); |
3161 | 3224 |
continue; |
3162 | 3225 |
} |
... | ... | |
3194 | 3257 |
//insert permission |
3195 | 3258 |
AccessControlForSingleFile accessControl = |
3196 | 3259 |
new AccessControlForSingleFile(accessionNumber); |
3197 |
//System.out.println("permission in MetacatHandler: " + l.longValue()); |
|
3198 |
//System.out.println("permission in MetacatHandler: " + Integer.valueOf(AccessControlList.intValue(permission)).longValue()); |
|
3199 |
accessControl.insertPermissions(principal, Integer.valueOf(AccessControlList.intValue(permission)).longValue(), permType, permOrder, null, null); |
|
3260 |
//System.out.println("permission in MetacatHandler: " + |
|
3261 |
// l.longValue()); |
|
3262 |
//System.out.println("permission in MetacatHandler: " + |
|
3263 |
// Integer.valueOf(AccessControlList.intValue(permission)).longValue()); |
|
3264 |
accessControl.insertPermissions(principal, |
|
3265 |
Integer.valueOf(AccessControlList.intValue(permission)).longValue(), |
|
3266 |
permType, permOrder, null, null); |
|
3200 | 3267 |
} catch (Exception ee) { |
3201 |
logMetacat.error("MetaCatServlet.handleSetAccessAction - Error inserting permission: " |
|
3202 |
+ ee.getMessage()); |
|
3268 |
logMetacat.error("MetacatHandler.handleSetAccessAction - " + |
|
3269 |
"Error inserting permission: " + |
|
3270 |
ee.getMessage()); |
|
3203 | 3271 |
ee.printStackTrace(System.out); |
3204 | 3272 |
error = "Failed to set access control for document " |
3205 | 3273 |
+ accessionNumber + " because " + ee.getMessage(); |
... | ... | |
3214 | 3282 |
} |
3215 | 3283 |
ForceReplicationHandler frh = |
3216 | 3284 |
new ForceReplicationHandler(accessionNumber, isXml, null); |
3217 |
logMetacat.debug("MetaCatServlet.handleSetAccessAction - ForceReplicationHandler created: " + frh.toString()); |
|
3285 |
logMetacat.debug("MetacatHandler.handleSetAccessAction - " + |
|
3286 |
"ForceReplicationHandler created: " + frh.toString()); |
|
3218 | 3287 |
|
3219 | 3288 |
} |
3220 | 3289 |
if (errorList.isEmpty()) { |
3221 |
successList.addElement("MetaCatServlet.handleSetAccessAction - successfully added individual access for doc id: " + docList[0]); |
|
3290 |
successList.addElement("MetacatHandler.handleSetAccessAction - " + |
|
3291 |
"successfully added individual access for doc id: " + |
|
3292 |
docList[0]); |
|
3222 | 3293 |
} |
3223 | 3294 |
if (params.get("forwardto") != null) { |
3224 | 3295 |
try { |
... | ... | |
3256 | 3327 |
try { |
3257 | 3328 |
//check out DBConnection |
3258 | 3329 |
conn = DBConnectionPool |
3259 |
.getDBConnection("MetaCatServlet.getPublicIdForDoc");
|
|
3330 |
.getDBConnection("MetacatHandler.getPublicIdForDoc");
|
|
3260 | 3331 |
serialNumber = conn.getCheckOutSerialNumber(); |
3261 | 3332 |
pstmt = conn.prepareStatement("SELECT " + fieldName |
3262 | 3333 |
+ " FROM xml_documents " + "WHERE docid = ? "); |
... | ... | |
3273 | 3344 |
+ accessionNumber); |
3274 | 3345 |
} |
3275 | 3346 |
} catch (Exception e) { |
3276 |
logMetacat.error("MetaCatServlet.getFieldValueForDoc - General error: "
|
|
3347 |
logMetacat.error("MetacatHandler.getFieldValueForDoc - General error: "
|
|
3277 | 3348 |
+ e.getMessage()); |
3278 | 3349 |
throw e; |
3279 | 3350 |
} finally { |
... | ... | |
3295 | 3366 |
* @ returns the array of identifiers |
3296 | 3367 |
*/ |
3297 | 3368 |
private Vector<String> getDocumentList() throws SQLException { |
3298 |
Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
3369 |
Logger logMetacat = Logger.getLogger(MetacatHandler.class);
|
|
3299 | 3370 |
Vector<String> docList = new Vector<String>(); |
3300 | 3371 |
PreparedStatement pstmt = null; |
3301 | 3372 |
ResultSet rs = null; |
... | ... | |
3305 | 3376 |
try { |
3306 | 3377 |
//check out DBConnection |
3307 | 3378 |
conn = DBConnectionPool |
3308 |
.getDBConnection("MetaCatServlet.getDocumentList");
|
|
3379 |
.getDBConnection("MetacatHandler.getDocumentList");
|
|
3309 | 3380 |
serialNumber = conn.getCheckOutSerialNumber(); |
3310 | 3381 |
pstmt = conn.prepareStatement("SELECT docid, rev" |
3311 | 3382 |
+ " FROM xml_documents "); |
... | ... | |
3317 | 3388 |
docList.add(docid + "." + rev); |
3318 | 3389 |
} |
3319 | 3390 |
} catch (SQLException e) { |
3320 |
logMetacat.error("MetaCatServlet.getDocumentList - General exception: "
|
|
3391 |
logMetacat.error("MetacatHandler.getDocumentList - General exception: "
|
|
3321 | 3392 |
+ e.getMessage()); |
3322 | 3393 |
throw e; |
3323 | 3394 |
} finally { |
... | ... | |
3326 | 3397 |
pstmt.close(); |
3327 | 3398 |
|
3328 | 3399 |
} catch (SQLException se) { |
3329 |
logMetacat.error("MetaCatServlet.getDocumentList - General exception: "
|
|
3400 |
logMetacat.error("MetacatHandler.getDocumentList - General exception: "
|
|
3330 | 3401 |
+ se.getMessage()); |
3331 | 3402 |
throw se; |
3332 | 3403 |
} finally { |
... | ... | |
3380 | 3451 |
* If the given docid only have one seperter, we need |
3381 | 3452 |
* append rev for it. The rev come from xml_documents |
3382 | 3453 |
*/ |
3383 |
private static String appendRev(String docid) throws PropertyNotFoundException, SQLException, McdbDocNotFoundException { |
|
3454 |
private static String appendRev(String docid) |
|
3455 |
throws PropertyNotFoundException, SQLException, McdbDocNotFoundException { |
|
3384 | 3456 |
String newAccNum = null; |
3385 | 3457 |
String separator = PropertyService.getProperty("document.accNumSeparator"); |
3386 | 3458 |
int firstIndex = docid.indexOf(separator); |
... | ... | |
3421 | 3493 |
sitemapInterval = |
3422 | 3494 |
Integer.parseInt(PropertyService.getProperty("sitemap.interval")); |
3423 | 3495 |
} catch (PropertyNotFoundException pnfe) { |
3424 |
logMetacat.error("MetaCatServlet.scheduleSitemapGeneration - Could not run site map generation because property " |
|
3425 |
+ "could not be found: " + pnfe.getMessage()); |
|
3496 |
logMetacat.error("MetacatHandler.scheduleSitemapGeneration - " + |
|
3497 |
"Could not run site map generation because property " + |
|
3498 |
"could not be found: " + pnfe.getMessage()); |
|
3426 | 3499 |
} |
3427 | 3500 |
|
3428 | 3501 |
File directory = new File(directoryName); |
Also available in: Unified diff
Minor changes to MetacatHandler:
- Improved logging where MetaCatServlet.class was used in getLogger() rather than MetacatHandler.class (holdover from the refactor)
- Minor formatting changes, and replacement of 'MetaCatServlet' with 'MetacatHandler' in the logging output as needed.