Revision 2663
Added by sgarg over 18 years ago
MetaCatServlet.java | ||
---|---|---|
65 | 65 |
import com.oreilly.servlet.multipart.ParamPart; |
66 | 66 |
import com.oreilly.servlet.multipart.Part; |
67 | 67 |
|
68 |
import org.apache.log4j.Logger; |
|
69 |
import org.apache.log4j.PropertyConfigurator; |
|
70 |
|
|
68 | 71 |
import edu.ucsb.nceas.utilities.Options; |
69 | 72 |
|
70 | 73 |
/** |
... | ... | |
161 | 164 |
private static final String CONFIG_DIR = "WEB-INF"; |
162 | 165 |
|
163 | 166 |
private static final String CONFIG_NAME = "metacat.properties"; |
164 |
|
|
165 |
public static String LOG_CONFIG_NAME;
|
|
166 |
|
|
167 |
|
|
168 |
private static Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
|
|
169 |
|
|
167 | 170 |
/** |
168 | 171 |
* Initialize the servlet by creating appropriate database connections |
169 | 172 |
*/ |
... | ... | |
178 | 181 |
String dirPath = context.getRealPath(CONFIG_DIR); |
179 | 182 |
File propertyFile = new File(dirPath, CONFIG_NAME); |
180 | 183 |
|
181 |
LOG_CONFIG_NAME = dirPath + "/log4j.properties"; |
|
182 |
|
|
184 |
String LOG_CONFIG_NAME = dirPath + "/log4j.properties"; |
|
185 |
PropertyConfigurator.configureAndWatch(LOG_CONFIG_NAME); |
|
186 |
|
|
183 | 187 |
Options options = null; |
184 | 188 |
try { |
185 | 189 |
options = Options.initialize(propertyFile); |
186 |
MetaCatUtil.debugMessage("Options configured: "
|
|
187 |
+ options.getOption("configured"), 20);
|
|
190 |
MetaCatUtil.printMessage("Options configured: "
|
|
191 |
+ options.getOption("configured")); |
|
188 | 192 |
} catch (IOException ioe) { |
189 |
MetaCatUtil.debugMessage("Error in loading options: "
|
|
190 |
+ ioe.getMessage(), 20);
|
|
193 |
logMetacat.error("Error in loading options: "
|
|
194 |
+ ioe.getMessage()); |
|
191 | 195 |
} |
192 | 196 |
|
193 | 197 |
util = new MetaCatUtil(); |
... | ... | |
207 | 211 |
// Index the paths specified in the metacat.properties |
208 | 212 |
checkIndexPaths(); |
209 | 213 |
|
210 |
System.out.println("Metacat (" + Version.getVersion()
|
|
214 |
MetaCatUtil.printMessage("Metacat (" + Version.getVersion()
|
|
211 | 215 |
+ ") initialized."); |
212 | 216 |
|
213 | 217 |
} catch (ServletException ex) { |
214 | 218 |
throw ex; |
215 | 219 |
} catch (SQLException e) { |
216 |
MetaCatUtil.debugMessage("Error in MetacatServlet.init: "
|
|
217 |
+ e.getMessage(), 20);
|
|
220 |
logMetacat.error("Error in MetacatServlet.init: "
|
|
221 |
+ e.getMessage()); |
|
218 | 222 |
} |
219 | 223 |
} |
220 | 224 |
|
... | ... | |
255 | 259 |
|
256 | 260 |
if (MetaCatUtil.pathsForIndexing != null) { |
257 | 261 |
|
258 |
MetaCatUtil.debugMessage("Indexing paths....", 20);
|
|
262 |
MetaCatUtil.printMessage("Indexing paths specified in metacat.properties....");
|
|
259 | 263 |
|
260 | 264 |
DBConnection conn = null; |
261 | 265 |
int serialNumber = -1; |
... | ... | |
264 | 268 |
ResultSet rs = null; |
265 | 269 |
|
266 | 270 |
for (int i = 0; i < MetaCatUtil.pathsForIndexing.size(); i++) { |
267 |
MetaCatUtil.formattedDebugMessage("Checking if '"
|
|
271 |
logMetacat.info("Checking if '"
|
|
268 | 272 |
+ (String) MetaCatUtil.pathsForIndexing.elementAt(i) |
269 |
+ "' is indexed.... ",30, false, true);
|
|
273 |
+ "' is indexed.... "); |
|
270 | 274 |
|
271 | 275 |
try { |
272 | 276 |
//check out DBConnection |
... | ... | |
283 | 287 |
rs = pstmt.getResultSet(); |
284 | 288 |
|
285 | 289 |
if (!rs.next()) { |
286 |
MetaCatUtil.formattedDebugMessage("not indexed yet.", 30, |
|
287 |
true, false); |
|
290 |
logMetacat.info(".....not indexed yet."); |
|
288 | 291 |
rs.close(); |
289 | 292 |
pstmt.close(); |
290 | 293 |
conn.increaseUsageCount(1); |
291 | 294 |
|
292 |
MetaCatUtil.debugMessage(
|
|
295 |
logMetacat.debug(
|
|
293 | 296 |
"Inserting following path in xml_path_index: " |
294 | 297 |
+ (String)MetaCatUtil.pathsForIndexing |
295 |
.elementAt(i), 60);
|
|
298 |
.elementAt(i)); |
|
296 | 299 |
|
297 | 300 |
pstmt = conn.prepareStatement("SELECT DISTINCT n.docid, " |
298 | 301 |
+ "n.nodedata, n.nodedatanumerical, n.parentnodeid" |
... | ... | |
305 | 308 |
rs = pstmt.getResultSet(); |
306 | 309 |
|
307 | 310 |
int count = 0; |
308 |
MetaCatUtil.debugMessage(
|
|
311 |
logMetacat.debug(
|
|
309 | 312 |
"Executed the select statement for: " |
310 | 313 |
+ (String) MetaCatUtil.pathsForIndexing |
311 |
.elementAt(i), 60);
|
|
314 |
.elementAt(i)); |
|
312 | 315 |
|
313 | 316 |
try { |
314 | 317 |
while (rs.next()) { |
... | ... | |
349 | 352 |
pstmt.close(); |
350 | 353 |
conn.increaseUsageCount(1); |
351 | 354 |
|
352 |
MetaCatUtil.debugMessage("Indexed " + count
|
|
355 |
logMetacat.warn("Indexed " + count
|
|
353 | 356 |
+ " records from xml_nodes for '" |
354 | 357 |
+ (String) MetaCatUtil.pathsForIndexing.elementAt(i) |
355 |
+ "'", 20);
|
|
358 |
+ "'"); |
|
356 | 359 |
|
357 | 360 |
} else { |
358 |
MetaCatUtil.formattedDebugMessage("already indexed.", 30, |
|
359 |
true, false); |
|
361 |
logMetacat.info(".....already indexed."); |
|
360 | 362 |
} |
361 | 363 |
|
362 | 364 |
rs.close(); |
... | ... | |
364 | 366 |
conn.increaseUsageCount(1); |
365 | 367 |
|
366 | 368 |
} catch (Exception e) { |
367 |
MetaCatUtil.debugMessage("error in DocumentImpl.delete: "
|
|
368 |
+ e.getMessage(), 30);
|
|
369 |
logMetacat.error("Error in MetaCatServlet.checkIndexPaths: "
|
|
370 |
+ e.getMessage()); |
|
369 | 371 |
}finally { |
370 | 372 |
//check in DBonnection |
371 | 373 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
... | ... | |
374 | 376 |
|
375 | 377 |
} |
376 | 378 |
|
377 |
MetaCatUtil.debugMessage("Path Indexing Completed", 20);
|
|
379 |
MetaCatUtil.printMessage("Path Indexing Completed");
|
|
378 | 380 |
} |
379 | 381 |
} |
380 | 382 |
|
... | ... | |
390 | 392 |
util = new MetaCatUtil(); |
391 | 393 |
} |
392 | 394 |
/* |
393 |
* MetaCatUtil.debugMessage("Connection pool size: "
|
|
395 |
* logMetacat.info("Connection pool size: "
|
|
394 | 396 |
* +connPool.getSizeOfDBConnectionPool(),10); |
395 |
* MetaCatUtil.debugMessage("Free DBConnection number: "
|
|
397 |
* logMetacat.info("Free DBConnection number: "
|
|
396 | 398 |
*/ |
397 | 399 |
//If all DBConnection in the pool are free and DBConnection pool |
398 | 400 |
//size is greater than initial value, shrink the connection pool |
... | ... | |
448 | 450 |
} |
449 | 451 |
|
450 | 452 |
String action = ((String[]) params.get("action"))[0]; |
451 |
MetaCatUtil.debugMessage("Line 230: Action is: " + action, 1);
|
|
453 |
logMetacat.warn("Action is: " + action);
|
|
452 | 454 |
|
453 | 455 |
// This block handles session management for the servlet |
454 | 456 |
// by looking up the current session information for all actions |
... | ... | |
495 | 497 |
HttpSession sess = request.getSession(true); |
496 | 498 |
if (sess.isNew() && !params.containsKey("sessionid")) { |
497 | 499 |
// session expired or has not been stored b/w user requests |
498 |
MetaCatUtil.debugMessage(
|
|
499 |
"in session is new or no sessionid", 40);
|
|
500 |
logMetacat.warn(
|
|
501 |
"The session is new or no sessionid is assigned. The user is public");
|
|
500 | 502 |
username = "public"; |
501 | 503 |
sess.setAttribute("username", username); |
502 | 504 |
} else { |
503 |
MetaCatUtil.debugMessage("in session is not new or "
|
|
504 |
+ " has sessionid parameter", 40);
|
|
505 |
logMetacat.warn("The session is not new or "
|
|
506 |
+ " has sessionid parameter"); |
|
505 | 507 |
try { |
506 | 508 |
if (params.containsKey("sessionid")) { |
507 | 509 |
sess_id = ((String[]) params.get("sessionid"))[0]; |
508 |
MetaCatUtil.debugMessage("in has sessionid "
|
|
509 |
+ sess_id, 40);
|
|
510 |
logMetacat.info("in has sessionid "
|
|
511 |
+ sess_id); |
|
510 | 512 |
if (sessionHash.containsKey(sess_id)) { |
511 |
MetaCatUtil.debugMessage("find the id "
|
|
512 |
+ sess_id + " in hash table", 40);
|
|
513 |
logMetacat.info("find the id "
|
|
514 |
+ sess_id + " in hash table"); |
|
513 | 515 |
sess = (HttpSession) sessionHash.get(sess_id); |
514 | 516 |
} |
515 | 517 |
} else { |
516 | 518 |
// we already store the session in login, so we |
517 | 519 |
// don't need here |
518 | 520 |
/* |
519 |
* MetaCatUtil.debugMessage("in no sessionid
|
|
521 |
* logMetacat.info("in no sessionid
|
|
520 | 522 |
* parameter ", 40); sess_id = |
521 | 523 |
* (String)sess.getId(); |
522 |
* MetaCatUtil.debugMessage("storing the session id "
|
|
524 |
* logMetacat.info("storing the session id "
|
|
523 | 525 |
* + sess_id + " which has username " + |
524 | 526 |
* sess.getAttribute("username") + " into session |
525 | 527 |
* hash in handleGetOrPost method", 35); |
526 | 528 |
*/ |
527 | 529 |
} |
528 | 530 |
} catch (IllegalStateException ise) { |
529 |
System.out.println(
|
|
530 |
"error in handleGetOrPost: this shouldn't "
|
|
531 |
logMetacat.error(
|
|
532 |
"Error in handleGetOrPost: this shouldn't "
|
|
531 | 533 |
+ "happen: the session should be valid: " |
532 | 534 |
+ ise.getMessage()); |
533 | 535 |
} |
534 | 536 |
|
535 | 537 |
username = (String) sess.getAttribute("username"); |
536 |
MetaCatUtil.debugMessage("The user name from session is: "
|
|
537 |
+ username, 20);
|
|
538 |
logMetacat.warn("The user name from session is: "
|
|
539 |
+ username); |
|
538 | 540 |
password = (String) sess.getAttribute("password"); |
539 | 541 |
groupnames = (String[]) sess.getAttribute("groupnames"); |
540 | 542 |
} |
... | ... | |
543 | 545 |
if (username == null || (username.trim().equals(""))) { |
544 | 546 |
username = "public"; |
545 | 547 |
} |
546 |
MetaCatUtil.debugMessage("The user is : " + username, 5);
|
|
548 |
logMetacat.warn("The user is : " + username);
|
|
547 | 549 |
} |
548 | 550 |
// Now that we know the session is valid, we can delegate the |
549 | 551 |
// request |
... | ... | |
737 | 739 |
} |
738 | 740 |
|
739 | 741 |
String un = ((String[]) params.get("username"))[0]; |
740 |
MetaCatUtil.debugMessage("user " + un + " try to login", 20);
|
|
742 |
logMetacat.warn("user " + un + " try to login");
|
|
741 | 743 |
String pw = ((String[]) params.get("password"))[0]; |
742 | 744 |
|
743 | 745 |
String qformat = "xml"; |
... | ... | |
759 | 761 |
if (isValid) { |
760 | 762 |
HttpSession session = sess.getSessions(); |
761 | 763 |
String id = session.getId(); |
762 |
MetaCatUtil.debugMessage("Store session id " + id
|
|
764 |
logMetacat.info("Store session id " + id
|
|
763 | 765 |
+ "which has username" + session.getAttribute("username") |
764 |
+ " into hash in login method", 35);
|
|
766 |
+ " into hash in login method"); |
|
765 | 767 |
sessionHash.put(id, session); |
766 | 768 |
} |
767 | 769 |
|
... | ... | |
778 | 780 |
out, null); |
779 | 781 |
} catch (Exception e) { |
780 | 782 |
|
781 |
MetaCatUtil.debugMessage(
|
|
783 |
logMetacat.error(
|
|
782 | 784 |
"Error in MetaCatServlet.handleLoginAction: " |
783 |
+ e.getMessage(), 30);
|
|
785 |
+ e.getMessage()); |
|
784 | 786 |
} |
785 | 787 |
} |
786 | 788 |
} |
... | ... | |
799 | 801 |
|
800 | 802 |
// close the connection |
801 | 803 |
HttpSession sess = request.getSession(false); |
802 |
MetaCatUtil.debugMessage("After get session in logout request", 40);
|
|
804 |
logMetacat.info("After get session in logout request");
|
|
803 | 805 |
if (sess != null) { |
804 |
MetaCatUtil.debugMessage("The session id " + sess.getId()
|
|
805 |
+ " will be invalidate in logout action", 30);
|
|
806 |
MetaCatUtil.debugMessage("The session contains user "
|
|
806 |
logMetacat.info("The session id " + sess.getId()
|
|
807 |
+ " will be invalidate in logout action"); |
|
808 |
logMetacat.warn("The session contains user "
|
|
807 | 809 |
+ sess.getAttribute("username") |
808 |
+ " will be invalidate in logout action", 30);
|
|
810 |
+ " will be invalidate in logout action"); |
|
809 | 811 |
sess.invalidate(); |
810 | 812 |
} |
811 | 813 |
|
... | ... | |
828 | 830 |
"-//NCEAS//login//EN", "-//W3C//HTML//EN", qformat, |
829 | 831 |
out, null); |
830 | 832 |
} catch (Exception e) { |
831 |
MetaCatUtil.debugMessage(
|
|
833 |
logMetacat.error(
|
|
832 | 834 |
"Error in MetaCatServlet.handleLogoutAction" |
833 |
+ e.getMessage(), 30);
|
|
835 |
+ e.getMessage()); |
|
834 | 836 |
} |
835 | 837 |
} |
836 | 838 |
} |
... | ... | |
855 | 857 |
DBQuery queryobj = new DBQuery(saxparser); |
856 | 858 |
queryobj.findDocuments(response, out, params, user, groups, sessionid); |
857 | 859 |
double outPutTime = System.currentTimeMillis() / 1000; |
858 |
MetaCatUtil.debugMessage("total search time: "
|
|
859 |
+ (outPutTime - startTime), 30);
|
|
860 |
logMetacat.warn("Total search time for action 'squery': "
|
|
861 |
+ (outPutTime - startTime)); |
|
860 | 862 |
|
861 | 863 |
} |
862 | 864 |
|
... | ... | |
881 | 883 |
DBQuery queryobj = new DBQuery(saxparser); |
882 | 884 |
queryobj.findDocuments(response, out, params, user, groups, sessionid); |
883 | 885 |
double outPutTime = System.currentTimeMillis() / 1000; |
884 |
MetaCatUtil.debugMessage("total search time: "
|
|
885 |
+ (outPutTime - startTime), 30);
|
|
886 |
logMetacat.warn("Total search time for action 'query': "
|
|
887 |
+ (outPutTime - startTime)); |
|
886 | 888 |
|
887 | 889 |
//handleSQuery(out, params, response,user, groups, sessionid); |
888 | 890 |
} |
... | ... | |
967 | 969 |
zOut.close(); |
968 | 970 |
} |
969 | 971 |
} catch (IOException ioe) { |
970 |
MetaCatUtil.debugMessage("Problem with the servlet output "
|
|
972 |
logMetacat.error("Problem with the servlet output "
|
|
971 | 973 |
+ "in MetacatServlet.handleExportAction: " |
972 |
+ ioe.getMessage(), 30);
|
|
974 |
+ ioe.getMessage()); |
|
973 | 975 |
} |
974 | 976 |
|
975 |
MetaCatUtil.debugMessage(
|
|
977 |
logMetacat.error(
|
|
976 | 978 |
"Error in MetacatServlet.handleExportAction: " |
977 |
+ e.getMessage(), 30);
|
|
979 |
+ e.getMessage()); |
|
978 | 980 |
e.printStackTrace(System.out); |
979 | 981 |
|
980 | 982 |
} |
... | ... | |
1082 | 1084 |
out.close(); |
1083 | 1085 |
} |
1084 | 1086 |
} catch (IOException ioe) { |
1085 |
MetaCatUtil.debugMessage("Problem with the servlet output "
|
|
1087 |
logMetacat.error("Problem with the servlet output "
|
|
1086 | 1088 |
+ "in MetacatServlet.handleExportAction: " |
1087 |
+ ioe.getMessage(), 30);
|
|
1089 |
+ ioe.getMessage()); |
|
1088 | 1090 |
} |
1089 |
MetaCatUtil.debugMessage(
|
|
1091 |
logMetacat.error(
|
|
1090 | 1092 |
"Error in MetacatServlet.handleReadInlineDataAction: " |
1091 |
+ e.getMessage(), 30);
|
|
1093 |
+ e.getMessage()); |
|
1092 | 1094 |
} |
1093 | 1095 |
} |
1094 | 1096 |
|
... | ... | |
1138 | 1140 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
1139 | 1141 |
} |
1140 | 1142 |
} |
1141 |
MetaCatUtil.debugMessage("The nodeid for inlinedataid " + inLineDataId
|
|
1142 |
+ " is: " + nodeId, 35);
|
|
1143 |
logMetacat.info("The nodeid for inlinedataid " + inLineDataId
|
|
1144 |
+ " is: " + nodeId); |
|
1143 | 1145 |
return nodeId; |
1144 | 1146 |
} |
1145 | 1147 |
|
... | ... | |
1244 | 1246 |
// the docid which didn't be found |
1245 | 1247 |
String notFoundDocId = notFoundE.getUnfoundDocId(); |
1246 | 1248 |
String notFoundRevision = notFoundE.getUnfoundRevision(); |
1247 |
MetaCatUtil.debugMessage("Missed id: " + notFoundDocId, 30);
|
|
1248 |
MetaCatUtil.debugMessage("Missed rev: " + notFoundRevision, 30);
|
|
1249 |
logMetacat.warn("Missed id: " + notFoundDocId);
|
|
1250 |
logMetacat.warn("Missed rev: " + notFoundRevision);
|
|
1249 | 1251 |
try { |
1250 | 1252 |
// read docid from remote server |
1251 | 1253 |
readFromRemoteMetaCat(response, notFoundDocId, |
... | ... | |
1260 | 1262 |
} |
1261 | 1263 |
|
1262 | 1264 |
} catch (Exception exc) { |
1263 |
MetaCatUtil.debugMessage(
|
|
1265 |
logMetacat.error(
|
|
1264 | 1266 |
"Erorr in MetacatServlet.hanldReadAction: " |
1265 |
+ exc.getMessage(), 30);
|
|
1267 |
+ exc.getMessage()); |
|
1266 | 1268 |
try { |
1267 | 1269 |
if (out != null) { |
1268 | 1270 |
response.setContentType("text/xml"); |
... | ... | |
1293 | 1295 |
zout.close(); |
1294 | 1296 |
} |
1295 | 1297 |
} catch (IOException ie) { |
1296 |
MetaCatUtil.debugMessage("Problem with the servlet output "
|
|
1298 |
logMetacat.error("Problem with the servlet output "
|
|
1297 | 1299 |
+ "in MetacatServlet.handleReadAction: " |
1298 |
+ ie.getMessage(), 30);
|
|
1300 |
+ ie.getMessage()); |
|
1299 | 1301 |
} |
1300 | 1302 |
} |
1301 | 1303 |
} catch (Exception e) { |
... | ... | |
1329 | 1331 |
} |
1330 | 1332 |
|
1331 | 1333 |
} catch (IOException ioe) { |
1332 |
MetaCatUtil.debugMessage("Problem with the servlet output "
|
|
1334 |
logMetacat.error("Problem with the servlet output "
|
|
1333 | 1335 |
+ "in MetacatServlet.handleReadAction: " |
1334 |
+ ioe.getMessage(), 30);
|
|
1336 |
+ ioe.getMessage()); |
|
1335 | 1337 |
ioe.printStackTrace(System.out); |
1336 | 1338 |
|
1337 | 1339 |
} |
1338 | 1340 |
|
1339 |
MetaCatUtil.debugMessage(
|
|
1341 |
logMetacat.error(
|
|
1340 | 1342 |
"Error in MetacatServlet.handleReadAction: " |
1341 |
+ e.getMessage(), 30);
|
|
1343 |
+ e.getMessage()); |
|
1342 | 1344 |
//e.printStackTrace(System.out); |
1343 | 1345 |
} |
1344 | 1346 |
} |
... | ... | |
1390 | 1392 |
ContentTypeProvider provider = new ContentTypeProvider( |
1391 | 1393 |
docid); |
1392 | 1394 |
contentType = provider.getContentType(); |
1393 |
MetaCatUtil.debugMessage("Final contenttype is: "
|
|
1394 |
+ contentType, 30);
|
|
1395 |
logMetacat.warn("Final contenttype is: "
|
|
1396 |
+ contentType); |
|
1395 | 1397 |
} |
1396 | 1398 |
|
1397 | 1399 |
response.setContentType(contentType); |
... | ... | |
1636 | 1638 |
out.println("<error>"); |
1637 | 1639 |
out.println("Docid not specified"); |
1638 | 1640 |
out.println("</error>"); |
1639 |
MetaCatUtil.debugMessage("Docid not specified",10);
|
|
1641 |
logMetacat.error("Docid not specified");
|
|
1640 | 1642 |
return; |
1641 | 1643 |
} |
1642 | 1644 |
|
... | ... | |
1645 | 1647 |
out.println("<error>"); |
1646 | 1648 |
out.println("User '" + user + "' not allowed to insert and update"); |
1647 | 1649 |
out.println("</error>"); |
1648 |
MetaCatUtil.debugMessage("User '" + user + "' not allowed to insert and update",10);
|
|
1650 |
logMetacat.error("User '" + user + "' not allowed to insert and update");
|
|
1649 | 1651 |
return; |
1650 | 1652 |
} |
1651 | 1653 |
|
... | ... | |
1735 | 1737 |
// write the document to the database |
1736 | 1738 |
try { |
1737 | 1739 |
String accNumber = docid[0]; |
1738 |
MetaCatUtil.debugMessage("" + doAction + " "
|
|
1739 |
+ accNumber + "...", 10);
|
|
1740 |
logMetacat.warn("" + doAction + " "
|
|
1741 |
+ accNumber + "..."); |
|
1740 | 1742 |
if (accNumber.equals("")) { |
1741 | 1743 |
accNumber = null; |
1742 | 1744 |
} |
... | ... | |
1835 | 1837 |
} |
1836 | 1838 |
} |
1837 | 1839 |
|
1838 |
MetaCatUtil.debugMessage("Validation for dtd is " + validate, 10);
|
|
1840 |
logMetacat.warn("Validation for dtd is " + validate);
|
|
1839 | 1841 |
return validate; |
1840 | 1842 |
} |
1841 | 1843 |
|
... | ... | |
1846 | 1848 |
{ |
1847 | 1849 |
boolean needSchemaValidate = false; |
1848 | 1850 |
if (xml == null) { |
1849 |
MetaCatUtil.debugMessage("Validation for schema is "
|
|
1850 |
+ needSchemaValidate, 10);
|
|
1851 |
logMetacat.warn("Validation for schema is "
|
|
1852 |
+ needSchemaValidate); |
|
1851 | 1853 |
return needSchemaValidate; |
1852 | 1854 |
} |
1853 | 1855 |
System.out.println("before get target line"); |
... | ... | |
1861 | 1863 |
needSchemaValidate = true; |
1862 | 1864 |
} |
1863 | 1865 |
|
1864 |
MetaCatUtil.debugMessage("Validation for schema is "
|
|
1865 |
+ needSchemaValidate, 10);
|
|
1866 |
logMetacat.warn("Validation for schema is "
|
|
1867 |
+ needSchemaValidate); |
|
1866 | 1868 |
return needSchemaValidate; |
1867 | 1869 |
|
1868 | 1870 |
} |
... | ... | |
1877 | 1879 |
String eml2_1_0NameSpace = DocumentImpl.EML2_1_0NAMESPACE; |
1878 | 1880 |
|
1879 | 1881 |
if (xml == null) { |
1880 |
MetaCatUtil.debugMessage("Validation for schema is "
|
|
1881 |
+ namespace, 10);
|
|
1882 |
logMetacat.warn("Validation for schema is "
|
|
1883 |
+ namespace); |
|
1882 | 1884 |
return namespace; |
1883 | 1885 |
} |
1884 | 1886 |
String targetLine = getSchemaLine(xml); |
... | ... | |
1905 | 1907 |
} |
1906 | 1908 |
} |
1907 | 1909 |
schemaLocation = targetLine.substring(start + 1, end); |
1908 |
MetaCatUtil.debugMessage("schemaLocation in xml is: "
|
|
1909 |
+ schemaLocation, 30);
|
|
1910 |
logMetacat.info("schemaLocation in xml is: "
|
|
1911 |
+ schemaLocation); |
|
1910 | 1912 |
if (schemaLocation.indexOf(eml2_0_0NameSpace) != -1) { |
1911 | 1913 |
namespace = eml2_0_0NameSpace; |
1912 | 1914 |
} else if (schemaLocation.indexOf(eml2_0_1NameSpace) != -1) { |
... | ... | |
1916 | 1918 |
} |
1917 | 1919 |
} |
1918 | 1920 |
|
1919 |
MetaCatUtil.debugMessage("Validation for eml is " + namespace, |
|
1920 |
10); |
|
1921 |
logMetacat.warn("Validation for eml is " + namespace); |
|
1921 | 1922 |
|
1922 | 1923 |
return namespace; |
1923 | 1924 |
|
... | ... | |
1969 | 1970 |
tmp = xml.read(); |
1970 | 1971 |
} |
1971 | 1972 |
secondLine = buffer.toString(); |
1972 |
MetaCatUtil
|
|
1973 |
.debugMessage("the second line string is: " + secondLine, 25); |
|
1973 |
logMetacat.info("the second line string is: " + secondLine);
|
|
1974 |
|
|
1974 | 1975 |
xml.reset(); |
1975 | 1976 |
return secondLine; |
1976 | 1977 |
} |
... | ... | |
2321 | 2322 |
docid, event, startDate, endDate)); |
2322 | 2323 |
out.close(); |
2323 | 2324 |
} catch (IOException e) { |
2324 |
MetaCatUtil.debugMessage(
|
|
2325 |
"Could not open http response for writing: " + e.getMessage(), 5);
|
|
2325 |
logMetacat.error(
|
|
2326 |
"Could not open http response for writing: " + e.getMessage()); |
|
2326 | 2327 |
} |
2327 | 2328 |
} |
2328 | 2329 |
|
... | ... | |
2383 | 2384 |
out.println("</success>"); |
2384 | 2385 |
out.close(); |
2385 | 2386 |
} catch (IOException e) { |
2386 |
MetaCatUtil.debugMessage(
|
|
2387 |
logMetacat.error(
|
|
2387 | 2388 |
"Could not open http response for writing: " |
2388 |
+ e.getMessage(), 5);
|
|
2389 |
+ e.getMessage()); |
|
2389 | 2390 |
} |
2390 | 2391 |
} |
2391 | 2392 |
|
... | ... | |
2428 | 2429 |
Hashtable fileList = new Hashtable(); |
2429 | 2430 |
int sizeLimit = (new Integer(MetaCatUtil.getOption("datafilesizelimit"))) |
2430 | 2431 |
.intValue(); |
2431 |
MetaCatUtil.debugMessage(
|
|
2432 |
"The limit size of data file is: " + sizeLimit, 50);
|
|
2432 |
logMetacat.info(
|
|
2433 |
"The limit size of data file is: " + sizeLimit); |
|
2433 | 2434 |
|
2434 | 2435 |
try { |
2435 | 2436 |
// MBJ: need to put filesize limit in Metacat config |
... | ... | |
2465 | 2466 |
try { |
2466 | 2467 |
out = response.getWriter(); |
2467 | 2468 |
} catch (IOException ioe2) { |
2468 |
System.err |
|
2469 |
.println("Fatal Error: couldn't get response output stream."); |
|
2469 |
logMetacat.fatal("Fatal Error: couldn't get response output stream."); |
|
2470 | 2470 |
} |
2471 | 2471 |
out.println("<?xml version=\"1.0\"?>"); |
2472 | 2472 |
out.println("<error>"); |
... | ... | |
2504 | 2504 |
try { |
2505 | 2505 |
out = response.getWriter(); |
2506 | 2506 |
} catch (IOException ioe2) { |
2507 |
MetaCatUtil.debugMessage("Fatal Error: couldn't get response "
|
|
2508 |
+ "output stream.", 30);
|
|
2507 |
logMetacat.error("Fatal Error: couldn't get response "
|
|
2508 |
+ "output stream."); |
|
2509 | 2509 |
} |
2510 | 2510 |
|
2511 | 2511 |
if (action.equals("upload")) { |
... | ... | |
2564 | 2564 |
// Get a reference to the file part of the form |
2565 | 2565 |
FilePart filePart = (FilePart) fileList.get("datafile"); |
2566 | 2566 |
String fileName = filePart.getFileName(); |
2567 |
MetaCatUtil.debugMessage("Uploading filename: " + fileName, 10);
|
|
2567 |
logMetacat.warn("Uploading filename: " + fileName);
|
|
2568 | 2568 |
|
2569 | 2569 |
// Check if the right file existed in the uploaded data |
2570 | 2570 |
if (fileName != null) { |
2571 | 2571 |
|
2572 | 2572 |
try { |
2573 |
//MetaCatUtil.debugMessage("Upload datafile " + docid
|
|
2573 |
//logMetacat.info("Upload datafile " + docid
|
|
2574 | 2574 |
// +"...", 10); |
2575 | 2575 |
//If document get lock data file grant |
2576 | 2576 |
if (DocumentImpl.getDataFileLockGrant(docid)) { |
... | ... | |
2693 | 2693 |
//debug |
2694 | 2694 |
if (packageSet != null) { |
2695 | 2695 |
for (int i = 0; i < packageSet.size(); i++) { |
2696 |
MetaCatUtil.debugMessage("doctype in package set: "
|
|
2697 |
+ (String) packageSet.elementAt(i), 34);
|
|
2696 |
logMetacat.info("doctype in package set: "
|
|
2697 |
+ (String) packageSet.elementAt(i)); |
|
2698 | 2698 |
} |
2699 | 2699 |
} |
2700 | 2700 |
|
... | ... | |
2708 | 2708 |
owner = getFieldValueForDoc(accessionNumber, "user_owner"); |
2709 | 2709 |
publicId = getFieldValueForDoc(accessionNumber, "doctype"); |
2710 | 2710 |
} catch (Exception e) { |
2711 |
MetaCatUtil.debugMessage("Error in handleSetAccessAction: "
|
|
2712 |
+ e.getMessage(), 30);
|
|
2711 |
logMetacat.error("Error in handleSetAccessAction: "
|
|
2712 |
+ e.getMessage()); |
|
2713 | 2713 |
error = "Error in set access control for document - " |
2714 | 2714 |
+ accessionNumber + e.getMessage(); |
2715 | 2715 |
errorList.addElement(error); |
... | ... | |
2751 | 2751 |
+ accessionNumber + " successfully"; |
2752 | 2752 |
successList.addElement(success); |
2753 | 2753 |
} catch (Exception ee) { |
2754 |
MetaCatUtil.debugMessage(
|
|
2754 |
logMetacat.error(
|
|
2755 | 2755 |
"Erorr in handleSetAccessAction2: " |
2756 |
+ ee.getMessage(), 30);
|
|
2756 |
+ ee.getMessage()); |
|
2757 | 2757 |
error = "Faild to set access control for document " |
2758 | 2758 |
+ accessionNumber + " because " + ee.getMessage(); |
2759 | 2759 |
errorList.addElement(error); |
... | ... | |
2804 | 2804 |
+ accessionNumber); |
2805 | 2805 |
} |
2806 | 2806 |
} catch (Exception e) { |
2807 |
MetaCatUtil.debugMessage(
|
|
2807 |
logMetacat.error(
|
|
2808 | 2808 |
"Exception in MetacatServlet.getPublicIdForDoc: " |
2809 |
+ e.getMessage(), 30);
|
|
2809 |
+ e.getMessage()); |
|
2810 | 2810 |
throw e; |
2811 | 2811 |
} finally { |
2812 | 2812 |
try { |
... | ... | |
2849 | 2849 |
docList.add(docid + "." + rev); |
2850 | 2850 |
} |
2851 | 2851 |
} catch (SQLException e) { |
2852 |
MetaCatUtil.debugMessage(
|
|
2852 |
logMetacat.error(
|
|
2853 | 2853 |
"Exception in MetacatServlet.getDocumentList: " |
2854 |
+ e.getMessage(), 30);
|
|
2854 |
+ e.getMessage()); |
|
2855 | 2855 |
throw e; |
2856 | 2856 |
} finally { |
2857 | 2857 |
try { |
... | ... | |
2859 | 2859 |
pstmt.close(); |
2860 | 2860 |
|
2861 | 2861 |
} catch (SQLException se) { |
2862 |
MetaCatUtil.debugMessage(
|
|
2862 |
logMetacat.error(
|
|
2863 | 2863 |
"Exception in MetacatServlet.getDocumentList: " |
2864 |
+ se.getMessage(), 30);
|
|
2864 |
+ se.getMessage()); |
|
2865 | 2865 |
throw se; |
2866 | 2866 |
} finally { |
2867 | 2867 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
... | ... | |
2945 | 2945 |
// in other suituation we don't change the docid |
2946 | 2946 |
newAccNum = docid; |
2947 | 2947 |
} |
2948 |
MetaCatUtil.debugMessage("The docid will be read is "+newAccNum, 20);
|
|
2948 |
logMetacat.warn("The docid will be read is "+newAccNum);
|
|
2949 | 2949 |
return newAccNum; |
2950 | 2950 |
} |
2951 | 2951 |
} |
Also available in: Unified diff
Replacing MetaCatUtil.debugMessage or MetaCatUtil.logMetacat call with logMetacat (private Logger object) call