Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that implements a metadata catalog as a java Servlet
4
 *  Copyright: 2006 Regents of the University of California and the
5
 *             National Center for Ecological Analysis and Synthesis
6
 *    Authors: Matt Jones, Dan Higgins, Jivka Bojilova, Chad Berkley, Matthew Perry
7
 *
8
 *   '$Author: leinfelder $'
9
 *     '$Date: 2011-04-07 15:17:15 -0700 (Thu, 07 Apr 2011) $'
10
 * '$Revision: 6031 $'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26

    
27
package edu.ucsb.nceas.metacat;
28

    
29
import java.io.IOException;
30
import java.io.OutputStreamWriter;
31
import java.io.PrintWriter;
32
import java.io.Writer;
33
import java.sql.PreparedStatement;
34
import java.sql.ResultSet;
35
import java.sql.SQLException;
36
import java.sql.Timestamp;
37
import java.util.Enumeration;
38
import java.util.Hashtable;
39
import java.util.Timer;
40
import java.util.Vector;
41

    
42
import javax.servlet.ServletConfig;
43
import javax.servlet.ServletContext;
44
import javax.servlet.ServletException;
45
import javax.servlet.ServletOutputStream;
46
import javax.servlet.http.HttpServlet;
47
import javax.servlet.http.HttpServletRequest;
48
import javax.servlet.http.HttpServletResponse;
49
import javax.servlet.http.HttpSession;
50

    
51
import org.apache.log4j.Logger;
52
import org.apache.log4j.PropertyConfigurator;
53

    
54
import edu.ucsb.nceas.metacat.database.DBConnection;
55
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
56
import edu.ucsb.nceas.metacat.database.DatabaseService;
57
import edu.ucsb.nceas.metacat.plugin.MetacatHandlerPlugin;
58
import edu.ucsb.nceas.metacat.plugin.MetacatHandlerPluginManager;
59
import edu.ucsb.nceas.metacat.properties.PropertyService;
60
import edu.ucsb.nceas.metacat.properties.SkinPropertyService;
61
import edu.ucsb.nceas.metacat.replication.ReplicationService;
62
import edu.ucsb.nceas.metacat.service.ServiceService;
63
import edu.ucsb.nceas.metacat.service.SessionService;
64
import edu.ucsb.nceas.metacat.service.XMLSchemaService;
65
import edu.ucsb.nceas.metacat.shared.BaseException;
66
import edu.ucsb.nceas.metacat.shared.HandlerException;
67
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
68
import edu.ucsb.nceas.metacat.shared.ServiceException;
69
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester;
70
import edu.ucsb.nceas.metacat.util.AuthUtil;
71
import edu.ucsb.nceas.metacat.util.ConfigurationUtil;
72
import edu.ucsb.nceas.metacat.util.DocumentUtil;
73
import edu.ucsb.nceas.metacat.util.ErrorSendingErrorException;
74
import edu.ucsb.nceas.metacat.util.RequestUtil;
75
import edu.ucsb.nceas.metacat.util.ResponseUtil;
76
import edu.ucsb.nceas.metacat.util.SessionData;
77
import edu.ucsb.nceas.metacat.util.SystemUtil;
78
import edu.ucsb.nceas.metacat.workflow.WorkflowSchedulerClient;
79
import edu.ucsb.nceas.utilities.FileUtil;
80
import edu.ucsb.nceas.utilities.GeneralPropertyException;
81
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
82
import edu.ucsb.nceas.utilities.UtilException;
83

    
84
/**
85
 * A metadata catalog server implemented as a Java Servlet
86
 *
87
 * Valid actions are:
88
 * 
89
 * action=login
90
 *     username
91
 *     password
92
 *     qformat
93
 * action=logout
94
 *     qformat
95
 * action=query -- query the values of all elements and attributes and return a result set of nodes
96
 *     meta_file_id --
97
 *     returndoctype --
98
 *     filterdoctype --
99
 *     returnfield --
100
 *     owner --
101
 *     site --
102
 *     operator --
103
 *     casesensitive --
104
 *     searchmode --
105
 *     anyfield --
106
 * action=spatial_query -- run a spatial query.  these queries may include any of the
107
 *                         queries supported by the WFS / WMS standards
108
 *     xmax --
109
 *     ymax --
110
 *     xmin --
111
 *     ymin --
112
 *     skin --
113
 *     pagesize --
114
 *     pagestart --
115
 * action=squery -- structured query (see pathquery.dtd)
116
 *     query --
117
 *     pagesize --
118
 *     pagestart --
119
 * action=export -- export a zip format for data packadge
120
 *     docid -- 
121
 * action=read -- read any metadata/data file from Metacat and from Internet
122
 *     archiveEntryName --
123
 *     docid --
124
 *     qformat --
125
 *     metadatadocid --
126
 * action=readinlinedata -- read inline data only
127
 *     inlinedataid
128
 * action=insert -- insert an XML document into the database store
129
 *     qformat -- 
130
 *     docid --
131
 *     doctext --
132
 *     dtdtext --
133
 * action=insertmultipart -- insert an xml document into the database using multipart encoding
134
 *     qformat -- 
135
 *     docid --
136
 * action=update -- update an XML document that is in the database store
137
 *     qformat -- 
138
 *     docid --
139
 *     doctext --
140
 *     dtdtext --
141
 * action=delete -- delete an XML document from the database store
142
 *     docid --
143
 * action=validate -- validate the xml contained in valtext
144
 *     valtext --
145
 *     docid --
146
 * action=setaccess -- change access permissions for a user on a document.
147
 *     docid --
148
 *     principal --
149
 *     permission --
150
 *     permType --
151
 *     permOrder --
152
 * action=getaccesscontrol -- retrieve acl info for Metacat document
153
 *     docid -- 
154
 * action=getprincipals -- retrieve a list of principals in XML
155
 * action=getalldocids -- retrieves a list of all docids registered with the system
156
 *     scope --
157
 * action=getlastdocid --
158
 *     scope --
159
 *     username --
160
 * action=isregistered -- checks to see if the provided docid is registered
161
 *     docid --
162
 * action=getrevisionanddoctype -- get a document's revision and doctype from database 
163
 *     docid --
164
 * action=getversion -- 
165
 * action=getdoctypes -- retrieve all doctypes (publicID) 
166
 * action=getdtdschema -- retrieve a DTD or Schema file
167
 *     doctype --
168
 * action=getlog -- get a report of events that have occurred in the system
169
 *     ipAddress --  filter on one or more IP addresses>
170
 *     principal -- filter on one or more principals (LDAP DN syntax)
171
 *     docid -- filter on one or more document identifiers (with revision)
172
 *     event -- filter on event type (e.g., read, insert, update, delete)
173
 *     start -- filter out events before the start date-time
174
 *     end -- filter out events before the end date-time
175
 * action=getloggedinuserinfo -- get user info for the currently logged in user
176
 *     ipAddress --  filter on one or more IP addresses>
177
 *     principal -- filter on one or more principals (LDAP DN syntax)
178
 *     docid -- filter on one or more document identifiers (with revision)
179
 *     event -- filter on event type (e.g., read, insert, update, delete)
180
 *     start -- filter out events before the start date-time
181
 *     end -- filter out events before the end date-time
182
 * action=shrink -- Shrink the database connection pool size if it has grown and 
183
 *                  extra connections are no longer being used.
184
 * action=buildindex --
185
 *     docid --
186
 * action=refreshServices --
187
 * action=scheduleWorkflow -- Schedule a workflow to be run.  Scheduling a workflow 
188
 *                            registers it with the scheduling engine and creates a row
189
 *                            in the scheduled_job table.  Note that this may be 
190
 *                            extracted into a separate servlet.
191
 *     delay -- The amount of time from now before the workflow should be run.  The 
192
 *              delay can be expressed in number of seconds, minutes, hours and days, 
193
 *              for instance 30s, 2h, etc.
194
 *     starttime -- The time that the workflow should first run.  If both are provided
195
 *                  this takes precedence over delay.  The time should be expressed as: 
196
 *                  MM/dd/yyyy HH:mm:ss with the timezone assumed to be that of the OS.
197
 *     endtime -- The time when the workflow should end. The time should be expressed as: 
198
 *                  MM/dd/yyyy HH:mm:ss with the timezone assumed to be that of the OS.
199
 *     intervalvalue -- The numeric value of the interval between runs
200
 *     intervalunit -- The unit of the interval between runs.  Can be s, m, h, d for 
201
 *                     seconds, minutes, hours and days respectively
202
 *     workflowid -- The lsid of the workflow that we want to schedule.  This workflow
203
 *                   must already exist in the database.
204
 *     karid -- The karid for the workflow that we want to schedule.
205
 *     workflowname -- The name of the workflow.
206
 *     forwardto -- If provided, forward to this page when processing is done.
207
 *     qformat -- If provided, render results using the stylesheets associated with
208
 *                this skin.  Default is xml.
209
 * action=unscheduleWorkflow -- Unschedule a workflow.  Unscheduling a workflow 
210
 *                            removes it from the scheduling engine and changes the 
211
 *                            status in the scheduled_job table to " unscheduled.  Note 
212
 *                            that this may be extracted into a separate servlet.
213
 *     workflowjobname -- The job ID for the workflow run that we want to unschedule.  This
214
 *                      is held in the database as scheduled_job.name
215
 *     forwardto -- If provided, forward to this page when processing is done.
216
 *     qformat -- If provided, render results using the stylesheets associated with
217
 *                this skin.  Default is xml.
218
 * action=rescheduleWorkflow -- Unschedule a workflow.  Rescheduling a workflow 
219
 *                            registers it with the scheduling engine and changes the 
220
 *                            status in the scheduled_job table to " scheduled.  Note 
221
 *                            that this may be extracted into a separate servlet.
222
 *     workflowjobname -- The job ID for the workflow run that we want to reschedule.  This
223
 *                      is held in the database as scheduled_job.name
224
 *     forwardto -- If provided, forward to this page when processing is done.
225
 *     qformat -- If provided, render results using the stylesheets associated with
226
 *                this skin.  Default is xml.
227
 * action=deleteScheduledWorkflow -- Delete a workflow.  Deleting a workflow 
228
 *                            removes it from the scheduling engine and changes the 
229
 *                            status in the scheduled_job table to " deleted.  Note 
230
 *                            that this may be extracted into a separate servlet.
231
 *     workflowjobname -- The job ID for the workflow run that we want to delete.  This
232
 *                      is held in the database as scheduled_job.name
233
 *     forwardto -- If provided, forward to this page when processing is done.
234
 *     qformat -- If provided, render results using the stylesheets associated with
235
 *                this skin.  Default is xml.
236
 *     
237
 *     
238
 * Here are some of the common parameters for actions
239
 *     doctype -- document type list returned by the query (publicID) 
240
 *     qformat=xml -- display resultset from query in XML 
241
 *     qformat=html -- display resultset from query in HTML 
242
 *     qformat=zip -- zip resultset from query
243
 *     docid=34 -- display the document with the document ID number 34 
244
 *     doctext -- XML text of the document to load into the database 
245
 *     acltext -- XML access text for a document to load into the database 
246
 *     dtdtext -- XML DTD text for a new DTD to load into Metacat XML Catalog 
247
 *     query -- actual query text (to go with 'action=query' or 'action=squery')
248
 *     valtext -- XML text to be validated 
249
 *     scope --can limit the query by the scope of the id
250
 *     docid --the docid to check
251
 *     datadoc -- data document name (id)
252
 */
