Revision 2663
Added by sgarg over 18 years ago
DocumentImpl.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
54 | 54 |
|
55 |
import org.apache.log4j.Logger; |
|
55 | 56 |
import org.xml.sax.ContentHandler; |
56 | 57 |
import org.xml.sax.DTDHandler; |
57 | 58 |
import org.xml.sax.EntityResolver; |
... | ... | |
124 | 125 |
private ElementNode rootNode = null; |
125 | 126 |
private TreeSet nodeRecordList = null; |
126 | 127 |
|
128 |
private static Logger logMetacat = Logger.getLogger(DocumentImpl.class); |
|
129 |
|
|
127 | 130 |
/** |
128 | 131 |
* Default constructor |
129 | 132 |
* |
... | ... | |
543 | 546 |
private static String checkRevInXMLDocuments(String docid, int userSpecifyRev) throws Exception |
544 | 547 |
{ |
545 | 548 |
String action = null; |
546 |
MetaCatUtil.debugMessage("The user specifyRev: " + userSpecifyRev, 30);
|
|
549 |
logMetacat.info("The user specifyRev: " + userSpecifyRev);
|
|
547 | 550 |
// Revision for this docid in current database |
548 | 551 |
int revInDataBase =DBUtil.getLatestRevisionInDocumentTable(docid); |
549 |
MetaCatUtil.debugMessage("The rev in data base: " + revInDataBase, 30);
|
|
552 |
logMetacat.info("The rev in data base: " + revInDataBase);
|
|
550 | 553 |
// String to store the revision |
551 | 554 |
String rev = null; |
552 | 555 |
|
... | ... | |
598 | 601 |
} |
599 | 602 |
catch (SQLException e) |
600 | 603 |
{ |
601 |
MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+
|
|
602 |
" be found because " + e.getMessage(), 45);
|
|
604 |
logMetacat.error("Local rev for docid "+ docid + " could not "+
|
|
605 |
" be found because " + e.getMessage()); |
|
603 | 606 |
MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+ |
604 | 607 |
"written because error happend to find it's local revision"); |
605 | 608 |
throw new Exception (e.getMessage()); |
606 | 609 |
} |
607 |
MetaCatUtil.debugMessage("rev list in xml_revision table for docid "+ docid + " is "+
|
|
608 |
localrev.toString(), 45);
|
|
610 |
logMetacat.info("rev list in xml_revision table for docid "+ docid + " is "+
|
|
611 |
localrev.toString()); |
|
609 | 612 |
|
610 | 613 |
// if the rev is in the xml_revision, it throws a exception |
611 | 614 |
if (localrev.contains(new Integer(rev))) |
... | ... | |
942 | 945 |
while (it.hasNext()) { |
943 | 946 |
|
944 | 947 |
NodeRecord currentNode = (NodeRecord) it.next(); |
945 |
util.debugMessage("[Got Node ID: " + currentNode.nodeid + " ("
|
|
948 |
logMetacat.info("[Got Node ID: " + currentNode.nodeid + " ("
|
|
946 | 949 |
+ currentNode.parentnodeid + ", " + currentNode.nodeindex |
947 | 950 |
+ ", " + currentNode.nodetype + ", " + currentNode.nodename |
948 |
+ ", " + currentNode.nodedata + ")]", 50);
|
|
951 |
+ ", " + currentNode.nodedata + ")]"); |
|
949 | 952 |
// Print the end tag for the previous node if needed |
950 | 953 |
// |
951 | 954 |
// This is determined by inspecting the parent nodeid for the |
... | ... | |
967 | 970 |
if (currentNode.parentnodeid != currentElement.nodeid) { |
968 | 971 |
while (currentNode.parentnodeid != currentElement.nodeid) { |
969 | 972 |
currentElement = (NodeRecord) openElements.pop(); |
970 |
util.debugMessage("\n POPPED: "
|
|
971 |
+ currentElement.nodename, 50);
|
|
973 |
logMetacat.info("\n POPPED: "
|
|
974 |
+ currentElement.nodename); |
|
972 | 975 |
if (previousNodeWasElement) { |
973 | 976 |
out.print(">"); |
974 | 977 |
previousNodeWasElement = false; |
... | ... | |
1015 | 1018 |
} |
1016 | 1019 |
firstElement = false; |
1017 | 1020 |
openElements.push(currentNode); |
1018 |
util.debugMessage("\n PUSHED: " + currentNode.nodename, 50);
|
|
1021 |
logMetacat.info("\n PUSHED: " + currentNode.nodename);
|
|
1019 | 1022 |
previousNodeWasElement = true; |
1020 | 1023 |
if (currentNode.nodeprefix != null) { |
1021 | 1024 |
out.print("<" + currentNode.nodeprefix + ":" |
... | ... | |
1169 | 1172 |
// Print the final end tag for the root element |
1170 | 1173 |
while (!openElements.empty()) { |
1171 | 1174 |
NodeRecord currentElement = (NodeRecord) openElements.pop(); |
1172 |
util.debugMessage("\n POPPED: " + currentElement.nodename, 50);
|
|
1175 |
logMetacat.info("\n POPPED: " + currentElement.nodename);
|
|
1173 | 1176 |
if (currentElement.nodeprefix != null) { |
1174 | 1177 |
out.print("</" + currentElement.nodeprefix + ":" |
1175 | 1178 |
+ currentElement.nodename + ">"); |
... | ... | |
1212 | 1215 |
/*try { |
1213 | 1216 |
doc = new DocumentIdentifier(docid); |
1214 | 1217 |
} catch (AccessionNumberException e){ |
1215 |
MetaCatUtil.debugMessage("AccessionNumber Exception while "
|
|
1218 |
logMetacat.info("AccessionNumber Exception while "
|
|
1216 | 1219 |
+ " inserting path index " |
1217 | 1220 |
+ "in DocumentImpl.buildIndex for " |
1218 | 1221 |
+ "document " + docid, 10); |
1219 |
MetaCatUtil.debugMessage(e.getMessage(), 10);
|
|
1222 |
logMetacat.info(e.getMessage(), 10);
|
|
1220 | 1223 |
}*/ |
1221 | 1224 |
|
1222 | 1225 |
// Opening separate db connection for deleting and writing |
... | ... | |
1273 | 1276 |
|
1274 | 1277 |
dbConn.commit(); |
1275 | 1278 |
} catch (SQLException e) { |
1276 |
MetaCatUtil.debugMessage("SQL Exception while inserting path index "
|
|
1279 |
logMetacat.error("SQL Exception while inserting path index "
|
|
1277 | 1280 |
+ "in DocumentImpl.buildIndex for " |
1278 |
+ "document " + docid, 10);
|
|
1279 |
MetaCatUtil.debugMessage(e.getMessage(), 10);
|
|
1281 |
+ "document " + docid); |
|
1282 |
logMetacat.error(e.getMessage());
|
|
1280 | 1283 |
try { |
1281 | 1284 |
dbConn.rollback(); |
1282 | 1285 |
} catch (SQLException sqle) { |
1283 |
MetaCatUtil.debugMessage("Error while rolling back "
|
|
1286 |
logMetacat.error("Error while rolling back "
|
|
1284 | 1287 |
+ "commit in DocumentImpl" |
1285 | 1288 |
+ ".buildIndex" + "\n" |
1286 |
+ sqle.getMessage(), 10);
|
|
1289 |
+ sqle.getMessage()); |
|
1287 | 1290 |
} |
1288 | 1291 |
} finally { |
1289 | 1292 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
... | ... | |
1351 | 1354 |
pstmt.close(); |
1352 | 1355 |
dbConn.increaseUsageCount(1); |
1353 | 1356 |
|
1354 |
MetaCatUtil.debugMessage("Indexed " + count |
|
1355 |
+ " records from xml_nodes", |
|
1356 |
20); |
|
1357 |
logMetacat.warn("Indexed " + count |
|
1358 |
+ " records from xml_nodes"); |
|
1357 | 1359 |
|
1358 | 1360 |
dbConn.commit(); |
1359 | 1361 |
} catch (SQLException e) { |
1360 |
MetaCatUtil.debugMessage("SQL Exception while inserting path index "
|
|
1362 |
logMetacat.error("SQL Exception while inserting path index "
|
|
1361 | 1363 |
+ "in DocumentImpl.buildIndex for " |
1362 |
+ "document " + docid, 10);
|
|
1363 |
MetaCatUtil.debugMessage(e.getMessage(), 10);
|
|
1364 |
+ "document " + docid); |
|
1365 |
logMetacat.error(e.getMessage());
|
|
1364 | 1366 |
try { |
1365 | 1367 |
dbConn.rollback(); |
1366 | 1368 |
} catch (SQLException sqle) { |
1367 |
MetaCatUtil.debugMessage("Error while rolling back "
|
|
1369 |
logMetacat.error("Error while rolling back "
|
|
1368 | 1370 |
+ "commit in DocumentImpl" |
1369 | 1371 |
+ ".buildIndex" + "\n" |
1370 |
+ sqle.getMessage(), 10);
|
|
1372 |
+ sqle.getMessage()); |
|
1371 | 1373 |
} |
1372 | 1374 |
} finally { |
1373 | 1375 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
... | ... | |
1400 | 1402 |
if (current.nodetype.equals("ATTRIBUTE")) { |
1401 | 1403 |
currentName = "@" + currentName; |
1402 | 1404 |
} |
1403 |
MetaCatUtil.debugMessage("A: " + currentName +"\n", 60);
|
|
1405 |
logMetacat.debug("A: " + currentName +"\n");
|
|
1404 | 1406 |
pathList.put(currentName, new PathIndexEntry(leafNodeId, |
1405 | 1407 |
currentName, docid, doctype, parentId)); |
1406 | 1408 |
} |
... | ... | |
1412 | 1414 |
} |
1413 | 1415 |
String path = current.getNodeName() + children; |
1414 | 1416 |
if (!children.equals("")) { |
1415 |
MetaCatUtil.debugMessage("B: " + path +"\n", 60);
|
|
1417 |
logMetacat.debug("B: " + path +"\n");
|
|
1416 | 1418 |
pathList.put(path, new PathIndexEntry(leafNodeId, path, docid, |
1417 | 1419 |
doctype, parentId)); |
1418 | 1420 |
} |
1419 | 1421 |
if (id == rootNodeId) { |
1420 | 1422 |
String fullPath = '/' + path; |
1421 |
MetaCatUtil.debugMessage("C: " + fullPath +"\n", 60);
|
|
1423 |
logMetacat.debug("C: " + fullPath +"\n");
|
|
1422 | 1424 |
pathList.put(fullPath, new PathIndexEntry(leafNodeId, fullPath, |
1423 | 1425 |
docid, doctype, parentId)); |
1424 | 1426 |
} |
... | ... | |
1437 | 1439 |
//String familyId = MetaCatUtil.getDocIdFromString(docid); |
1438 | 1440 |
String familyId = docid; |
1439 | 1441 |
String sql = "DELETE FROM xml_index WHERE docid LIKE ?"; |
1440 |
MetaCatUtil.debugMessage(sql, 55);
|
|
1441 |
MetaCatUtil.debugMessage("SQL is: " + sql, 60);
|
|
1442 |
logMetacat.debug(sql);
|
|
1443 |
logMetacat.debug("SQL is: " + sql);
|
|
1442 | 1444 |
|
1443 | 1445 |
PreparedStatement pstmt = conn.prepareStatement(sql); |
1444 | 1446 |
|
... | ... | |
1449 | 1451 |
pstmt.setString(1, familyId); |
1450 | 1452 |
int rows = pstmt.executeUpdate(); |
1451 | 1453 |
pstmt.close(); |
1452 |
MetaCatUtil.debugMessage("Deleted " + rows + " rows from xml_index " +
|
|
1453 |
"for document " + docid, 55);
|
|
1454 |
logMetacat.debug("Deleted " + rows + " rows from xml_index " +
|
|
1455 |
"for document " + docid); |
|
1454 | 1456 |
} |
1455 | 1457 |
|
1456 | 1458 |
/** |
... | ... | |
1479 | 1481 |
Iterator it = pathList.values().iterator(); |
1480 | 1482 |
while (it.hasNext()) { |
1481 | 1483 |
PathIndexEntry entry = (PathIndexEntry)it.next(); |
1482 |
MetaCatUtil.debugMessage("Inserting: " + entry.nodeId +
|
|
1483 |
" (" + entry.parentId + "): " + entry.path, 60);
|
|
1484 |
logMetacat.debug("Inserting: " + entry.nodeId +
|
|
1485 |
" (" + entry.parentId + "): " + entry.path); |
|
1484 | 1486 |
pstmt.setLong(1, entry.nodeId); |
1485 | 1487 |
pstmt.setString(2, entry.path); |
1486 | 1488 |
pstmt.setLong(5, entry.parentId); |
... | ... | |
1590 | 1592 |
throw notFound; |
1591 | 1593 |
} catch (Exception e) { |
1592 | 1594 |
|
1593 |
MetaCatUtil.debugMessage("error in DocumentImpl.getDocumentInfo: "
|
|
1594 |
+ e.getMessage(), 30);
|
|
1595 |
logMetacat.error("error in DocumentImpl.getDocumentInfo: "
|
|
1596 |
+ e.getMessage()); |
|
1595 | 1597 |
throw e; |
1596 | 1598 |
} |
1597 | 1599 |
|
... | ... | |
1645 | 1647 |
this.docHomeServer = MetaCatUtil |
1646 | 1648 |
.getLocalReplicationServerName(); |
1647 | 1649 |
} |
1648 |
MetaCatUtil.debugMessage("server: " + docHomeServer, 50);
|
|
1650 |
logMetacat.info("server: " + docHomeServer);
|
|
1649 | 1651 |
|
1650 | 1652 |
} |
1651 | 1653 |
pstmt.close(); |
... | ... | |
1668 | 1670 |
pstmt.close(); |
1669 | 1671 |
} |
1670 | 1672 |
} catch (SQLException e) { |
1671 |
MetaCatUtil.debugMessage("error in DocumentImpl.getDocumentInfo: "
|
|
1672 |
+ e.getMessage(), 30);
|
|
1673 |
logMetacat.error("error in DocumentImpl.getDocumentInfo: "
|
|
1674 |
+ e.getMessage()); |
|
1673 | 1675 |
e.printStackTrace(System.out); |
1674 | 1676 |
throw new McdbException("Error accessing database connection in " |
1675 | 1677 |
+ "DocumentImpl.getDocumentInfo: ", e); |
... | ... | |
1677 | 1679 |
try { |
1678 | 1680 |
pstmt.close(); |
1679 | 1681 |
} catch (SQLException ee) { |
1680 |
MetaCatUtil.debugMessage(
|
|
1682 |
logMetacat.error(
|
|
1681 | 1683 |
"error in DocumentImple.getDocumentInfo: " |
1682 |
+ ee.getMessage(), 30);
|
|
1684 |
+ ee.getMessage()); |
|
1683 | 1685 |
} finally { |
1684 | 1686 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
1685 | 1687 |
} |
... | ... | |
1729 | 1731 |
+ ")"; |
1730 | 1732 |
|
1731 | 1733 |
} |
1732 |
MetaCatUtil.debugMessage("The final query to select part node tree: "
|
|
1733 |
+ sql, 25);
|
|
1734 |
logMetacat.info("The final query to select part node tree: "
|
|
1735 |
+ sql); |
|
1734 | 1736 |
|
1735 | 1737 |
try { |
1736 | 1738 |
dbconn = DBConnectionPool |
... | ... | |
1770 | 1772 |
try { |
1771 | 1773 |
pstmt.close(); |
1772 | 1774 |
} catch (SQLException ee) { |
1773 |
MetaCatUtil.debugMessage(
|
|
1775 |
logMetacat.error(
|
|
1774 | 1776 |
"error in DocumentImpl.getPartNodeRecordList: " |
1775 |
+ ee.getMessage(), 30);
|
|
1777 |
+ ee.getMessage()); |
|
1776 | 1778 |
} finally { |
1777 | 1779 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
1778 | 1780 |
} |
... | ... | |
1819 | 1821 |
throw notFound; |
1820 | 1822 |
} catch (Exception e) { |
1821 | 1823 |
|
1822 |
MetaCatUtil.debugMessage("error in DocumentImpl.getDocumentInfo: "
|
|
1823 |
+ e.getMessage(), 30);
|
|
1824 |
logMetacat.error("error in DocumentImpl.getDocumentInfo: "
|
|
1825 |
+ e.getMessage()); |
|
1824 | 1826 |
} |
1825 | 1827 |
//System.out.println("in getNodeREcorelist !!!!!!!!!!!3"); |
1826 | 1828 |
try { |
... | ... | |
1867 | 1869 |
try { |
1868 | 1870 |
pstmt.close(); |
1869 | 1871 |
} catch (SQLException ee) { |
1870 |
MetaCatUtil.debugMessage(
|
|
1872 |
logMetacat.error(
|
|
1871 | 1873 |
"error in DocumentImpl.getNodeRecordList: " |
1872 |
+ ee.getMessage(), 30);
|
|
1874 |
+ ee.getMessage()); |
|
1873 | 1875 |
} finally { |
1874 | 1876 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
1875 | 1877 |
} |
... | ... | |
1946 | 1948 |
|
1947 | 1949 |
} else if (action.equals("UPDATE")) { |
1948 | 1950 |
int thisrev = DBUtil.getLatestRevisionInDocumentTable(docid); |
1949 |
MetaCatUtil.debugMessage("this revsion is: " + thisrev, 40);
|
|
1951 |
logMetacat.info("this revsion is: " + thisrev);
|
|
1950 | 1952 |
// Save the old document publicaccessentry in a backup table |
1951 | 1953 |
String accNumber = docid+MetaCatUtil.getOption("accNumSeparator")+thisrev; |
1952 | 1954 |
thisdoc = new DocumentImpl(accNumber, false); |
1953 | 1955 |
DocumentImpl.archiveDocAndNodesRevision(connection, docid, user, thisdoc); |
1954 |
MetaCatUtil.debugMessage("after archiveDoc", 30);
|
|
1956 |
logMetacat.info("after archiveDoc");
|
|
1955 | 1957 |
//if the updated vesion is not greater than current one, |
1956 | 1958 |
//throw it into a exception |
1957 | 1959 |
if (rev <= thisrev) { |
... | ... | |
1961 | 1963 |
//set the user specified revision |
1962 | 1964 |
thisrev = rev; |
1963 | 1965 |
} |
1964 |
MetaCatUtil.debugMessage("final revsion is: " + thisrev, 40);
|
|
1966 |
logMetacat.info("final revsion is: " + thisrev);
|
|
1965 | 1967 |
boolean useXMLIndex = (new Boolean(MetaCatUtil |
1966 | 1968 |
.getOption("usexmlindex"))).booleanValue(); |
1967 | 1969 |
if (useXMLIndex) { |
1968 |
MetaCatUtil.debugMessage("before delete", 40);
|
|
1970 |
logMetacat.info("before delete");
|
|
1969 | 1971 |
// Delete index for the old version of docid |
1970 | 1972 |
// The new index is inserting on the next calls to DBSAXNode |
1971 | 1973 |
pstmt = connection |
1972 | 1974 |
.prepareStatement("DELETE FROM xml_index WHERE docid='" |
1973 | 1975 |
+ this.docid + "'"); |
1974 |
MetaCatUtil.debugMessage("after delete", 40);
|
|
1976 |
logMetacat.info("after delete");
|
|
1975 | 1977 |
// Increase dbconnection usage count |
1976 | 1978 |
connection.increaseUsageCount(1); |
1977 | 1979 |
|
... | ... | |
2121 | 2123 |
{ |
2122 | 2124 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
2123 | 2125 |
//MetaCatUtil util = new MetaCatUtil(); |
2124 |
MetaCatUtil.debugMessage("conn usage count before writting: "
|
|
2125 |
+ conn.getUsageCount(), 50);
|
|
2126 |
logMetacat.info("conn usage count before writting: "
|
|
2127 |
+ conn.getUsageCount()); |
|
2126 | 2128 |
AccessionNumber ac = new AccessionNumber(accnum, action); |
2127 | 2129 |
String docid = ac.getDocid(); |
2128 | 2130 |
String rev = ac.getRev(); |
2129 |
MetaCatUtil.debugMessage("action: " + action + " servercode: "
|
|
2130 |
+ serverCode + " override: " + override, 10);
|
|
2131 |
logMetacat.warn("action: " + action + " servercode: "
|
|
2132 |
+ serverCode + " override: " + override); |
|
2131 | 2133 |
|
2132 | 2134 |
if ((serverCode != 1 && action.equals("UPDATE")) && !override) { |
2133 | 2135 |
// if this document being written is not a resident of this server |
... | ... | |
2292 | 2294 |
pstmt.close(); |
2293 | 2295 |
conn.increaseUsageCount(1); |
2294 | 2296 |
} catch (Exception e){ |
2295 |
MetaCatUtil.debugMessage("Error in deleting enteries from "
|
|
2297 |
logMetacat.error("Error in deleting enteries from "
|
|
2296 | 2298 |
+ "xml_queryresult where docid is " |
2297 | 2299 |
+ docid + " in DBQuery.write: " |
2298 |
+ e.getMessage(), 20);
|
|
2300 |
+ e.getMessage()); |
|
2299 | 2301 |
} |
2300 | 2302 |
|
2301 | 2303 |
} |
... | ... | |
2307 | 2309 |
ForceReplicationHandler frh = new ForceReplicationHandler(accnum, |
2308 | 2310 |
action, true, null); |
2309 | 2311 |
|
2310 |
MetaCatUtil.debugMessage("Conn Usage count after writting: "
|
|
2311 |
+ conn.getUsageCount(), 50);
|
|
2312 |
logMetacat.info("Conn Usage count after writting: "
|
|
2313 |
+ conn.getUsageCount()); |
|
2312 | 2314 |
return (accnum); |
2313 | 2315 |
} |
2314 | 2316 |
|
... | ... | |
2349 | 2351 |
String docType = null; |
2350 | 2352 |
String docName = null; |
2351 | 2353 |
String catalogId = null; |
2352 |
MetaCatUtil.debugMessage("user in replication" + user, 30);
|
|
2354 |
logMetacat.info("user in replication" + user);
|
|
2353 | 2355 |
// Docid without revision |
2354 | 2356 |
String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum); |
2355 | 2357 |
// Revision specified by user (int) |
2356 | 2358 |
int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum); |
2357 |
MetaCatUtil.debugMessage("The user specifyRev: " + userSpecifyRev, 30);
|
|
2359 |
logMetacat.info("The user specifyRev: " + userSpecifyRev);
|
|
2358 | 2360 |
// Revision for this docid in current database |
2359 | 2361 |
int revInDataBase = DBUtil.getLatestRevisionInDocumentTable(docid); |
2360 |
MetaCatUtil.debugMessage("The rev in data base: " + revInDataBase, 30);
|
|
2362 |
logMetacat.info("The rev in data base: " + revInDataBase);
|
|
2361 | 2363 |
// String to store the revision |
2362 | 2364 |
String rev = (new Integer(userSpecifyRev)).toString(); |
2363 | 2365 |
|
... | ... | |
2383 | 2385 |
// Get server code again |
2384 | 2386 |
serverCode = getServerCode(homeServer); |
2385 | 2387 |
|
2386 |
MetaCatUtil |
|
2387 |
.debugMessage("Document " + docid + "." + rev + " " + action |
|
2388 |
logMetacat.warn("Document " + docid + "." + rev + " " + action |
|
2388 | 2389 |
+ " into local" + " metacat with servercode: " |
2389 |
+ serverCode, 10);
|
|
2390 |
+ serverCode); |
|
2390 | 2391 |
|
2391 | 2392 |
// insert into xml_nodes table |
2392 | 2393 |
XMLReader parser = null; |
... | ... | |
2465 | 2466 |
MetacatReplication.replErrorLog("Failed to " + "create access " |
2466 | 2467 |
+ "rule for package: " + accnum + " because " |
2467 | 2468 |
+ ee.getMessage()); |
2468 |
MetaCatUtil.debugMessage("Failed to " + "create access "
|
|
2469 |
logMetacat.error("Failed to " + "create access "
|
|
2469 | 2470 |
+ "rule for package: " + accnum + " because " |
2470 |
+ ee.getMessage(), 30);
|
|
2471 |
+ ee.getMessage()); |
|
2471 | 2472 |
} |
2472 | 2473 |
//Force replication to other server |
2473 | 2474 |
if (!timedReplication) |
... | ... | |
2536 | 2537 |
dbconn.rollback(); |
2537 | 2538 |
dbconn.setAutoCommit(true); |
2538 | 2539 |
} |
2539 |
MetaCatUtil.debugMessage(
|
|
2540 |
logMetacat.error(
|
|
2540 | 2541 |
"Error in DocumentImple.runRelationAndAccessHandler " |
2541 |
+ e.getMessage(), 30);
|
|
2542 |
+ e.getMessage()); |
|
2542 | 2543 |
throw e; |
2543 | 2544 |
} finally { |
2544 | 2545 |
if (dbconn != null) { |
... | ... | |
2589 | 2590 |
pstate.close(); |
2590 | 2591 |
}//try |
2591 | 2592 |
catch (SQLException e) { |
2592 |
MetaCatUtil.debugMessage("error in DocumentImpl." |
|
2593 |
+ "getDocTypeFromDBForCurrentDocument " + e.getMessage(), |
|
2594 |
30); |
|
2593 |
logMetacat.error("error in DocumentImpl." |
|
2594 |
+ "getDocTypeFromDBForCurrentDocument " + e.getMessage()); |
|
2595 | 2595 |
throw e; |
2596 | 2596 |
}//catch |
2597 | 2597 |
finally { |
2598 | 2598 |
pstate.close(); |
2599 | 2599 |
DBConnectionPool.returnDBConnection(dbConnection, serialNumber); |
2600 | 2600 |
}// |
2601 |
MetaCatUtil.debugMessage("The current doctype from db is: "
|
|
2602 |
+ docoumentType, 35);
|
|
2601 |
logMetacat.info("The current doctype from db is: "
|
|
2602 |
+ docoumentType); |
|
2603 | 2603 |
return docoumentType; |
2604 | 2604 |
} |
2605 | 2605 |
|
... | ... | |
2654 | 2654 |
isXML = false; |
2655 | 2655 |
} |
2656 | 2656 |
|
2657 |
MetaCatUtil.debugMessage("Start deleting doc " + docid + "...", 20);
|
|
2657 |
logMetacat.warn("Start deleting doc " + docid + "...");
|
|
2658 | 2658 |
// check for 'write' permission for 'user' to delete this document |
2659 | 2659 |
if (!hasAllPermission(user, groups, accnum)) { |
2660 | 2660 |
if(!MetaCatUtil.isAdministrator(user, groups)){ |
... | ... | |
2760 | 2760 |
conn.setAutoCommit(true); |
2761 | 2761 |
|
2762 | 2762 |
} catch (Exception e) { |
2763 |
MetaCatUtil.debugMessage("error in DocumentImpl.delete: " |
|
2764 |
+ e.getMessage(), 30); |
|
2765 |
e.printStackTrace(); |
|
2763 |
logMetacat.error("error in DocumentImpl.delete: " |
|
2764 |
+ e.getMessage()); |
|
2766 | 2765 |
throw e; |
2767 | 2766 |
} finally { |
2768 | 2767 |
|
... | ... | |
2796 | 2795 |
{ |
2797 | 2796 |
type = result.getString(1); |
2798 | 2797 |
} |
2799 |
MetaCatUtil.debugMessage("The type of deleting docid " + docidWithoutRev +
|
|
2800 |
" is " + type, 2);
|
|
2798 |
logMetacat.warn("The type of deleting docid " + docidWithoutRev +
|
|
2799 |
" is " + type); |
|
2801 | 2800 |
return type; |
2802 | 2801 |
} |
2803 | 2802 |
|
... | ... | |
2862 | 2861 |
String parserName = MetaCatUtil.getOption("saxparser"); |
2863 | 2862 |
parser = XMLReaderFactory.createXMLReader(parserName); |
2864 | 2863 |
if (ruleBase != null && ruleBase.equals(EML200)) { |
2865 |
MetaCatUtil.debugMessage("eml 2.0.0 parser", 20);
|
|
2864 |
logMetacat.warn("eml 2.0.0 parser");
|
|
2866 | 2865 |
chandler = new Eml200SAXHandler(dbconn, action, docid, rev, |
2867 | 2866 |
user, groups, pub, serverCode, createDate, updateDate); |
2868 | 2867 |
chandler.setIsRevisionDoc(isRevision); |
... | ... | |
2887 | 2886 |
externalSchemaLocation); |
2888 | 2887 |
} |
2889 | 2888 |
} else if (ruleBase != null && ruleBase.equals(EML210)) { |
2890 |
MetaCatUtil.debugMessage("eml 2.1.0 parser", 20);
|
|
2889 |
logMetacat.warn("eml 2.1.0 parser");
|
|
2891 | 2890 |
chandler = new Eml210SAXHandler(dbconn, action, docid, rev, |
2892 | 2891 |
user, groups, pub, serverCode, createDate, updateDate); |
2893 | 2892 |
chandler.setIsRevisionDoc(isRevision); |
... | ... | |
2924 | 2923 |
|
2925 | 2924 |
if (ruleBase != null && ruleBase.equals(SCHEMA) |
2926 | 2925 |
&& needValidation) { |
2927 |
MetaCatUtil.debugMessage("General schema parser", 20);
|
|
2926 |
logMetacat.warn("General schema parser");
|
|
2928 | 2927 |
// turn on schema validation feature |
2929 | 2928 |
parser.setFeature(VALIDATIONFEATURE, true); |
2930 | 2929 |
parser.setFeature(NAMESPACEFEATURE, true); |
... | ... | |
2945 | 2944 |
|
2946 | 2945 |
} else if (ruleBase != null && ruleBase.equals(DTD) |
2947 | 2946 |
&& needValidation) { |
2948 |
MetaCatUtil.debugMessage("dtd parser", 20);
|
|
2947 |
logMetacat.warn("dtd parser");
|
|
2949 | 2948 |
// turn on dtd validaton feature |
2950 | 2949 |
parser.setFeature(VALIDATIONFEATURE, true); |
2951 | 2950 |
eresolver = new DBEntityResolver(dbconn, |
... | ... | |
2954 | 2953 |
parser.setEntityResolver((EntityResolver) eresolver); |
2955 | 2954 |
parser.setDTDHandler((DTDHandler) dtdhandler); |
2956 | 2955 |
} else { |
2957 |
MetaCatUtil.debugMessage("other parser", 20);
|
|
2956 |
logMetacat.warn("other parser");
|
|
2958 | 2957 |
// non validation |
2959 | 2958 |
parser.setFeature(VALIDATIONFEATURE, false); |
2960 | 2959 |
eresolver = new DBEntityResolver(dbconn, |
... | ... | |
2995 | 2994 |
archiveDocAndNodesRevison(dbconn, docid, user, rootNodeId); |
2996 | 2995 |
|
2997 | 2996 |
}catch (Exception e) { |
2998 |
MetaCatUtil.debugMessage(
|
|
2997 |
logMetacat.error(
|
|
2999 | 2998 |
"Error in DocumentImpl.archiveDocRevision : " |
3000 |
+ e.getMessage(), 30);
|
|
2999 |
+ e.getMessage()); |
|
3001 | 3000 |
} |
3002 | 3001 |
|
3003 | 3002 |
|
... | ... | |
3043 | 3042 |
pstmt.close(); |
3044 | 3043 |
|
3045 | 3044 |
} catch (SQLException e) { |
3046 |
MetaCatUtil.debugMessage(
|
|
3045 |
logMetacat.error(
|
|
3047 | 3046 |
"Error in DocumentImpl.archiveDocAndNodesRevision : " |
3048 |
+ e.getMessage(), 30);
|
|
3047 |
+ e.getMessage()); |
|
3049 | 3048 |
throw e; |
3050 | 3049 |
} catch (Exception e) { |
3051 |
MetaCatUtil.debugMessage(
|
|
3050 |
logMetacat.error(
|
|
3052 | 3051 |
"Error in DocumentImpl.archiveDocAndNodesRevision : " |
3053 |
+ e.getMessage(), 30);
|
|
3052 |
+ e.getMessage()); |
|
3054 | 3053 |
throw e; |
3055 | 3054 |
} |
3056 | 3055 |
finally { |
3057 | 3056 |
try { |
3058 | 3057 |
pstmt.close(); |
3059 | 3058 |
} catch (SQLException ee) { |
3060 |
MetaCatUtil.debugMessage(
|
|
3059 |
logMetacat.error(
|
|
3061 | 3060 |
"Error in DocumnetImpl.archiveDocRevision: " |
3062 |
+ ee.getMessage(), 50);
|
|
3061 |
+ ee.getMessage()); |
|
3063 | 3062 |
} |
3064 | 3063 |
} |
3065 | 3064 |
|
... | ... | |
3068 | 3067 |
private static void moveNodesToNodesRevision(DBConnection dbconn, |
3069 | 3068 |
long rootNodeId) throws Exception |
3070 | 3069 |
{ |
3071 |
MetaCatUtil.debugMessage("the root node id is "+rootNodeId+
|
|
3072 |
" will be moved from xml_nodes to xml_node_revision table", 20);
|
|
3070 |
logMetacat.warn("the root node id is "+rootNodeId+
|
|
3071 |
" will be moved from xml_nodes to xml_node_revision table"); |
|
3073 | 3072 |
PreparedStatement pstmt = null; |
3074 | 3073 |
// Move the nodes from xml_nodes to xml_revisions table... |
3075 | 3074 |
pstmt = dbconn.prepareStatement("INSERT INTO xml_nodes_revisions " |
... | ... | |
3120 | 3119 |
pstmt.execute(); |
3121 | 3120 |
pstmt.close(); |
3122 | 3121 |
} catch (SQLException e) { |
3123 |
MetaCatUtil.debugMessage(
|
|
3122 |
logMetacat.error(
|
|
3124 | 3123 |
"Error in DocumentImpl.archiveDocRevision : " |
3125 |
+ e.getMessage(), 30);
|
|
3124 |
+ e.getMessage()); |
|
3126 | 3125 |
throw e; |
3127 | 3126 |
} finally { |
3128 | 3127 |
try { |
3129 | 3128 |
pstmt.close(); |
3130 | 3129 |
} catch (SQLException ee) { |
3131 |
MetaCatUtil.debugMessage(
|
|
3130 |
logMetacat.error(
|
|
3132 | 3131 |
"Error in DocumnetImpl.archiveDocRevision: " |
3133 |
+ ee.getMessage(), 50);
|
|
3132 |
+ ee.getMessage()); |
|
3134 | 3133 |
throw ee; |
3135 | 3134 |
} finally { |
3136 | 3135 |
//check in DBConnection |
... | ... | |
3163 | 3162 |
try { |
3164 | 3163 |
pStmt.close(); |
3165 | 3164 |
} catch (SQLException e) { |
3166 |
MetaCatUtil.debugMessage(
|
|
3165 |
logMetacat.error(
|
|
3167 | 3166 |
"error in DocumentImpl.deleteXMLDocuments: " |
3168 |
+ e.getMessage(), 50);
|
|
3167 |
+ e.getMessage()); |
|
3169 | 3168 |
} finally { |
3170 | 3169 |
//return back DBconnection |
3171 | 3170 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
... | ... | |
3221 | 3220 |
pStmt.close(); |
3222 | 3221 |
}//try |
3223 | 3222 |
catch (Exception ee) { |
3224 |
MetaCatUtil.debugMessage(
|
|
3223 |
logMetacat.error(
|
|
3225 | 3224 |
"Error in DocumentImpl.getServerLocationNu(): " |
3226 |
+ ee.getMessage(), 50);
|
|
3225 |
+ ee.getMessage()); |
|
3227 | 3226 |
}//catch |
3228 | 3227 |
finally { |
3229 | 3228 |
DBConnectionPool.returnDBConnection(conn, serialNumber); |
... | ... | |
3277 | 3276 |
pStmt.close(); |
3278 | 3277 |
} |
3279 | 3278 |
} catch (Exception e) { |
3280 |
MetaCatUtil.debugMessage("Error in DocumentImpl.getServerCode(): "
|
|
3281 |
+ e.getMessage(), 30);
|
|
3279 |
logMetacat.error("Error in DocumentImpl.getServerCode(): "
|
|
3280 |
+ e.getMessage()); |
|
3282 | 3281 |
} finally { |
3283 | 3282 |
try { |
3284 | 3283 |
pStmt.close(); |
3285 | 3284 |
} catch (Exception ee) { |
3286 |
MetaCatUtil.debugMessage(
|
|
3285 |
logMetacat.error(
|
|
3287 | 3286 |
"Error in DocumentImpl.getServerCode(): " |
3288 |
+ ee.getMessage(), 50);
|
|
3287 |
+ ee.getMessage()); |
|
3289 | 3288 |
} finally { |
3290 | 3289 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
3291 | 3290 |
} |
... | ... | |
3360 | 3359 |
} |
3361 | 3360 |
}//try |
3362 | 3361 |
catch (Exception e) { |
3363 |
MetaCatUtil.debugMessage(
|
|
3362 |
logMetacat.error(
|
|
3364 | 3363 |
"Error in DocumentImpl.insertServerIntoRepli(): " |
3365 |
+ e.getMessage(), 30);
|
|
3364 |
+ e.getMessage()); |
|
3366 | 3365 |
}//catch |
3367 | 3366 |
finally { |
3368 | 3367 |
|
... | ... | |
3373 | 3372 |
|
3374 | 3373 |
}//try |
3375 | 3374 |
catch (Exception ee) { |
3376 |
MetaCatUtil.debugMessage(
|
|
3375 |
logMetacat.error(
|
|
3377 | 3376 |
"Error in DocumentImpl.insetServerIntoRepl(): " |
3378 |
+ ee.getMessage(), 50);
|
|
3377 |
+ ee.getMessage()); |
|
3379 | 3378 |
}//catch |
3380 | 3379 |
finally { |
3381 | 3380 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
... | ... | |
3481 | 3480 |
if (action.equals("READ")) { |
3482 | 3481 |
DocumentImpl xmldoc = new DocumentImpl(docid); |
3483 | 3482 |
if (useOldReadAlgorithm) { |
3484 |
MetaCatUtil.debugMessage(xmldoc.readUsingSlowAlgorithm(), 10);
|
|
3483 |
logMetacat.error(xmldoc.readUsingSlowAlgorithm());
|
|
3485 | 3484 |
} else { |
3486 | 3485 |
xmldoc.toXml(new PrintWriter(System.out), null, null, true); |
3487 | 3486 |
} |
... | ... | |
3508 | 3507 |
double insertTime = (stopTime - connTime) / 1000; |
3509 | 3508 |
double executionTime = (stopTime - startTime) / 1000; |
3510 | 3509 |
if (showRuntime) { |
3511 |
MetaCatUtil.debugMessage("\n\nTotal Execution time was: "
|
|
3512 |
+ executionTime + " seconds.", 10);
|
|
3513 |
MetaCatUtil.debugMessage("Time to open DB connection was: "
|
|
3514 |
+ dbOpenTime + " seconds.", 10);
|
|
3515 |
MetaCatUtil.debugMessage("Time to insert document was: " + insertTime
|
|
3516 |
+ " seconds.", 10);
|
|
3510 |
logMetacat.warn("\n\nTotal Execution time was: "
|
|
3511 |
+ executionTime + " seconds."); |
|
3512 |
logMetacat.warn("Time to open DB connection was: "
|
|
3513 |
+ dbOpenTime + " seconds."); |
|
3514 |
logMetacat.warn("Time to insert document was: " + insertTime
|
|
3515 |
+ " seconds."); |
|
3517 | 3516 |
} |
3518 | 3517 |
dbconn.close(); |
3519 | 3518 |
} catch (McdbException me) { |
... | ... | |
3550 | 3549 |
{ |
3551 | 3550 |
createDate = dbAdapter.toDate(createDate, "YYYY-MM-DD HH24:MI:SS"); |
3552 | 3551 |
} |
3553 |
MetaCatUtil.debugMessage("the create date is "+createDate, 30);
|
|
3552 |
logMetacat.info("the create date is "+createDate);
|
|
3554 | 3553 |
if (updateDate == null) |
3555 | 3554 |
{ |
3556 | 3555 |
updateDate = dbAdapter.getDateTimeFunction(); |
... | ... | |
3559 | 3558 |
{ |
3560 | 3559 |
updateDate = dbAdapter.toDate(updateDate, "YYYY-MM-DD HH24:MI:SS"); |
3561 | 3560 |
} |
3562 |
MetaCatUtil.debugMessage("the update date is "+updateDate, 30);
|
|
3561 |
logMetacat.info("the update date is "+updateDate);
|
|
3563 | 3562 |
PreparedStatement pstmt = null; |
3564 | 3563 |
String sql = null; |
3565 |
MetaCatUtil.debugMessage("the root node id is "+rootNodeId, 20);
|
|
3564 |
logMetacat.info("the root node id is "+rootNodeId);
|
|
3566 | 3565 |
if (rootNodeId <= 0) |
3567 | 3566 |
{ |
3568 | 3567 |
// this is for data file, not rootnodeid need |
... | ... | |
3588 | 3587 |
|
3589 | 3588 |
// Bind the values to the query |
3590 | 3589 |
pstmt.setString(1, docId); |
3591 |
MetaCatUtil.debugMessage("docid is "+docId, 50);
|
|
3590 |
logMetacat.info("docid is "+docId);
|
|
3592 | 3591 |
pstmt.setString(2, docName); |
3593 |
MetaCatUtil.debugMessage("docname is "+docName, 50);
|
|
3592 |
logMetacat.info("docname is "+docName);
|
|
3594 | 3593 |
pstmt.setString(3, docType); |
3595 |
MetaCatUtil.debugMessage("docType is "+docType, 50);
|
|
3594 |
logMetacat.info("docType is "+docType);
|
|
3596 | 3595 |
pstmt.setString(4, user); |
3597 |
MetaCatUtil.debugMessage("onwer is "+user, 50);
|
|
3596 |
logMetacat.info("onwer is "+user);
|
|
3598 | 3597 |
pstmt.setString(5, user); |
3599 |
MetaCatUtil.debugMessage("update user is "+user, 50);
|
|
3598 |
logMetacat.info("update user is "+user);
|
|
3600 | 3599 |
pstmt.setInt(6, 0); |
3601 | 3600 |
pstmt.setInt(7, (new Integer(catalogid)).intValue()); |
3602 |
MetaCatUtil.debugMessage("catalogid is "+catalogid, 50);
|
|
3601 |
logMetacat.info("catalogid is "+catalogid);
|
|
3603 | 3602 |
pstmt.setInt(8, serverCode); |
3604 |
MetaCatUtil.debugMessage("server code is "+serverCode, 50);
|
|
3603 |
logMetacat.info("server code is "+serverCode);
|
|
3605 | 3604 |
pstmt.setInt(9, Integer.parseInt(rev)); |
3606 |
MetaCatUtil.debugMessage("rev is "+rev, 50);
|
|
3605 |
logMetacat.info("rev is "+rev);
|
|
3607 | 3606 |
|
3608 | 3607 |
if (rootNodeId >0 ) |
3609 | 3608 |
{ |
3610 | 3609 |
pstmt.setLong(10, rootNodeId); |
3611 |
MetaCatUtil.debugMessage("root id is "+rootNodeId, 50);
|
|
3610 |
logMetacat.info("root id is "+rootNodeId);
|
|
3612 | 3611 |
} |
3613 | 3612 |
// Do the insertion |
3614 | 3613 |
pstmt.execute(); |
3615 | 3614 |
pstmt.close(); |
3616 |
MetaCatUtil.debugMessage("end of write into revisons", 50);
|
|
3615 |
logMetacat.info("end of write into revisons");
|
|
3617 | 3616 |
|
3618 | 3617 |
} |
3619 | 3618 |
catch (SQLException sqle) |
Also available in: Unified diff
Replacing MetaCatUtil.debugMessage or MetaCatUtil.logMetacat call with logMetacat (private Logger object) call