[metacat-cvs] metacat/src/edu/ucsb/nceas/metacat IndexingTimerTask.java MetaCatServlet.java

Saurabh Garg sgarg at ecoinformatics.org
Thu Nov 17 12:37:48 PST 2005


sgarg       05/11/17 12:37:48

  Modified:    src/edu/ucsb/nceas/metacat IndexingTimerTask.java
                        MetaCatServlet.java
  Log:
  Replaced hardcoded namespaces with variable defined in metacat.properties
  
  Revision  Changes    Path
  1.3       +37 -8     metacat/src/edu/ucsb/nceas/metacat/IndexingTimerTask.java
  
  Index: IndexingTimerTask.java
  ===================================================================
  RCS file: /cvs/metacat/src/edu/ucsb/nceas/metacat/IndexingTimerTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IndexingTimerTask.java	11 Nov 2005 18:01:47 -0000	1.2
  +++ IndexingTimerTask.java	17 Nov 2005 20:37:47 -0000	1.3
  @@ -7,8 +7,8 @@
    *    Release: @release@
    *
    *   '$Author: sgarg $'
  - *     '$Date: 2005/11/11 18:01:47 $'
  - * '$Revision: 1.2 $'
  + *     '$Date: 2005/11/17 20:37:47 $'
  + * '$Revision: 1.3 $'
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
  @@ -31,6 +31,8 @@
   import java.sql.ResultSet;
   import java.sql.SQLException;
   import java.util.TimerTask;
  +import java.util.Vector;
  +import java.util.Iterator;
   
   import edu.ucsb.nceas.metacat.MetaCatUtil;
   import org.apache.log4j.Logger;
  @@ -56,14 +58,41 @@
   	    		
   	    		dbConn = DBConnectionPool.getDBConnection("IndexingThread.run");
   	    		serialNumber = dbConn.getCheckOutSerialNumber();
  +	            Vector indexNamespaces = MetaCatUtil.getOptionList(MetaCatUtil.getOption("indexNamespaces"));
  +	            String nonJoinCriteria = "b.docid is NULL";
  +	    		boolean first = true;
  +
  +	    		if(indexNamespaces != null && !indexNamespaces.isEmpty()){
  +	    			Iterator it = indexNamespaces.iterator();
  +	    			while(it.hasNext()){
  +	    				if(first){
  +	    					nonJoinCriteria = nonJoinCriteria + " AND (";
  +	    					nonJoinCriteria = nonJoinCriteria 
  +	    						+ " a.doctype like '" 
  +	    						+ it.next()
  +	    						+ "'";
  +
  +	    					first = false;
  +	    				} else {
  +	    					nonJoinCriteria = nonJoinCriteria + " OR ";
  +	    					nonJoinCriteria = nonJoinCriteria 
  +	    						+ " a.doctype like '" 
  +	    						+ it.next()
  +	    						+ "'";
  +	    				}
  +	    			}
  +	    			nonJoinCriteria = nonJoinCriteria + ")";
  +	    		} else {
  +	    			// if no namespaces are defined in metacat.properties then return
  +	    			return;
  +	    		}
  +	    		
   	    		String xmlDocumentsCheck = 
   	    			MetaCatUtil.dbAdapter.getLeftJoinQuery("a.docid, a.rev", "xml_documents", 
  -	    					"xml_index", "a.docid = b.docid", "b.docid is NULL AND "
  -	    					+ "(a.doctype like 'eml://ecoinformatics.org/eml-2.0.0' "
  -	    					+ "or a.doctype like 'eml://ecoinformatics.org/eml-2.0.1')");
  -	    		
  -	    		PreparedStatement xmlDocCheck = dbConn
  -	    		.prepareStatement(xmlDocumentsCheck);
  +	    					"xml_index", "a.docid = b.docid", nonJoinCriteria);
  +
  +	    		logMetacat.warn(xmlDocumentsCheck);
  +	    		PreparedStatement xmlDocCheck = dbConn.prepareStatement(xmlDocumentsCheck);
   	    		
   	    		// Increase usage count
   	    		dbConn.increaseUsageCount(1);
  
  
  
  1.238     +3 -3      metacat/src/edu/ucsb/nceas/metacat/MetaCatServlet.java
  
  Index: MetaCatServlet.java
  ===================================================================
  RCS file: /cvs/metacat/src/edu/ucsb/nceas/metacat/MetaCatServlet.java,v
  retrieving revision 1.237
  retrieving revision 1.238
  diff -u -r1.237 -r1.238
  --- MetaCatServlet.java	17 Nov 2005 19:38:24 -0000	1.237
  +++ MetaCatServlet.java	17 Nov 2005 20:37:47 -0000	1.238
  @@ -6,9 +6,9 @@
    *    Authors: Matt Jones, Dan Higgins, Jivka Bojilova, Chad Berkley
    *    Release: @release@
    *
  - *   '$Author: jones $'
  - *     '$Date: 2005/11/17 19:38:24 $'
  - * '$Revision: 1.237 $'
  + *   '$Author: sgarg $'
  + *     '$Date: 2005/11/17 20:37:47 $'
  + * '$Revision: 1.238 $'
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
  @@ -225,7 +225,7 @@
       private void checkIndexPaths() {
           Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
           MetaCatUtil.pathsForIndexing
  -            = MetaCatUtil.getOptionList(MetaCatUtil.getOption("indexed_paths"));
  +            = MetaCatUtil.getOptionList(MetaCatUtil.getOption("indexPaths"));
       
           if (MetaCatUtil.pathsForIndexing != null) {
       
  
  
  


More information about the Metacat-cvs mailing list