Project

General

Profile

« Previous | Next » 

Revision 2758

Added by sgarg over 18 years ago

Replaced hardcoded namespaces with variable defined in metacat.properties

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
225 225
    private void checkIndexPaths() {
226 226
        Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
227 227
        MetaCatUtil.pathsForIndexing
228
            = MetaCatUtil.getOptionList(MetaCatUtil.getOption("indexed_paths"));
228
            = MetaCatUtil.getOptionList(MetaCatUtil.getOption("indexPaths"));
229 229
    
230 230
        if (MetaCatUtil.pathsForIndexing != null) {
231 231
    
src/edu/ucsb/nceas/metacat/IndexingTimerTask.java
31 31
import java.sql.ResultSet;
32 32
import java.sql.SQLException;
33 33
import java.util.TimerTask;
34
import java.util.Vector;
35
import java.util.Iterator;
34 36

  
35 37
import edu.ucsb.nceas.metacat.MetaCatUtil;
36 38
import org.apache.log4j.Logger;
......
56 58
	    		
57 59
	    		dbConn = DBConnectionPool.getDBConnection("IndexingThread.run");
58 60
	    		serialNumber = dbConn.getCheckOutSerialNumber();
61
	            Vector indexNamespaces = MetaCatUtil.getOptionList(MetaCatUtil.getOption("indexNamespaces"));
62
	            String nonJoinCriteria = "b.docid is NULL";
63
	    		boolean first = true;
64

  
65
	    		if(indexNamespaces != null && !indexNamespaces.isEmpty()){
66
	    			Iterator it = indexNamespaces.iterator();
67
	    			while(it.hasNext()){
68
	    				if(first){
69
	    					nonJoinCriteria = nonJoinCriteria + " AND (";
70
	    					nonJoinCriteria = nonJoinCriteria 
71
	    						+ " a.doctype like '" 
72
	    						+ it.next()
73
	    						+ "'";
74

  
75
	    					first = false;
76
	    				} else {
77
	    					nonJoinCriteria = nonJoinCriteria + " OR ";
78
	    					nonJoinCriteria = nonJoinCriteria 
79
	    						+ " a.doctype like '" 
80
	    						+ it.next()
81
	    						+ "'";
82
	    				}
83
	    			}
84
	    			nonJoinCriteria = nonJoinCriteria + ")";
85
	    		} else {
86
	    			// if no namespaces are defined in metacat.properties then return
87
	    			return;
88
	    		}
89
	    		
59 90
	    		String xmlDocumentsCheck = 
60 91
	    			MetaCatUtil.dbAdapter.getLeftJoinQuery("a.docid, a.rev", "xml_documents", 
61
	    					"xml_index", "a.docid = b.docid", "b.docid is NULL AND "
62
	    					+ "(a.doctype like 'eml://ecoinformatics.org/eml-2.0.0' "
63
	    					+ "or a.doctype like 'eml://ecoinformatics.org/eml-2.0.1')");
92
	    					"xml_index", "a.docid = b.docid", nonJoinCriteria);
93

  
94
	    		logMetacat.warn(xmlDocumentsCheck);
95
	    		PreparedStatement xmlDocCheck = dbConn.prepareStatement(xmlDocumentsCheck);
64 96
	    		
65
	    		PreparedStatement xmlDocCheck = dbConn
66
	    		.prepareStatement(xmlDocumentsCheck);
67
	    		
68 97
	    		// Increase usage count
69 98
	    		dbConn.increaseUsageCount(1);
70 99
	    		xmlDocCheck.execute();

Also available in: Unified diff