253
public class MetaCatServlet extends HttpServlet {
254

    
255
	private static final long serialVersionUID = 1L;
256
	private Timer timer = null;
257
    private static boolean _firstHalfInitialized = false;
258
    private static boolean _fullyInitialized = false;
259
    private MetacatHandler handler = null;
260
    
261
    // Constants -- these should be final in a servlet
262
    public static final String SCHEMALOCATIONKEYWORD = ":schemaLocation";
263
    public static final String NONAMESPACELOCATION = ":noNamespaceSchemaLocation";
264
    public static final String EML2KEYWORD = ":eml";
265
    private static final String FALSE = "false";
266
    private static final String TRUE  = "true";
267
    private static String LOG_CONFIG_NAME = null;
268
    public static final String APPLICATION_NAME = "metacat";
269
	public static final String DEFAULT_ENCODING = "UTF-8";
270
    
271
    /**
272
     * Initialize the servlet by creating appropriate database connections
273
     */
274
    public void init(ServletConfig config) throws ServletException {
275
    	Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
276
    	try {
277
    		if(_firstHalfInitialized) {
278
    			return;
279
    		}
280
    		
281
            super.init(config);
282
            
283
            ServletContext context = config.getServletContext();
284
            context.setAttribute("APPLICATION_NAME", APPLICATION_NAME);
285
            
286
            ServiceService serviceService = ServiceService.getInstance(context);
287
            logMetacat.debug("MetaCatServlet.init - ServiceService singleton created " + serviceService);
288
            
289
            // Initialize the properties file
290
            String dirPath = ServiceService.getRealConfigDir();
291
            
292
            LOG_CONFIG_NAME = dirPath + "/log4j.properties";
293
            PropertyConfigurator.configureAndWatch(LOG_CONFIG_NAME);
294
            
295
            // Register preliminary services
296
            ServiceService.registerService("PropertyService", PropertyService.getInstance(context));         
297
            ServiceService.registerService("SkinPropertyService", SkinPropertyService.getInstance());
298
            ServiceService.registerService("SessionService", SessionService.getInstance()); 
299
            
300
    		// Check to see if the user has requested to bypass configuration 
301
            // (dev option) and check see if metacat has been configured.
302
    		// If both are false then stop the initialization
303
            if (!ConfigurationUtil.bypassConfiguration() && !ConfigurationUtil.isMetacatConfigured()) {
304
            	return;
305
            }  
306
            
307
            _firstHalfInitialized = true;
308
            
309
            initSecondHalf(context);
310
            
311
    	} catch (ServiceException se) {
312
        	String errorMessage = 
313
        		"Service problem while intializing MetaCat Servlet: " + se.getMessage();
314
            logMetacat.error("MetaCatServlet.init - " + errorMessage);
315
            throw new ServletException(errorMessage);
316
        } catch (MetacatUtilException mue) {
317
        	String errorMessage = "Metacat utility problem while intializing MetaCat Servlet: " 
318
        		+ mue.getMessage();
319
            logMetacat.error("MetaCatServlet.init - " + errorMessage);
320
            throw new ServletException(errorMessage);
321
        } 
322
    }
323

    
324
            
325
	/**
326
	 * Initialize the remainder of the servlet. This is the part that can only
327
	 * be initialized after metacat properties have been configured
328
	 * 
329
	 * @param context
330
	 *            the servlet context of MetaCatServlet
331
	 */
332
	public void initSecondHalf(ServletContext context) throws ServletException {
333
		
334
		Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
335

    
336
		try {			
337
			ServiceService.registerService("DatabaseService", DatabaseService.getInstance());
338
			
339
			// initialize DBConnection pool
340
			DBConnectionPool connPool = DBConnectionPool.getInstance();
341
			logMetacat.debug("MetaCatServlet.initSecondHalf - DBConnection pool initialized: " + connPool.toString());
342
			
343
			ServiceService.registerService("XMLSchemaService", XMLSchemaService.getInstance());
344

    
345
			// check if eml201 document were corrected or not. if not, correct eml201 documents.
346
			// Before Metacat 1.8.1, metacat uses tag RELEASE_EML_2_0_1_UPDATE_6 as eml
347
			// schema, which accidentily points to wrong version of eml-resource.xsd.
348
			String correctedEML201Doc = PropertyService.getProperty("document.eml201DocumentCorrected");
349
			if (correctedEML201Doc != null && correctedEML201Doc.equals(FALSE)) {
350
				logMetacat.info("MetaCatServlet.initSecondHalf - Start to correct eml201 documents");
351
				EML201DocumentCorrector correct = new EML201DocumentCorrector();
352
				boolean success = correct.run();
353
				if (success) {
354
					PropertyService.setProperty("document.eml201DocumentCorrected", TRUE);
355
				}
356
				logMetacat.info("MetaCatServlet.initSecondHalf - Finish to correct eml201 documents");
357
			}
358

    
359
			// Index the paths specified in the metacat.properties
360
			checkIndexPaths();
361

    
362
			// initiate the indexing Queue
363
			IndexingQueue.getInstance();
364

    
365
			// start the IndexingThread if indexingTimerTaskTime more than 0.
366
			// It will index all the documents not yet indexed in the database
367
			int indexingTimerTaskTime = Integer.parseInt(PropertyService
368
					.getProperty("database.indexingTimerTaskTime"));
369
			int delayTime = Integer.parseInt(PropertyService
370
					.getProperty("database.indexingInitialDelay"));
371

    
372
			if (indexingTimerTaskTime > 0) {
373
				timer = new Timer();
374
				timer.schedule(new IndexingTimerTask(), delayTime, indexingTimerTaskTime);
375
			}
376
			
377
			/*
378
			 * If spatial option is turned on and set to regenerate the spatial
379
			 * cache on restart, trigger the harvester regeneratation method
380
			 */
381
			if (PropertyService.getProperty("spatial.runSpatialOption").equals("true") && 
382
					PropertyService.getProperty("spatial.regenerateCacheOnRestart").equals("true")) {
383

    
384
				// Begin timer
385
				long before = System.currentTimeMillis();
386

    
387
				// if either the point or polygon shape files do not exist, then regenerate the entire spatial cache
388
				// this may be expensive with many documents		
389
				SpatialHarvester sh = new SpatialHarvester();
390
				sh.regenerate();
391
				sh.destroy();
392

    
393
				// After running the first time, we want to to set
394
				// regenerateCacheOnRestart to false
395
				// so that it does not regenerate the cache every time tomcat is
396
				// restarted
397
				PropertyService.setProperty("spatial.regenerateCacheOnRestart", "false");
398

    
399
				// End timer
400
				long after = System.currentTimeMillis();
401
				logMetacat.info("MetaCatServlet.initSecondHalf - Spatial Harvester Time  " 
402
						+ (after - before) + "ms");
403

    
404
			} else {
405
				logMetacat.info("MetaCatServlet.initSecondHalf - Spatial cache is not set to regenerate on restart");
406
			}
407
		
408
			// Set up the replication log file by setting the "replication.logfile.name" 
409
			// system property and reconfiguring the log4j property configurator.
410
			String replicationLogPath = PropertyService.getProperty("replication.logdir") 
411
				+ FileUtil.getFS() + ReplicationService.REPLICATION_LOG_FILE_NAME;				
412
			
413
			if (FileUtil.getFileStatus(replicationLogPath) == FileUtil.DOES_NOT_EXIST) {
414
				FileUtil.createFile(replicationLogPath);
415
			}
416

    
417
			if (FileUtil.getFileStatus(replicationLogPath) < FileUtil.EXISTS_READ_WRITABLE) {
418
				logMetacat.error("MetaCatServlet.initSecondHalf - Replication log file: " + replicationLogPath 
419
						+ " does not exist read/writable.");
420
			}
421
			
422
			System.setProperty("replication.logfile.name", replicationLogPath);			
423
			PropertyConfigurator.configureAndWatch(LOG_CONFIG_NAME);
424
			
425
			SessionService.getInstance().unRegisterAllSessions();
426
			
427
	         //Initialize Metacat Handler
428
            handler = new MetacatHandler(timer);
429

    
430
			handler.set_sitemapScheduled(false);
431
			
432
			// initialize the plugins
433
			MetacatHandlerPluginManager.getInstance();
434

    
435
			_fullyInitialized = true;
436
			
437
			logMetacat.warn("MetaCatServlet.initSecondHalf - Metacat (" + MetacatVersion.getVersionID()
438
					+ ") initialized.");
439
			
440
		} catch (SQLException e) {
441
			String errorMessage = "SQL problem while intializing MetaCat Servlet: "
442
					+ e.getMessage();
443
			logMetacat.error("MetaCatServlet.initSecondHalf - " + errorMessage);
444
			throw new ServletException(errorMessage);
445
		} catch (IOException ie) {
446
			String errorMessage = "IO problem while intializing MetaCat Servlet: "
447
					+ ie.getMessage();
448
			logMetacat.error("MetaCatServlet.initSecondHalf - " + errorMessage);
449
			throw new ServletException(errorMessage);
450
		} catch (GeneralPropertyException gpe) {
451
			String errorMessage = "Could not retrieve property while intializing MetaCat Servlet: "
452
					+ gpe.getMessage();
453
			logMetacat.error("MetaCatServlet.initSecondHalf - " + errorMessage);
454
			throw new ServletException(errorMessage);
455
		} catch (ServiceException se) {
456
			String errorMessage = "Service problem while intializing MetaCat Servlet: "
457
				+ se.getMessage();
458
			logMetacat.error("MetaCatServlet.initSecondHalf - " + errorMessage);
459
			throw new ServletException(errorMessage);
460
		} catch (UtilException ue) {
461
        	String errorMessage = "Utility problem while intializing MetaCat Servlet: " 
462
        		+ ue.getMessage();
463
            logMetacat.error("MetaCatServlet.initSecondHalf - " + errorMessage);
464
            throw new ServletException(errorMessage);
465
        } 
466
	}
467
    
468
    /**
469
	 * Close all db connections from the pool
470
	 */
471
    public void destroy() {
472
    	Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
473
    	
474
    	ServiceService.stopAllServices();
475
    	
476
        // Close all db connection
477
        logMetacat.warn("MetaCatServlet.destroy - Destroying MetacatServlet");
478
        timer.cancel();
479
        IndexingQueue.getInstance().setMetacatRunning(false);
480
        DBConnectionPool.release();
481
    }
482
    
483
    /** Handle "GET" method requests from HTTP clients */
484
    public void doGet(HttpServletRequest request, HttpServletResponse response)
485
    throws ServletException, IOException {
486
        
487
        // Process the data and send back the response
488
        handleGetOrPost(request, response);
489
    }
490
    
491
    /** Handle "POST" method requests from HTTP clients */
492
    public void doPost(HttpServletRequest request, HttpServletResponse response)
493
    throws ServletException, IOException {
494
        
495
        // Process the data and send back the response
496
        handleGetOrPost(request, response);
497
    }
498
    
499
    /**
500
	 * Index the paths specified in the metacat.properties
501
	 */
502
    private void checkIndexPaths() {
503
        Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
504

    
505
        Vector<String> pathsForIndexing = null;
506
        try {  
507
        	pathsForIndexing = SystemUtil.getPathsForIndexing();
508
        }
509
        catch (MetacatUtilException ue) {
510
        	pathsForIndexing = null;
511
            logMetacat.error("MetaCatServlet.checkIndexPaths - not find index paths.  Setting " 
512
            		+ "pathsForIndexing to null: " + ue.getMessage());
513
        }
514
        
515
        if (pathsForIndexing != null && !pathsForIndexing.isEmpty()) {
516
            
517
            logMetacat.debug("MetaCatServlet.checkIndexPaths - Indexing paths specified in metacat.properties....");
518
            
519
            DBConnection conn = null;
520
            int serialNumber = -1;
521
            PreparedStatement pstmt = null;
522
            PreparedStatement pstmt1 = null;
523
            ResultSet rs = null;
524
            
525
            for (String pathIndex : pathsForIndexing) {
526
                logMetacat.debug("MetaCatServlet.checkIndexPaths - Checking if '" + pathIndex  + "' is indexed.... ");
527
                
528
                try {
529
                    //check out DBConnection
530
                    conn = DBConnectionPool.
531
                            getDBConnection("MetaCatServlet.checkIndexPaths");
532
                    serialNumber = conn.getCheckOutSerialNumber();
533
                    
534
                    pstmt = conn.prepareStatement(
535
                            "SELECT * FROM xml_path_index " + "WHERE path = ?");
536
                    pstmt.setString(1, pathIndex);
537
                    
538
                    pstmt.execute();
539
                    rs = pstmt.getResultSet();
540
                    
541
                    if (!rs.next()) {
542
                        logMetacat.debug("MetaCatServlet.checkIndexPaths - not indexed yet.");
543
                        rs.close();
544
                        pstmt.close();
545
                        conn.increaseUsageCount(1);
546
                        
547
                        logMetacat.debug("MetaCatServlet.checkIndexPaths - Inserting following path in xml_path_index: "
548
                                + pathIndex);
549
                        if(pathIndex.indexOf("@")<0){
550
                            pstmt = conn.prepareStatement("SELECT DISTINCT n.docid, "
551
                                    + "n.nodedata, n.nodedatanumerical, n.nodedatadate, n.parentnodeid"
552
                                    + " FROM xml_nodes n, xml_index i WHERE"
553
                                    + " i.path = ? and n.parentnodeid=i.nodeid and"
554
                                    + " n.nodetype LIKE 'TEXT' order by n.parentnodeid");
555
                        } else {
556
                            pstmt = conn.prepareStatement("SELECT DISTINCT n.docid, "
557
                                    + "n.nodedata, n.nodedatanumerical, n.nodedatadate, n.parentnodeid"
558
                                    + " FROM xml_nodes n, xml_index i WHERE"
559
                                    + " i.path = ? and n.nodeid=i.nodeid and"
560
                                    + " n.nodetype LIKE 'ATTRIBUTE' order by n.parentnodeid");
561
                        }
562
                        pstmt.setString(1, pathIndex);
563
                        pstmt.execute();
564
                        rs = pstmt.getResultSet();
565
                        
566
                        int count = 0;
567
                        logMetacat.debug("MetaCatServlet.checkIndexPaths - Executed the select statement for: "
568
                                + pathIndex);
569
                        
570
                        try {
571
                            while (rs.next()) {
572
                                
573
                                String docid = rs.getString(1);
574
                                String nodedata = rs.getString(2);
575
                                float nodedatanumerical = rs.getFloat(3);
576
                                Timestamp nodedatadate = rs.getTimestamp(4);
577
                                int parentnodeid = rs.getInt(5);
578
                                
579
                                if (!nodedata.trim().equals("")) {
580
                                    pstmt1 = conn.prepareStatement(
581
                                            "INSERT INTO xml_path_index"
582
                                            + " (docid, path, nodedata, "
583
                                            + "nodedatanumerical, nodedatadate, parentnodeid)"
584
                                            + " VALUES (?, ?, ?, ?, ?, ?)");
585
                                    
586
                                    pstmt1.setString(1, docid);
587
                                    pstmt1.setString(2, pathIndex);
588
                                    pstmt1.setString(3, nodedata);
589
                                    pstmt1.setFloat(4, nodedatanumerical);
590
                                    pstmt1.setTimestamp(5, nodedatadate);
591
                                    pstmt1.setInt(6, parentnodeid);
592
                                    
593
                                    pstmt1.execute();
594
                                    pstmt1.close();
595
                                    
596
                                    count++;
597
                                    
598
                                }
599
                            }
600
                        } catch (Exception e) {
601
                            logMetacat.error("MetaCatServlet.checkIndexPaths - Exception:" + e.getMessage());
602
                            e.printStackTrace();
603
                        }
604
                        
605
                        rs.close();
606
                        pstmt.close();
607
                        conn.increaseUsageCount(1);
608
                        
609
                        logMetacat.info("MetaCatServlet.checkIndexPaths - Indexed " + count + " records from xml_nodes for '"
610
                                + pathIndex + "'");
611
                        
612
                    } else {
613
                        logMetacat.debug("MetaCatServlet.checkIndexPaths - already indexed.");
614
                    }
615
                    
616
                    rs.close();
617
                    pstmt.close();
618
                    conn.increaseUsageCount(1);
619
                    
620
                } catch (Exception e) {
621
                    logMetacat.error("MetaCatServlet.checkIndexPaths - Error in MetaCatServlet.checkIndexPaths: "
622
                            + e.getMessage());
623
                }finally {
624
                    //check in DBonnection
625
                    DBConnectionPool.returnDBConnection(conn, serialNumber);
626
                }
627
                
628
                
629
            }
630
            
631
            logMetacat.debug("MetaCatServlet.checkIndexPaths - Path Indexing Completed");
632
        }
633
    }
634
    
635
    /**
636
	 * Control servlet response depending on the action parameter specified
637
	 */
638
	@SuppressWarnings("unchecked")
639
	private void handleGetOrPost(HttpServletRequest request,
640
			HttpServletResponse response) throws ServletException, IOException {
641
		Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
642

    
643
		String requestEncoding = request.getCharacterEncoding();
644
		logMetacat.debug("requestEncoding: " + requestEncoding);
645
		
646
		// Update the last update time for this user if they are not new
647
		HttpSession httpSession = request.getSession(false);
648
		if (httpSession != null) {
649
		    SessionService.getInstance().touchSession(httpSession.getId());
650
		}
651
		
652
		// Each time metacat is called, check to see if metacat has been 
653
		// configured. If not then forward to the administration servlet
654
		if (!ConfigurationUtil.isMetacatConfigured()) {
655
			try {
656
				RequestUtil.forwardRequest(request, response, "/admin?action=configure", null);
657
				return;
658
			} catch (MetacatUtilException mue) {
659
				logMetacat.error("MetacatServlet.handleGetOrPost - utility error when forwarding to " + 
660
						"configuration screen: " + mue.getMessage());
661
				throw new ServletException("MetacatServlet.handleGetOrPost - utility error when forwarding to " + 
662
						"configuration screen: " + mue.getMessage());
663
			}
664
		}
665

    
666
		// if we get here, metacat is configured.  If we have not completed the 
667
		// second half of the initialization, do so now.  This allows us to initially
668
		// configure metacat without a restart.
669
		if (!_fullyInitialized) {
670
			initSecondHalf(request.getSession().getServletContext());
671
		}
672
		
673
		/*
674
		 * logMetacat.debug("Connection pool size: "
675
		 * +connPool.getSizeOfDBConnectionPool(),10); logMetacat.debug("Free
676
		 * DBConnection number: "
677
		 */
678
		// If all DBConnection in the pool are free and DBConnection pool
679
		// size is greater than initial value, shrink the connection pool
680
		// size to initial value
681
		DBConnectionPool.shrinkDBConnectionPoolSize();
682

    
683
		// Debug message to print out the method which have a busy DBConnection
684
		try {
685
			@SuppressWarnings("unused")
686
			DBConnectionPool pool = DBConnectionPool.getInstance();
687
//			pool.printMethodNameHavingBusyDBConnection();
688
		} catch (SQLException e) {
689
			logMetacat.error("MetaCatServlet.handleGetOrPost - Error in MetacatServlet.handleGetOrPost: " + e.getMessage());
690
			e.printStackTrace();
691
		}
692

    
693
		try {
694
			String ctype = request.getContentType();
695
			
696
			if (ctype != null && ctype.startsWith("multipart/form-data")) {
697
				handler.handleMultipartForm(request, response);
698
				return;
699
			} 
700

    
701
			String name = null;
702
			String[] value = null;
703
			String[] docid = new String[3];
704
			Hashtable<String, String[]> params = new Hashtable<String, String[]>();
705

    
706
			// Check if this is a simple read request that doesn't use the
707
			// "action" syntax
708
			// These URLs are of the form:
709
			// http://localhost:8180/knb/metacat/docid/skinname
710
			// e.g., http://localhost:8180/knb/metacat/test.1.1/knb
711
			String pathInfo = request.getPathInfo();
712
			if (pathInfo != null) {
713
				String[] path = pathInfo.split("/");
714
				if (path.length > 1) {
715
					String docidToRead = path[1];
716
					String docs[] = new String[1];
717
					docs[0] = docidToRead;
718
					logMetacat.debug("MetaCatServlet.handleGetOrPost - READING DOCID FROM PATHINFO: " + docs[0]);
719
					params.put("docid", docs);
720
					String skin = null;
721
					if (path.length > 2) {
722
						skin = path[2];
723
						String skins[] = new String[1];
724
						skins[0] = skin;
725
						params.put("qformat", skins);
726
					}
727
					handler.handleReadAction(params, request, response, "public", null, null);
728
					return;
729
				}
730
			}
731

    
732
			Enumeration<String> paramlist = 
733
				(Enumeration<String>) request.getParameterNames();
734
			while (paramlist.hasMoreElements()) {
735

    
736
				name = paramlist.nextElement();
737
				value = request.getParameterValues(name);
738

    
739
				// Decode the docid and mouse click information
740
				// THIS IS OBSOLETE -- I THINK -- REMOVE THIS BLOCK
741
				// 4/12/2007d
742
				// MBJ
743
				if (name.endsWith(".y")) {
744
					docid[0] = name.substring(0, name.length() - 2);
745
					params.put("docid", docid);
746
					name = "ypos";
747
				}
748
				if (name.endsWith(".x")) {
749
					name = "xpos";
750
				}
751

    
752
				params.put(name, value);
753
			}
754

    
755
			// handle param is emptpy
756
			if (params.isEmpty() || params == null) {
757
				return;
758
			}
759

    
760
			// if the user clicked on the input images, decode which image
761
			// was clicked then set the action.
762
			if (params.get("action") == null) {
763
				PrintWriter out = response.getWriter();
764
				response.setContentType("text/xml");
765
				out.println("<?xml version=\"1.0\"?>");
766
				out.println("<error>");
767
				out.println("Action not specified");
768
				out.println("</error>");
769
				out.close();
770
				return;
771
			}
772

    
773
			String action = (params.get("action"))[0];
774
			logMetacat.info("MetaCatServlet.handleGetOrPost - Action is: " + action);
775

    
776
			// This block handles session management for the servlet
777
			// by looking up the current session information for all actions
778
			// other than "login" and "logout"
779
			String userName = null;
780
			String password = null;
781
			String[] groupNames = null;
782
			String sessionId = null;
783
			name = null;
784

    
785
			// handle login action
786
			if (action.equals("login")) {
787
				PrintWriter out = response.getWriter();
788
				handler.handleLoginAction(out, params, request, response);
789
				out.close();
790

    
791
				// handle logout action
792
			} else if (action.equals("logout")) {
793
				PrintWriter out = response.getWriter();
794
				handler.handleLogoutAction(out, params, request, response);
795
				out.close();
796

    
797
				// handle shrink DBConnection request
798
			} else if (action.equals("validatesession")) {
799
				PrintWriter out = response.getWriter();
800
				String idToValidate = null;
801
				String idsToValidate[] = params.get("sessionid");
802
				if (idsToValidate != null) {
803
					idToValidate = idsToValidate[0];
804
				}
805
				SessionService.getInstance().validateSession(out, response, idToValidate);
806
				out.close();
807

    
808
				// handle shrink DBConnection request
809
			} else if (action.equals("shrink")) {
810
				PrintWriter out = response.getWriter();
811
				boolean success = false;
812
				// If all DBConnection in the pool are free and DBConnection
813
				// pool
814
				// size is greater than initial value, shrink the connection
815
				// pool
816
				// size to initial value
817
				success = DBConnectionPool.shrinkConnectionPoolSize();
818
				if (success) {
819
					// if successfully shrink the pool size to initial value
820
					out.println("DBConnection Pool shrunk successfully.");
821
				}// if
822
				else {
823
					out.println("DBConnection pool not shrunk successfully.");
824
				}
825
				// close out put
826
				out.close();
827

    
828
				// aware of session expiration on every request
829
			} else {
830
				SessionData sessionData = RequestUtil.getSessionData(request);
831
				
832
				if (sessionData != null) {
833
					userName = sessionData.getUserName();
834
					password = sessionData.getPassword();
835
					groupNames = sessionData.getGroupNames();
836
					sessionId = sessionData.getId();
837
				}
838

    
839
				logMetacat.info("MetaCatServlet.handleGetOrPost - The user is : " + userName);
840
			}
841
			// Now that we know the session is valid, we can delegate the
842
			// request to a particular action handler
843
			if (action.equals("query")) {
844
		        Writer out = new OutputStreamWriter(response.getOutputStream(), DEFAULT_ENCODING);
845
				handler.handleQuery(out, params, response, userName, groupNames, sessionId);
846
				out.close();
847
			} else if (action.equals("squery")) {
848
				Writer out = new OutputStreamWriter(response.getOutputStream(), DEFAULT_ENCODING);
849
				if (params.containsKey("query")) {
850
					handler.handleSQuery(out, params, response, userName, groupNames, sessionId);
851
					out.close();
852
				} else {
853
					out.write("Illegal action squery without \"query\" parameter");
854
					out.close();
855
				}
856
			} else if (action.trim().equals("spatial_query")) {
857

    
858
				logMetacat
859
						.debug("MetaCatServlet.handleGetOrPost - ******************* SPATIAL QUERY ********************");
860
				Writer out = new OutputStreamWriter(response.getOutputStream(), DEFAULT_ENCODING);
861
				handler.handleSpatialQuery(out, params, response, userName, groupNames, sessionId);
862
				out.close();
863

    
864
			} else if (action.trim().equals("dataquery")) {
865

    
866
				logMetacat.debug("MetaCatServlet.handleGetOrPost - ******************* DATA QUERY ********************");
867
				handler.handleDataquery(params, response, sessionId);
868
			} else if (action.trim().equals("editcart")) {
869
				logMetacat.debug("MetaCatServlet.handleGetOrPost - ******************* EDIT CART ********************");
870
				handler.handleEditCart(params, response, sessionId);
871
			} else if (action.equals("export")) {
872

    
873
				handler.handleExportAction(params, response, userName, groupNames, password);
874
			} else if (action.equals("read")) {
875
				if (params.get("archiveEntryName") != null) {
876
					ArchiveHandler.getInstance().readArchiveEntry(params, request,
877
							response, userName, password, groupNames);
878
				} else {
879
					handler.handleReadAction(params, request, response, userName, password,
880
							groupNames);
881
				}
882
			} else if (action.equals("readinlinedata")) {
883
				handler.handleReadInlineDataAction(params, request, response, userName, password,
884
						groupNames);
885
			} else if (action.equals("insert") || action.equals("update")) {
886
				PrintWriter out = response.getWriter();
887
				if ((userName != null) && !userName.equals("public")) {
888
					handler.handleInsertOrUpdateAction(request.getRemoteAddr(), response, out, params, userName,
889
							groupNames);
890
				} else {
891
					response.setContentType("text/xml");
892
					out.println("<?xml version=\"1.0\"?>");
893
					out.println("<error>");
894
					out.println("Permission denied for user " + userName + " " + action);
895
					out.println("</error>");
896
				}
897
				out.close();
898
			} else if (action.equals("delete")) {
899
				PrintWriter out = response.getWriter();
900
				if ((userName != null) && !userName.equals("public")) {
901
					handler.handleDeleteAction(out, params, request, response, userName,
902
							groupNames);
903
				} else {
904
					response.setContentType("text/xml");
905
					out.println("<?xml version=\"1.0\"?>");
906
					out.println("<error>");
907
					out.println("Permission denied for " + action);
908
					out.println("</error>");
909
				}
910
				out.close();
911
			} else if (action.equals("validate")) {
912
				PrintWriter out = response.getWriter();
913
				handler.handleValidateAction(out, params);
914
				out.close();
915
			} else if (action.equals("setaccess")) {
916
				PrintWriter out = response.getWriter();
917
				handler.handleSetAccessAction(out, params, userName, request, response);
918
				out.close();
919
			} else if (action.equals("getaccesscontrol")) {
920
				PrintWriter out = response.getWriter();
921
				handler.handleGetAccessControlAction(out, params, response, userName, groupNames);
922
				out.close();
923
			} else if (action.equals("isauthorized")) {
924
				PrintWriter out = response.getWriter();
925
				DocumentUtil.isAuthorized(out, params, request, response);
926
				out.close();
927
			} else if (action.equals("getprincipals")) {
928
				PrintWriter out = response.getWriter();
929
				handler.handleGetPrincipalsAction(out, userName, password);
930
				out.close();
931
			} else if (action.equals("getdoctypes")) {
932
				PrintWriter out = response.getWriter();
933
				handler.handleGetDoctypesAction(out, params, response);
934
				out.close();
935
			} else if (action.equals("getdtdschema")) {
936
				PrintWriter out = response.getWriter();
937
				handler.handleGetDTDSchemaAction(out, params, response);
938
				out.close();
939
			} else if (action.equals("getlastdocid")) {
940
				PrintWriter out = response.getWriter();
941
				handler.handleGetMaxDocidAction(out, params, response);
942
				out.close();
943
			} else if (action.equals("getalldocids")) {
944
				PrintWriter out = response.getWriter();
945
				handler.handleGetAllDocidsAction(out, params, response);
946
				out.close();
947
			} else if (action.equals("isregistered")) {
948
				PrintWriter out = response.getWriter();
949
				handler.handleIdIsRegisteredAction(out, params, response);
950
				out.close();
951
			} else if (action.equals("getrevisionanddoctype")) {
952
				PrintWriter out = response.getWriter();
953
				handler.handleGetRevisionAndDocTypeAction(out, params);
954
				out.close();
955
			} else if (action.equals("getversion")) {
956
				response.setContentType("text/xml");
957
				PrintWriter out = response.getWriter();
958
				out.println(MetacatVersion.getVersionAsXml());
959
				out.close();
960
			} else if (action.equals("getlog")) {
961
				handler.handleGetLogAction(params, request, response, userName, groupNames);
962
			} else if (action.equals("getloggedinuserinfo")) {
963
				PrintWriter out = response.getWriter();
964
				response.setContentType("text/xml");
965
				out.println("<?xml version=\"1.0\"?>");
966
				out.println("\n<user>\n");
967
				out.println("\n<username>\n");
968
				out.println(userName);
969
				out.println("\n</username>\n");
970
				if (name != null) {
971
					out.println("\n<name>\n");
972
					out.println(name);
973
					out.println("\n</name>\n");
974
				}
975
				if (AuthUtil.isAdministrator(userName, groupNames)) {
976
					out.println("<isAdministrator></isAdministrator>\n");
977
				}
978
				if (AuthUtil.isModerator(userName, groupNames)) {
979
					out.println("<isModerator></isModerator>\n");
980
				}
981
				out.println("\n</user>\n");
982
				out.close();
983
			} else if (action.equals("buildindex")) {
984
				handler.handleBuildIndexAction(params, request, response, userName, groupNames);
985
			} else if (action.equals("login") || action.equals("logout")) {
986
				/*
987
				 * } else if (action.equals("protocoltest")) { String testURL =
988
				 * "metacat://dev.nceas.ucsb.edu/NCEAS.897766.9"; try { testURL =
989
				 * ((String[]) params.get("url"))[0]; } catch (Throwable t) { }
990
				 * String phandler = System
991
				 * .getProperty("java.protocol.handler.pkgs");
992
				 * response.setContentType("text/html"); PrintWriter out =
993
				 * response.getWriter(); out.println("<body
994
				 * bgcolor=\"white\">"); out.println("<p>Handler property:
995
				 * <code>" + phandler + "</code></p>"); out.println("<p>Starting
996
				 * test for:<br>"); out.println(" " + testURL + "</p>"); try {
997
				 * URL u = new URL(testURL); out.println("<pre>");
998
				 * out.println("Protocol: " + u.getProtocol()); out.println("
999
				 * Host: " + u.getHost()); out.println(" Port: " + u.getPort());
1000
				 * out.println(" Path: " + u.getPath()); out.println(" Ref: " +
1001
				 * u.getRef()); String pquery = u.getQuery(); out.println("
1002
				 * Query: " + pquery); out.println(" Params: "); if (pquery !=
1003
				 * null) { Hashtable qparams =
1004
				 * MetacatUtil.parseQuery(u.getQuery()); for (Enumeration en =
1005
				 * qparams.keys(); en .hasMoreElements();) { String pname =
1006
				 * (String) en.nextElement(); String pvalue = (String)
1007
				 * qparams.get(pname); out.println(" " + pname + ": " + pvalue); } }
1008
				 * out.println("</pre>"); out.println("</body>");
1009
				 * out.close(); } catch (MalformedURLException mue) {
1010
				 * System.out.println( "bad url from
1011
				 * MetacatServlet.handleGetOrPost");
1012
				 * out.println(mue.getMessage()); mue.printStackTrace(out);
1013
				 * out.close(); }
1014
				 */
1015
			} else if (action.equals("refreshServices")) {
1016
				// TODO MCD this interface is for testing. It should go through
1017
				// a ServiceService class and only work for an admin user. Move 
1018
				// to the MetacatAdminServlet
1019
				ServiceService.refreshService("XMLSchemaService");
1020
				return;
1021
			} else if (action.equals("scheduleWorkflow")) {
1022
				try {
1023
					WorkflowSchedulerClient.getInstance().scheduleJob(request, response,
1024
							params, userName, groupNames);
1025
					return;
1026
				} catch (BaseException be) {
1027
					ResponseUtil.sendErrorXML(response,
1028
							ResponseUtil.SCHEDULE_WORKFLOW_ERROR, be);
1029
					return;
1030
				}
1031
			} else if (action.equals("unscheduleWorkflow")) {
1032
				try {
1033
					WorkflowSchedulerClient.getInstance().unScheduleJob(request,
1034
							response, params, userName, groupNames);
1035
					return;
1036
				} catch (BaseException be) {
1037
					ResponseUtil.sendErrorXML(response,
1038
							ResponseUtil.UNSCHEDULE_WORKFLOW_ERROR, be);
1039
					return;
1040
				}
1041
			} else if (action.equals("rescheduleWorkflow")) {
1042
				try {
1043
					WorkflowSchedulerClient.getInstance().reScheduleJob(request,
1044
							response, params, userName, groupNames);
1045
					return;
1046
				} catch (BaseException be) {
1047
					ResponseUtil.sendErrorXML(response,
1048
							ResponseUtil.RESCHEDULE_WORKFLOW_ERROR, be);
1049
					return;
1050
				}
1051
			} else if (action.equals("getScheduledWorkflow")) {
1052
				try {
1053
					WorkflowSchedulerClient.getInstance().getJobs(request, response,
1054
							params, userName, groupNames);
1055
					return;
1056
				} catch (BaseException be) {
1057
					ResponseUtil.sendErrorXML(response,
1058
							ResponseUtil.GET_SCHEDULED_WORKFLOW_ERROR, be);
1059
					return;
1060
				}
1061
			} else if (action.equals("deleteScheduledWorkflow")) {
1062
				try {
1063
					WorkflowSchedulerClient.getInstance().deleteJob(request, response,
1064
							params, userName, groupNames);
1065
					return;
1066
				} catch (BaseException be) {
1067
					ResponseUtil.sendErrorXML(response,
1068
							ResponseUtil.DELETE_SCHEDULED_WORKFLOW_ERROR, be);
1069
					return;
1070
				}
1071

    
1072
			} else {
1073
				//try the plugin handler if it has an entry for handling this action
1074
				MetacatHandlerPlugin handlerPlugin = MetacatHandlerPluginManager.getInstance().getHandler(action);
1075
				if (handlerPlugin != null) {
1076
					handlerPlugin.handleAction(action, params, request, response, userName, groupNames, sessionId);
1077
				} 
1078
				else {
1079
					PrintWriter out = response.getWriter();
1080
					out.println("<?xml version=\"1.0\"?>");
1081
					out.println("<error>");
1082
					out.println("Error: action: " + action + " not registered.  Please report this error.");
1083
					out.println("</error>");
1084
					out.close();
1085
				}
1086
			}
1087

    
1088
			// Schedule the sitemap generator to run periodically
1089
			handler.scheduleSitemapGeneration(request);
1090

    
1091

    
1092
		} catch (PropertyNotFoundException pnfe) {
1093
			String errorString = "Critical property not found: " + pnfe.getMessage();
1094
			logMetacat.error("MetaCatServlet.handleGetOrPost - " + errorString);
1095
			throw new ServletException(errorString);
1096
		} catch (MetacatUtilException ue) {
1097
			String errorString = "Utility error: " + ue.getMessage();
1098
			logMetacat.error("MetaCatServlet.handleGetOrPost - " + errorString);
1099
			throw new ServletException(errorString);
1100
		} catch (ServiceException ue) {
1101
			String errorString = "Service error: " + ue.getMessage();
1102
			logMetacat.error("MetaCatServlet.handleGetOrPost - " + errorString);
1103
			throw new ServletException(errorString);
1104
		} catch (HandlerException he) {
1105
			String errorString = "Handler error: " + he.getMessage();
1106
			logMetacat.error("MetaCatServlet.handleGetOrPost - " + errorString);
1107
			throw new ServletException(errorString);
1108
		} catch (ErrorSendingErrorException esee) {
1109
			String errorString = "Error sending error message: " + esee.getMessage();
1110
			logMetacat.error("MetaCatServlet.handleGetOrPost - " + errorString);
1111
			throw new ServletException(errorString);
1112
		} catch (ErrorHandledException ehe) {
1113
			// Nothing to do here.  We assume if we get here, the error has been 
1114
			// written to ouput.  Continue on and let it display.
1115
		} 
1116
	}
1117
    
1118
    /**
1119
     * Reports whether the MetaCatServlet has been fully initialized
1120
     * 
1121
     * @return true if fully intialized, false otherwise
1122
     */
1123
    public static boolean isFullyInitialized() {
1124
    	return _fullyInitialized;
1125
    }
1126
}
(42-42/65)