Project

General

Profile

« Previous | Next » 

Revision 4467

Added by daigle over 15 years ago

Add some generics typing. Separate the code that strips inline data from document files to have a different strategy for 2.0.X versus 2.1.X documents.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
28 28

  
29 29
import java.io.BufferedInputStream;
30 30
import java.io.BufferedOutputStream;
31
import java.io.BufferedReader;
32 31
import java.io.File;
33 32
import java.io.FileOutputStream;
34
import java.io.FileReader;
35 33
import java.io.IOException;
36 34
import java.io.InputStream;
37 35
import java.io.PrintWriter;
......
104 102
    public static final String NAMESPACEFEATURE = "http://xml.org/sax/features/namespaces";
105 103
    public static final String NAMESPACEPREFIXESFEATURE = "http://xml.org/sax/features/namespace-prefixes";
106 104
    
105
    public static final String EML2_0_0NAMESPACE;
106
    public static final String EML2_0_1NAMESPACE;
107 107
    public static final String EML2_1_0NAMESPACE;
108
    public static final String EML2_0_1NAMESPACE;
109
    public static final String EML2_0_0NAMESPACE;
110 108
    
111 109
    static {
110
    	String eml200NameSpace = null;
111
    	String eml201NameSpace = null;
112 112
    	String eml210NameSpace = null;
113
    	String eml201NameSpace = null;
114
    	String eml200NameSpace = null;
115 113
    	try {
114
    		eml200NameSpace = PropertyService.getProperty("xml.eml2_0_0namespace");
115
    		eml201NameSpace = PropertyService.getProperty("xml.eml2_0_1namespace");
116 116
    		eml210NameSpace = PropertyService.getProperty("xml.eml2_1_0namespace");
117
    		eml200NameSpace = PropertyService.getProperty("xml.eml2_0_1namespace");
118
    		eml201NameSpace = PropertyService.getProperty("xml.eml2_0_0namespace");
119 117
    	} catch (PropertyNotFoundException pnfe) {
120 118
    		System.err.println("Could not get property in static block: " 
121 119
					+ pnfe.getMessage());
......
152 150
    private String publicaccess;
153 151
    protected long rootnodeid;
154 152
    private ElementNode rootNode = null;
155
    private TreeSet nodeRecordList = null;
156

  
157
    
153
    private TreeSet<NodeRecord> nodeRecordList = null;
154
  
158 155
    private static Logger logMetacat = Logger.getLogger(DocumentImpl.class);
159 156

  
160 157
    /**
......
625 622
        {
626 623
          ForceReplicationHandler forceReplication = new ForceReplicationHandler(
627 624
                accnum, false, notificationServer);
625
          logMetacat.debug("ForceReplicationHandler created: " + forceReplication.toString());
628 626
        }
629 627
    }
630 628
    
......
642 640
        int revInDataBase =DBUtil.getLatestRevisionInDocumentTable(docid);
643 641
        logMetacat.warn("The rev in data base: " + revInDataBase);
644 642
        // String to store the revision
645
        String rev = null;
643
//        String rev = null;
646 644

  
647 645
        //revIndataBase=-1, there is no record in xml_documents table
648 646
        //the document is a new one for local server, inert it into table
649 647
        //user specified rev should be great than 0
650 648
        if (revInDataBase == -1 && userSpecifyRev >= 0) {
651 649
            // rev equals user specified
652
            rev = (new Integer(userSpecifyRev)).toString();
650
//            rev = (new Integer(userSpecifyRev)).toString();
653 651
            // action should be INSERT
654 652
            action = "INSERT";
655 653
        }
......
657 655
        // it is a updated file
658 656
        else if (userSpecifyRev > revInDataBase && revInDataBase >= 0) {
659 657
            // rev equals user specified
660
            rev = (new Integer(userSpecifyRev)).toString();
658
//            rev = (new Integer(userSpecifyRev)).toString();
661 659
            // action should be update
662 660
            action = "UPDATE";
663 661
        }
......
684 682
     private static String checkXMLRevisionTable(String docid, int rev) throws Exception
685 683
     {
686 684
         String action = "INSERT";
687
         Vector localrev = null;
685
         Vector<Integer> localrev = null;
688 686
           
689 687
         try
690 688
         {
......
999 997
            proccessEml2 = true;
1000 998
        }
1001 999
        // flag for process inline data
1002
        boolean prcocessInlineData = false;
1000
        boolean processInlineData = false;
1003 1001

  
1004
        TreeSet nodeRecordLists = null;
1002
        TreeSet<NodeRecord> nodeRecordLists = null;
1005 1003
        PrintWriter out = null;
1006 1004
        if (pw instanceof PrintWriter) {
1007 1005
            out = (PrintWriter) pw;
......
1027 1025
        } else {
1028 1026
        	nodeRecordLists = this.nodeRecordList;
1029 1027
        }
1030
        Stack openElements = new Stack();
1028
        Stack<NodeRecord> openElements = new Stack<NodeRecord>();
1031 1029
        boolean atRootElement = true;
1032 1030
        boolean previousNodeWasElement = false;
1033 1031

  
1034 1032
        // Step through all of the node records we were given
1035 1033

  
1036
        Iterator it = nodeRecordLists.iterator();
1034
        Iterator<NodeRecord> it = nodeRecordLists.iterator();
1037 1035

  
1038 1036
        while (it.hasNext()) {
1039 1037

  
1040
            NodeRecord currentNode = (NodeRecord) it.next();
1038
            NodeRecord currentNode = it.next();
1041 1039
            logMetacat.debug("[Got Node ID: " + currentNode.getNodeId() + " ("
1042 1040
                    + currentNode.getParentNodeId() + ", " + currentNode.getNodeIndex()
1043 1041
                    + ", " + currentNode.getNodeType() + ", " + currentNode.getNodeName()
......
1059 1057
            // having been sorted in a depth first traversal of the nodes, which
1060 1058
            // is handled by the NodeComparator class used by the TreeSet
1061 1059
            if (!atRootElement) {
1062
                NodeRecord currentElement = (NodeRecord) openElements.peek();
1060
                NodeRecord currentElement = openElements.peek();
1063 1061
                if (currentNode.getParentNodeId() != currentElement.getNodeId()) {
1064 1062
                    while (currentNode.getParentNodeId() != currentElement.getNodeId()) {
1065 1063
                        currentElement = (NodeRecord) openElements.pop();
......
1075 1073
                        } else {
1076 1074
                            out.print("</" + currentElement.getNodeName() + ">");
1077 1075
                        }
1078
                        currentElement = (NodeRecord) openElements.peek();
1076
                        currentElement = openElements.peek();
1079 1077
                    }
1080 1078
                }
1081 1079
            }
......
1120 1118
                    out.print("<" + currentNode.getNodeName());
1121 1119
                }
1122 1120

  
1123
                // if currentNode is inline and handle eml2, set flag proccess
1124
                // in
1121
                // if currentNode is inline and handle eml2, set flag process
1122
                // on
1125 1123
                if (currentNode.getNodeName() != null
1126 1124
                        && currentNode.getNodeName().equals(Eml200SAXHandler.INLINE)
1127 1125
                        && proccessEml2) {
1128
                    prcocessInlineData = true;
1126
                	processInlineData = true;
1129 1127
                }
1130 1128

  
1131 1129
                // Handle the ATTRIBUTE nodes
......
1155 1153
                if (previousNodeWasElement) {
1156 1154
                    out.print(">");
1157 1155
                }
1158
                if (!prcocessInlineData) {
1156
                if (!processInlineData) {
1159 1157
                    // if it is not inline data just out put data
1160 1158
                    out.print(currentNode.getNodeData());
1161 1159
                } else {
......
1167 1165
                    // check if user has read permision for this inline data
1168 1166
                    boolean readInlinedata = false;
1169 1167
                    try {
1170
                        Hashtable unReadableInlineDataList =
1168
                        Hashtable<String, String> unReadableInlineDataList =
1171 1169
                            PermissionController
1172 1170
                                .getUnReadableInlineDataIdList(accessfileName,
1173 1171
                                        user, groups, true);
......
1179 1177
                    }
1180 1178

  
1181 1179
                    if (readInlinedata) {
1182
                        //user want to see it, pull out from
1183
                        // file system and output it
1184
                        // for inline data, the data base only store the file
1185
                        // name, so we
1186
                        // can combine the file name and inline data file path,
1187
                        // to get it
1180
                        //user want to see it, pull out from file system and 
1181
                    	// output it for inline data, the data base only store 
1182
                    	// the file name, so we can combine the file name and
1183
                    	// inline data file path, to get it
1188 1184

  
1189 1185
                        Reader reader = Eml200SAXHandler
1190 1186
                                .readInlineDataFromFileSystem(fileName);
......
1192 1188
                        try {
1193 1189
                            int length = reader.read(characterArray);
1194 1190
                            while (length != -1) {
1195
                                out
1196
                                        .print(new String(characterArray, 0,
1191
                                out.print(new String(characterArray, 0,
1197 1192
                                                length));
1198 1193
                                out.flush();
1199 1194
                                length = reader.read(characterArray);
......
1205 1200
                    }//if can read inline data
1206 1201
                    else {
1207 1202
                        // if user can't read it, we only send it back a empty
1208
                        // string
1209
                        // in inline element.
1203
                        // string in inline element.
1210 1204
                        out.print("");
1211 1205
                    }// else can't read inlinedata
1212 1206
                    // reset proccess inline data false
1213
                    prcocessInlineData = false;
1207
                    processInlineData = false;
1214 1208
                }// in inlinedata part
1215 1209
                previousNodeWasElement = false;
1216 1210
                // Handle the COMMENT nodes
......
1299 1293
	 */
1300 1294
    public void readFromFileSystem(Writer pw, String user, String[] groups,
1301 1295
            String documentPath) throws McdbException {
1302
    	
1303
    	boolean proccessEml2 = false;
1304
        boolean readInlinedata = false;
1305
    	
1306
        // if this is not EML version 2.x, we do not need to worry about 
1307
        // inline data
1308
        if (doctype != null
1309
                && (doctype.equals(EML2_0_0NAMESPACE)
1310
                        || doctype.equals(EML2_0_1NAMESPACE) 
1311
                        || doctype.equals(EML2_1_0NAMESPACE))) {
1312
            proccessEml2 = true;
1313
        }
1314 1296
        
1315
        // create a printwriter
1316
        PrintWriter out = null;
1317
        if (pw instanceof PrintWriter) {
1318
            out = (PrintWriter) pw;
1319
        } else {
1320
            out = new PrintWriter(pw);
1321
        }
1297
//        // create a printwriter
1298
//        PrintWriter out = null;
1299
//        if (pw instanceof PrintWriter) {
1300
//            out = (PrintWriter) pw;
1301
//        } else {
1302
//            out = new PrintWriter(pw);
1303
//        }
1322 1304
        
1323

  
1324
		String xmlFileLine;
1325 1305
		String xmlFileContents = "";
1326 1306
		
1327 1307
		try {			
......
1334 1314
                    .getUnReadableInlineDataIdList(docid,
1335 1315
                            user, groups, true);
1336 1316
            
1337
            // for each unreadable section, strip the inline data from the doc
1338
            if (proccessEml2 && unReadableInlineDataList.size() > 0) {
1339
                Set<String> inlineKeySet = unReadableInlineDataList.keySet();
1340
            	for(String inlineKey : inlineKeySet) {
1341
            		String inlineValue = unReadableInlineDataList.get(inlineKey);
1342
            		if (inlineValue.startsWith(docid)) {
1343
            			xmlFileContents = stripInlineData(xmlFileContents, inlineKey);
1344
            		}
1345
            	}
1346
            }
1317
            // If this is for each unreadable section, strip the inline data
1318
			// from the doc
1319
			if (unReadableInlineDataList.size() > 0 && doctype != null) {
1320
				Set<String> inlineKeySet = unReadableInlineDataList.keySet();
1321
				
1322
				boolean pre210Doc = doctype.equals(EML2_0_0NAMESPACE)
1323
						|| doctype.equals(EML2_0_1NAMESPACE);
1324

  
1325
				for (String inlineKey : inlineKeySet) {
1326
					String inlineValue = unReadableInlineDataList.get(inlineKey);
1327
					if (inlineValue.startsWith(docid)) {
1328
						// There are two different methods of stripping inline data depending
1329
						// on whether this is a 2.0.1 or earlier doc or 2.1.0 and later.  This 
1330
						// is because of eml schema changes for inline access.
1331
						if (pre210Doc) {
1332
							xmlFileContents = stripInline20XData(xmlFileContents,
1333
									inlineKey);
1334
						} else {
1335
							xmlFileContents = stripInline21XData(xmlFileContents, inlineKey);
1336
						}
1337
					}
1338
				}
1339
			}
1347 1340
            
1348 1341
            // write the doc
1349 1342
			pw.write(xmlFileContents);
......
1358 1351
    }
1359 1352
    
1360 1353
    /**
1361
	 * Strip out an inline data section from a document. This assumes that the
1362
	 * inline element is within a distribution element and the key for the
1354
	 * Strip out an inline data section from a 2.0.X version document. This assumes 
1355
	 * that the inline element is within a distribution element and the id for the
1363 1356
	 * distribution is the same as the subtreeid in the xml_access table.
1364 1357
	 * 
1365 1358
	 * @param xmlFileContents
......
1367 1360
	 * @param inLineKey
1368 1361
	 *            the unique key for this inline element
1369 1362
	 */
1370
    private String stripInlineData(String xmlFileContents, String inLineKey) {
1363
    private String stripInline20XData(String xmlFileContents, String inLineId)
1364
			throws Exception {
1365
		String changedString = xmlFileContents;
1366
		
1367
    	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
1368
    	Pattern distEndPattern = Pattern.compile("</distribution>", Pattern.CASE_INSENSITIVE);
1369
    	Pattern idPattern = Pattern.compile("id=\"" + inLineId);
1370
    	Pattern inlinePattern = Pattern.compile("<inline>.*</inline>");
1371
    	
1372
    	Matcher distStartMatcher = distStartPattern.matcher(xmlFileContents);
1373
    	Matcher distEndMatcher = distEndPattern.matcher(xmlFileContents);
1374
    	Matcher idMatcher = idPattern.matcher(xmlFileContents);
1375
    	Matcher inlineMatcher = inlinePattern.matcher(xmlFileContents);
1376
    	 
1377
    	// loop through the document looking for distribution elements
1378
    	while (distStartMatcher.find()) {
1379
    		// find the index of the corresponding end element
1380
    		int distStart = distStartMatcher.end();
1381
        	if (!distEndMatcher.find(distStart)) {
1382
        		throw new Exception("Could not find end tag for distribution");
1383
        	}
1384
        	int distEnd = distEndMatcher.start();
1385
        	
1386
        	// look for our inline id within the range of this distribution.
1387
        	idMatcher.region(distStart, distEnd);
1388
        	if (idMatcher.find()) {
1389
        		// if this distribution has the desired id, replace any 
1390
        		// <inline>.*</inline> in this distribution with <inline></inline>
1391
        		inlineMatcher.region(distStart, distEnd);
1392
            	if (inlineMatcher.find()) {
1393
            		changedString = inlineMatcher.replaceAll("<inline></inline>");
1394
            	} else {
1395
            		logMetacat.warn("Could not find an inline element for distribution: " + inLineId);
1396
            	}
1397
        	}
1398
    		
1399
    	}
1400

  
1401
		return changedString;
1402
	}
1403
    
1404
    /**
1405
	 * Strip out an inline data section from a 2.1.X version document. This
1406
	 * assumes that the inline element is within a distribution element and the
1407
	 * subtreeid in the xml_access table is an integer that represents the nth
1408
	 * distribution element in the document.
1409
	 * 
1410
	 * @param xmlFileContents
1411
	 *            the contents of the file
1412
	 * @param inLineKey
1413
	 *            the unique key for this inline element
1414
	 */
1415
    private String stripInline21XData(String xmlFileContents, String inLineId) throws Exception {
1416
    	int distributionIndex = Integer.valueOf(inLineId);
1371 1417
    	String changedString = xmlFileContents;
1372
    	String regex = "(<distribution .*id=\"" + inLineKey + "\">.*)<inline>.*</inline>(.*</distribution>)";
1373
    	Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); 
1374
    	Matcher matcher = pattern.matcher(xmlFileContents);
1375
    	if (matcher.find()) {
1376
    		changedString = matcher.replaceFirst(matcher.group(1) + "<inline></inline>" + matcher.group(2));
1418
    	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
1419
    	Pattern distEndPattern = Pattern.compile("</distribution>", Pattern.CASE_INSENSITIVE); 
1420
    	Pattern inlinePattern = Pattern.compile("<inline>.*</inline>");
1421
    	Matcher matcher = distStartPattern.matcher(xmlFileContents);
1422
    	
1423
    	// iterate through distributions until we find the nth match.  The nth match 
1424
    	// corresponds to the inLineKey that was passed in.  Use the end of that match
1425
    	// to set the start range we will search for the inline element.
1426
    	for (int i = 0; i < distributionIndex; i++) {
1427
    		if (!matcher.find()) {
1428
    			throw new Exception("Could not find distribution number " + (i + 1));
1429
    		}
1377 1430
    	}	
1431
    	int distStart = matcher.end();
1378 1432
    	
1433
    	// find the end tag for the distribution.  Use the beginning of that match to set
1434
    	// the end range we will search for the inline element
1435
    	matcher.usePattern(distEndPattern);
1436
    	if (!matcher.find(distStart)) {
1437
    		throw new Exception("Could not find end tag for distribution");
1438
    	}
1439
    	int distEnd = matcher.start();
1440
    	
1441
    	// set the inline search range
1442
    	matcher.region(distStart, distEnd);
1443
    	
1444
    	// match any inline elements and replace with an empty inline element
1445
    	matcher.usePattern(inlinePattern);  	
1446
    	if (matcher.find()) {
1447
    		changedString = matcher.replaceAll("<inline></inline>");
1448
    	} else {
1449
    		logMetacat.warn("Could not find an inline element for distribution: " 
1450
    				+ inLineId);
1451
    	}
1452
    	
1379 1453
    	return changedString;
1380 1454
    }
1381 1455

  
......
1392 1466
    {
1393 1467
    	logMetacat.warn("buildIndex called on docid " + docid);
1394 1468
    	double start = System.currentTimeMillis()/1000;
1395
        TreeSet nodeRecordLists = getNodeRecordList(rootnodeid);
1469
        TreeSet<NodeRecord> nodeRecordLists = getNodeRecordList(rootnodeid);
1396 1470
        boolean atRootElement = true;
1397 1471
        long rootNodeId = -1;
1398 1472

  
1399 1473
        // Build a map of the same records that are present in the
1400 1474
        // TreeSet so that any node can be easily accessed by nodeId
1401
        HashMap nodeRecordMap = new HashMap();
1402
        Iterator it = nodeRecordLists.iterator();
1475
        HashMap<Long, NodeRecord> nodeRecordMap = new HashMap<Long, NodeRecord>();
1476
        Iterator<NodeRecord> it = nodeRecordLists.iterator();
1403 1477
        while (it.hasNext()) {
1404 1478
            NodeRecord currentNode = (NodeRecord) it.next();
1405 1479
            Long nodeId = new Long(currentNode.getNodeId());
1406 1480
            nodeRecordMap.put(nodeId, currentNode);
1407 1481
        }
1408 1482

  
1409
        String doc = docid;
1483
//        String doc = docid;
1410 1484
      double afterPutNode = System.currentTimeMillis()/1000;
1411 1485
      logMetacat.info("The time for put node id into map is "+(afterPutNode - start));
1412 1486
      double afterDelete = 0;
......
1429 1503
            // TEXT nodes with their parent ELEMENT node ids to associate the
1430 1504
            // element with it's node data (stored in the text node)
1431 1505
            it = nodeRecordLists.iterator();
1432
            HashMap pathsFound = new HashMap();
1506
            HashMap<String, PathIndexEntry> pathsFound = new HashMap<String, PathIndexEntry>();
1433 1507
            while (it.hasNext()) {
1434 1508
                NodeRecord currentNode = (NodeRecord) it.next();
1435
                HashMap pathList = new HashMap();
1509
                HashMap<String, PathIndexEntry> pathList = new HashMap<String, PathIndexEntry>();
1436 1510
                if ( currentNode.getNodeType().equals("ELEMENT") ||
1437 1511
                     currentNode.getNodeType().equals("ATTRIBUTE") ){
1438 1512

  
......
1453 1527
                  // with ELEMENT paths with TEXT nodedata (since it's modeled 
1454 1528
                  // this way in the DOM)
1455 1529
                  NodeRecord parentNode = 
1456
                   (NodeRecord) nodeRecordMap.get(new Long(currentNode.getParentNodeId()));
1530
                	  nodeRecordMap.get(new Long(currentNode.getParentNodeId()));
1457 1531

  
1458 1532
                  if ( parentNode.getNodeType().equals("ELEMENT") ) {
1459 1533
                    
......
1534 1608
	 * @param nodedata
1535 1609
	 *            the nodedata for the current node
1536 1610
	 */
1537
    private void traverseParents(HashMap records, long rootNodeId,
1538
            long leafNodeId, long id,
1539
            String children, HashMap pathList, HashMap pathsFoundForIndexing) {
1540
    	  Long nodeId = new Long(id);
1611
    private void traverseParents(HashMap<Long,NodeRecord> records, long rootNodeId,
1612
            long leafNodeId, long id,String children, 
1613
            HashMap<String, PathIndexEntry> pathList, 
1614
            HashMap<String, PathIndexEntry> pathsFoundForIndexing) {
1615
    	Long nodeId = new Long(id);
1541 1616
        NodeRecord current = (NodeRecord)records.get(nodeId);
1542 1617
        long parentId = current.getParentNodeId();
1543 1618
        String currentName = current.getNodeName();
1544
        String nodeData = current.getNodeData();
1545
        float nodeDataNumerical = current.getNodeDataNumerical();
1619
//        String nodeData = current.getNodeData();
1620
//        float nodeDataNumerical = current.getNodeDataNumerical();
1546 1621
        NodeRecord leafRecord = (NodeRecord)records.get(new Long(leafNodeId));
1547 1622
        String leafData = leafRecord.getNodeData();
1548 1623
        long leafParentId = leafRecord.getParentNodeId();
......
1677 1752
     * @param pathList the hash of paths to insert
1678 1753
     * @throws SQLException if there is an error inserting into the db
1679 1754
     */
1680
    private void updateNodeIndex(DBConnection conn, HashMap pathList)
1755
    private void updateNodeIndex(DBConnection conn, HashMap<String, PathIndexEntry> pathList)
1681 1756
    	throws SQLException
1682 1757
    {
1683 1758
        // Create an insert statement to reuse for all of the path
......
1692 1767
        pstmt.setString(4, doctype);
1693 1768

  
1694 1769
        // Step through the hashtable and insert each of the path values
1695
        Iterator it = pathList.values().iterator();
1770
        Iterator<PathIndexEntry> it = pathList.values().iterator();
1696 1771
        while (it.hasNext()) {
1697 1772
        	 PathIndexEntry entry = (PathIndexEntry)it.next();
1698 1773
        	 logMetacat.debug("Inserting: " + entry.nodeId +
......
1714 1789
     * @param pathList the hash of paths to insert
1715 1790
     * @throws SQLException if there is an error inserting into the db
1716 1791
     */
1717
    private void updatePathIndex(DBConnection conn, HashMap pathsFound)
1792
    private void updatePathIndex(DBConnection conn, HashMap<String, PathIndexEntry> pathsFound)
1718 1793
        throws SQLException {
1719 1794
        // Increase usage count for the connection
1720 1795
        conn.increaseUsageCount(1);
......
1727 1802
                + " VALUES (?, ?, ?, ?, ?)");
1728 1803
        
1729 1804
        // Step through the hashtable and insert each of the path values
1730
        Iterator it = pathsFound.values().iterator();
1805
        Iterator<PathIndexEntry> it = pathsFound.values().iterator();
1731 1806
         while (it.hasNext()) {
1732 1807
             PathIndexEntry entry = (PathIndexEntry)it.next();
1733 1808
             pstmt.setString(1,entry.docid);
......
1785 1860
                //System.out.println("in revision table branch -------");
1786 1861
                // if we couldn't find it in xml_documents we 
1787 1862
                // need to find it in xml_revision table
1788
                Vector revList = DBUtil.getRevListFromRevisionTable(docid);
1863
                Vector<Integer> revList = DBUtil.getRevListFromRevisionTable(docid);
1789 1864
                for (int i=0; i<revList.size(); i++)
1790 1865
                {
1791
                    Integer k = (Integer) revList.elementAt(i);
1792
                    //System.out.println("The rev in xml_revision talbe "+ k.toString());
1866
                    //  Integer k = (Integer) revList.elementAt(i);
1867
                    // System.out.println("The rev in xml_revision table "+ k.toString());
1793 1868
                }
1794 1869
                
1795 1870
                if (revList.contains(new Integer(revision)))
......
1953 2028
     * @param rootnodeid
1954 2029
     *            the id of the root node of the node tree to look up
1955 2030
     */
1956
    private TreeSet getNodeRecordList(long rootnodeid) throws McdbException
2031
    private TreeSet<NodeRecord> getNodeRecordList(long rootnodeid) throws McdbException
1957 2032
    {
1958 2033
        PreparedStatement pstmt = null;
1959 2034
        DBConnection dbconn = null;
1960 2035
        int serialNumber = -1;
1961
        TreeSet nodeRecordList = new TreeSet(new NodeComparator());
2036
        TreeSet<NodeRecord> nodeRecordList = new TreeSet<NodeRecord>(new NodeComparator());
1962 2037
        long nodeid = 0;
1963 2038
        long parentnodeid = 0;
1964 2039
        long nodeindex = 0;
......
1967 2042
        String nodeprefix = null;
1968 2043
        String nodedata = null;
1969 2044
        float nodedatanumerical = -1;
1970
        String quotechar = DatabaseService.getDBAdapter().getStringDelimiter();
2045
//        String quotechar = DatabaseService.getDBAdapter().getStringDelimiter();
1971 2046
        String table = "xml_nodes";
1972 2047
        //System.out.println("in getNodeREcorelist !!!!!!!!!!!for root node id "+rootnodeid);
1973 2048
        try {
......
2362 2437
            // the resident server will not give a lock then we send the user
2363 2438
            // a  message saying that he/she needs to download a new copy of
2364 2439
            // the file and merge the differences manually.
2365
            int istreamInt;
2366
            char istreamChar;
2440
//            int istreamInt;
2441
//            char istreamChar;
2367 2442

  
2368 2443
            // check for 'write' permission for 'user' to update this document
2369 2444
            if (!hasWritePermission(user, groups, accnum)) {
......
2430 2505
                // Force replication the docid
2431 2506
                ForceReplicationHandler frh = new ForceReplicationHandler(
2432 2507
                        accnum, true, null);
2508
                logMetacat.debug("ForceReplicationHandler created: " + frh.toString());
2433 2509
                return (accnum);
2434 2510

  
2435 2511
            }
......
2529 2605
        // metacat notify the force replication.
2530 2606
        ForceReplicationHandler frh = new ForceReplicationHandler(accnum,
2531 2607
                action, true, null);
2608
        logMetacat.debug("ForceReplicationHandler created: " + frh.toString());
2532 2609
        // clear cache after inserting or updating a document
2533 2610
        if (PropertyService.getProperty("database.queryCacheOn").equals("true"))
2534 2611
        {
......
2714 2791
        {
2715 2792
          ForceReplicationHandler forceReplication = new ForceReplicationHandler(
2716 2793
                accnum, action, true, notifyServer);
2794
          logMetacat.debug("ForceReplicationHandler created: " + forceReplication.toString());
2717 2795
        }
2718 2796
        
2719 2797
        // clear cache after inserting or updating a document
......
2732 2810
    {
2733 2811
        DBConnection dbconn = null;
2734 2812
        int serialNumber = -1;
2735
        PreparedStatement pstmt = null;
2813
//        PreparedStatement pstmt = null;
2736 2814
        String documenttype = getDocTypeFromDBForCurrentDocument(accnumber);
2737 2815
        try {
2738 2816
            String packagedoctype = PropertyService.getProperty("xml.packagedoctype");
2739
            Vector packagedoctypes = new Vector();
2817
            Vector<String> packagedoctypes = new Vector<String>();
2740 2818
            packagedoctypes = MetaCatUtil.getOptionList(packagedoctype);
2741 2819
            String docIdWithoutRev = MetaCatUtil.getDocIdFromAccessionNumber(accnumber);
2742 2820
            int revision = MetaCatUtil.getRevisionFromAccessionNumber(accnumber);
......
2919 2997
            double afterArchiveDocAndNode = System.currentTimeMillis()/1000;
2920 2998
            logMetacat.info("The time for archiveDocAndNodesRevision is "+(afterArchiveDocAndNode - start));
2921 2999
            // Now delete it from the xml_index table
2922
            boolean useXMLIndex = (new Boolean(PropertyService
2923
                    .getProperty("database.usexmlindex"))).booleanValue();
3000
//            boolean useXMLIndex = (new Boolean(PropertyService
3001
//                    .getProperty("database.usexmlindex"))).booleanValue();
2924 3002

  
2925 3003

  
2926 3004

  
......
3029 3107
            // add force delete replcation document here.
3030 3108
            ForceReplicationHandler frh = new ForceReplicationHandler(
3031 3109
                             accnum, ForceReplicationHandler.DELETE, isXML, notifyServer);
3110
            logMetacat.debug("ForceReplicationHandler created: " + frh.toString());
3032 3111
            // clear cache after inserting or updating a document
3033 3112
            if (PropertyService.getProperty("database.queryCacheOn").equals("true"))
3034 3113
            {
......
3939 4018
    {
3940 4019
        DBConnection dbconn = null;
3941 4020
        int serialNumber = -1;
3942
        AccessionNumber ac;
3943
        PreparedStatement pstmt = null;
3944
        String action = null;
4021
//        AccessionNumber ac;
4022
//        PreparedStatement pstmt = null;
4023
//        String action = null;
3945 4024
        try 
3946 4025
        {
3947 4026
            //dbconn = util.openDBConnection();
......
3973 4052
     */
3974 4053
    static private void deleteXMLNodes(DBConnection dbconn, long rootId) throws Exception
3975 4054
    {
3976
        AccessionNumber ac;
4055
//        AccessionNumber ac;
3977 4056
        PreparedStatement pstmt = null;
3978 4057
        double start = System.currentTimeMillis()/1000;
3979 4058
        String sql = "DELETE FROM xml_nodes WHERE rootnodeid ="+ rootId;

Also available in: Unified diff