Project

General

Profile

« Previous | Next » 

Revision 5197

Added by daigle over 14 years ago

Make sure buildIndex throws an exception if it has a sqlexception. That way the indexing object will be added to the indexing queue and reprocessed.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
1580 1580
	 */
1581 1581
    public void buildIndex() throws McdbException
1582 1582
    {
1583
    	logMetacat.info("buildIndex called on docid " + docid);
1583
    	logMetacat.info("DocumentImpl.buildIndex - building index for docid " + docid);
1584 1584
    	double start = System.currentTimeMillis()/1000;
1585 1585
        TreeSet<NodeRecord> nodeRecordLists = getNodeRecordList(rootnodeid);
1586 1586
        boolean atRootElement = true;
......
1598 1598

  
1599 1599
//        String doc = docid;
1600 1600
      double afterPutNode = System.currentTimeMillis()/1000;
1601
      logMetacat.debug("The time for put node id into map is "+(afterPutNode - start));
1601
      logMetacat.debug("DocumentImpl.buildIndex - The time for put node id into map is "+(afterPutNode - start));
1602 1602
      double afterDelete = 0;
1603 1603
        // Opening separate db connection for deleting and writing
1604 1604
        // XML Index -- be sure that it is all in one db transaction
......
1649 1649
                    
1650 1650
                    currentNode.setNodeType(parentNode.getNodeType());
1651 1651
                    currentNode.setNodeName("");
1652
                    logMetacat.debug("Converted node " + currentNode.getNodeId() + 
1652
                    logMetacat.debug("DocumentImpl.buildIndex - Converted node " + currentNode.getNodeId() + 
1653 1653
                      " to type " + parentNode.getNodeType());
1654 1654
                    
1655 1655
                  	traverseParents(nodeRecordMap, rootNodeId,
......
1666 1666
            }
1667 1667
            
1668 1668
            dbConn.commit();
1669
        } catch (SQLException e) {
1670
            logMetacat.error("SQL Exception while indexing "
1671
                                     + "in DocumentImpl.buildIndex for "
1672
                                     + "document " + docid);
1673
            logMetacat.error(e.getMessage());
1669
        } catch (SQLException sqle) {
1670
            logMetacat.error("DocumentImpl.buildIndex - SQL Exception while indexing "
1671
            		+ "document " + docid + " : " + sqle.getMessage());
1674 1672
            try {
1675 1673
                dbConn.rollback();
1676
            } catch (SQLException sqle) {
1677
                logMetacat.error("Error while rolling back "
1678
                                         + "commit in DocumentImpl"
1679
                                         + ".buildIndex" + "\n"
1680
                                         + sqle.getMessage());
1674
            } catch (SQLException sqle2) {
1675
                logMetacat.error("DocumentImpl.buildIndex - Error while rolling back: "
1676
                		 + sqle2.getMessage());
1681 1677
            }
1678
            throw new McdbException("SQL error when building Index: " + sqle.getMessage());
1682 1679
        } finally {
1683 1680
			DBConnectionPool.returnDBConnection(dbConn, serialNumber);
1684 1681
		}
1685 1682
		double finish = System.currentTimeMillis() / 1000;
1686
		logMetacat.info("The time for inserting is " + (finish - afterDelete));
1687
		logMetacat.info("BuildIndex complete for docid " + docid);
1683
		logMetacat.info("DocumentImpl.buildIndex - The time for inserting is " + (finish - afterDelete));
1684
		logMetacat.info("DocumentImpl.buildIndex - BuildIndex complete for docid " + docid);
1688 1685

  
1689 1686
		// Adds the docid to the spatial data cache
1690 1687
		try {
1691 1688
			if (PropertyService.getProperty("spatial.runSpatialOption").equals("true")) {
1692 1689
				SpatialHarvester spatialHarvester = new SpatialHarvester();
1693
				logMetacat.debug(" --------- Attempting to update the spatial cache for docid "
1690
				logMetacat.debug("DocumentImpl.buildIndex -  Attempting to update the spatial cache for docid "
1694 1691
								+ docid);
1695 1692
				spatialHarvester.addToUpdateQue(docid);
1696 1693
				spatialHarvester.destroy();
1697
				logMetacat.debug(" --------- Finish to update the spatial cache for docid "
1694
				logMetacat.debug("DocumentImpl.buildIndex - Finished updating the spatial cache for docid "
1698 1695
								+ docid);
1699 1696
			}
1700 1697
		} catch (PropertyNotFoundException pnfe) {
1701
			logMetacat.error("Could not get 'runSpatialOption' property.  Spatial " 
1698
			logMetacat.error("DocumentImpl.buildIndex -  Could not get 'runSpatialOption' property.  Spatial " 
1702 1699
					+ "cache not run for docid: " + docid + " : " + pnfe.getMessage());
1700
		} catch (StringIndexOutOfBoundsException siobe) {
1701
			logMetacat.error("DocumentImpl.buildIndex -  String indexing problem.  Spatial " 
1702
					+ "cache not run for docid: " + docid + " : " + siobe.getMessage());		
1703 1703
		}
1704

  
1705

  
1706 1704
	}
1707 1705

  
1708 1706
    /**
......
3644 3642
            pstmt.execute();
3645 3643
            pstmt.close();
3646 3644
        } catch (SQLException e) {
3647
            logMetacat.error(
3648
                    "DocumentImpl.archiveDocRevision - SQL error: "
3645
            logMetacat.error("DocumentImpl.archiveDocRevision - SQL error: "
3649 3646
                            + e.getMessage());
3650 3647
            throw e;
3651 3648
        } finally {
3652 3649
            try {
3653 3650
                pstmt.close();
3654 3651
            } catch (SQLException ee) {
3655
                logMetacat.error(
3656
                        "DocumentImpl.archiveDocRevision - SQL Error: "
3652
                logMetacat.error("DocumentImpl.archiveDocRevision - SQL Error: "
3657 3653
                                + ee.getMessage());
3658 3654
                throw ee;
3659 3655
            } 

Also available in: Unified diff