Project

General

Profile

« Previous | Next » 

Revision 2729

Added by sgarg about 19 years ago

1. Added code to start the indexing thread.
2. Fixed a bug in the query on xml_nodes and xml_index
3. Added more debug statements
4. Fixed a bug in code which determines namespace

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
48 48
import java.util.Vector;
49 49
import java.util.zip.ZipEntry;
50 50
import java.util.zip.ZipOutputStream;
51
import java.util.Timer;
51 52

  
52 53
import javax.servlet.ServletConfig;
53 54
import javax.servlet.ServletContext;
......
168 169
    private static final String CONFIG_NAME = "metacat.properties";
169 170
     	 
170 171
    private static Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
172
       
173
    private Timer timer = null;
171 174
    
172 175
    /**
173 176
     * Initialize the servlet by creating appropriate database connections
......
213 216
            // Index the paths specified in the metacat.properties
214 217
            checkIndexPaths();
215 218

  
219
            // initiate the indexing Queue
220
            IndexingQueue.getInstance();
221
            
222
            // start the IndexingThread if indexingTimerTaskTime more than 0. 
223
            // It will index all the documents not yet indexed in the database             
224
            int indexingTimerTaskTime = Integer.parseInt(MetaCatUtil.getOption("indexingTimerTaskTime"));
225
            if(indexingTimerTaskTime > 0){
226
            	timer = new Timer();
227
            	timer.schedule(new IndexingTimerTask(), 0, indexingTimerTaskTime);
228
            }
229
            
216 230
            MetaCatUtil.printMessage("Metacat (" + Version.getVersion()
217 231
                               + ") initialized.");
218 232

  
......
232 246
        // Close all db connection
233 247
        System.out.println("Destroying MetacatServlet");
234 248
        DBConnectionPool.release();
249
        timer.cancel();
235 250
    }
236 251

  
237 252
    /** Handle "GET" method requests from HTTP clients */
......
303 318
                              + "n.nodedata, n.nodedatanumerical, n.parentnodeid"
304 319
                              + " FROM xml_nodes n, xml_index i WHERE"
305 320
                              + " i.path = ? and n.parentnodeid=i.nodeid and"
306
                              + " n.nodetype LIKE 'TEXT'");
321
                              + " n.nodetype LIKE 'TEXT' order by n.parentnodeid");
307 322
                        pstmt.setString(1, (String) MetaCatUtil.
308 323
                                        pathsForIndexing.elementAt(i));
309 324
                        pstmt.execute();
......
1799 1814
                out.println(npe.getMessage());
1800 1815
                out.println("</error>");
1801 1816
                logMetacat.warn("Error in writing eml document to the database" + npe.getMessage());
1817
                npe.printStackTrace();
1802 1818
            }
1803 1819
        } catch (Exception e) {
1804 1820
            //response.setContentType("text/xml");
......
1807 1823
            out.println(e.getMessage());
1808 1824
            out.println("</error>");
1809 1825
            logMetacat.warn("Error in writing eml document to the database" + e.getMessage());
1826
            e.printStackTrace();
1810 1827
        }
1811 1828
    }
1812 1829

  
......
1892 1909

  
1893 1910
        	// find if the root element has prefix
1894 1911
        	String prefix = getPrefix(targetLine);
1912
        	logMetacat.info("prefix is:" + prefix);
1895 1913
        	int startIndex = 0;
1896 1914
        	
1915
        	
1897 1916
        	if(prefix != null)
1898 1917
        	{
1899 1918
        		// if prefix found then look for xmlns:prefix
......
1901 1920
        		String namespaceWithPrefix = NAMESPACEKEYWORD 
1902 1921
        					+ ":" + prefix;
1903 1922
        		startIndex = targetLine.indexOf(namespaceWithPrefix);
1923
            	logMetacat.info("namespaceWithPrefix is:" + namespaceWithPrefix+":");
1924
            	logMetacat.info("startIndex is:" + startIndex);
1904 1925
        		
1905 1926
        	} else {
1906 1927
        		// if prefix not found then look for xmlns
1907 1928
        		// attribute to find the ns 
1908 1929
        		startIndex = targetLine.indexOf(NAMESPACEKEYWORD);
1930
            	logMetacat.info("startIndex is:" + startIndex);
1909 1931
        	}
1910 1932
        		
1911 1933
            int start = 1;
......
1928 1950
            } 
1929 1951
            // else: xmlns not found. namespace = null will be returned
1930 1952

  
1953
         	logMetacat.info("targetLine is " + targetLine);
1954
         	logMetacat.debug("start is " + end);
1955
         	logMetacat.debug("end is " + end);
1956
           
1931 1957
            if(start < end){
1932 1958
            	namespaceString = targetLine.substring(start + 1, end);
1959
            	logMetacat.info("namespaceString is " + namespaceString);
1933 1960
            }
1934 1961
            logMetacat.info("namespace in xml is: "
1935 1962
                    + namespaceString);
1936
            if (namespaceString.indexOf(eml2_0_0NameSpace) != -1) {
1937
                namespace = eml2_0_0NameSpace;
1938
            } else if (namespaceString.indexOf(eml2_0_1NameSpace) != -1) {
1939
                namespace = eml2_0_1NameSpace;
1940
            } else if (namespaceString.indexOf(eml2_1_0NameSpace) != -1) {
1941
                namespace = eml2_1_0NameSpace;
1942
            } else {
1943
            	namespace = namespaceString;
1963
            if(namespaceString != null){
1964
            	if (namespaceString.indexOf(eml2_0_0NameSpace) != -1) {
1965
            		namespace = eml2_0_0NameSpace;
1966
            	} else if (namespaceString.indexOf(eml2_0_1NameSpace) != -1) {
1967
            		namespace = eml2_0_1NameSpace;
1968
            	} else if (namespaceString.indexOf(eml2_1_0NameSpace) != -1) {
1969
            		namespace = eml2_1_0NameSpace;
1970
            	} else {
1971
            		namespace = namespaceString;
1972
            	}
1944 1973
            }
1945 1974
        }
1946 1975

  
......
2006 2035
    {
2007 2036
    	String prefix = null;
2008 2037
    	String rootElement = schemaLine.substring(0, schemaLine.indexOf(" "));
2009
        logMetacat.warn("rootElement:" + rootElement);
2038
        logMetacat.info("rootElement:" + rootElement);
2010 2039
        
2011 2040
        if(rootElement.indexOf(":") > 0){
2012 2041
        	prefix = rootElement.substring(rootElement.indexOf(":") + 1,
2013 2042
        			rootElement.length());
2014 2043
        } 
2015
        logMetacat.warn("prefix:" + prefix);        
2016
        return prefix;
2044
        return prefix.trim();
2017 2045
    }
2018 2046

  
2019 2047
    /**

Also available in: Unified diff