Project

General

Profile

« Previous | Next » 

Revision 4080

Added by daigle almost 16 years ago

Merge 1.9 changes into Head

View differences:

DBSAXHandler.java
37 37
import java.util.Stack;
38 38
import java.util.Vector;
39 39

  
40
import edu.ucsb.nceas.metacat.service.PropertyService;
41
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
40 42
import edu.ucsb.nceas.morpho.datapackage.Triple;
41 43
import edu.ucsb.nceas.morpho.datapackage.TripleCollection;
44
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
42 45

  
43 46
import org.apache.log4j.Logger;
44 47
import org.xml.sax.Attributes;
......
226 229
    }
227 230

  
228 231
    /** SAX Handler that receives notification of end of the document */
229
    public void endDocument() throws SAXException
230
    {
231
        logMetacat.info("end Document");
232
        // Starting new thread for writing XML Index.
233
        // It calls the run method of the thread.
232
	public void endDocument() throws SAXException {
233
		logMetacat.info("end Document");
234
		// Starting new thread for writing XML Index.
235
		// It calls the run method of the thread.
234 236

  
235
        //if it is data package insert triple into relationtion table;
236
        if (doctype != null
237
                && MetaCatUtil.getOptionList(
238
                        MetaCatUtil.getOption("packagedoctype")).contains(
239
                        doctype) && hasTriple && !isRevisionDoc) {
240
            try {
241
                //initial handler and write into relationdb only for xml-documents
242
                if (!isRevisionDoc)
243
                {
244
                  RelationHandler handler = new RelationHandler(docid, doctype,
245
                        connection, tripleList);
246
                }
247
            } catch (Exception e) {
248
                logMetacat.error(
249
                        "Failed to write triples into relation table"
250
                                + e.getMessage());
251
                throw new SAXException(
252
                        "Failed to write triples into relation table "
253
                                + e.getMessage());
254
            }
255
        }
256
    }
237
		try {
238
			// if it is data package insert triple into relationtion table;
239
			if (doctype != null
240
					&& MetaCatUtil.getOptionList(
241
							PropertyService.getProperty("packagedoctype")).contains(
242
							doctype) && hasTriple && !isRevisionDoc) {
257 243

  
244
				// initial handler and write into relationdb only for
245
				// xml-documents
246
				if (!isRevisionDoc) {
247
					RelationHandler handler = new RelationHandler(docid, doctype,
248
							connection, tripleList);
249
				}
250
			}
251
		} catch (Exception e) {
252
			logMetacat.error("Failed to write triples into relation table"
253
					+ e.getMessage());
254
			throw new SAXException("Failed to write triples into relation table "
255
					+ e.getMessage());
256
		}
257
	}
258

  
258 259
    /** SAX Handler that is called at the start of Namespace */
259 260
    public void startPrefixMapping(String prefix, String uri)
260 261
            throws SAXException
......
418 419
        }
419 420

  
420 421
        // Add the node to the stack, so that any text data can be
421
        // added as it is encountered
422
        nodeStack.push(currentNode);
423
        // Add the node to the vector used by thread for writing XML Index
424
        nodeIndex.addElement(currentNode);
425
        // start parsing triple
426
        if (doctype != null
427
                && MetaCatUtil.getOptionList(
428
                        MetaCatUtil.getOption("packagedoctype")).contains(
429
                        doctype) && localName.equals("triple")) {
430
            startParseTriple = true;
431
            hasTriple = true;
432
            currentTriple = new Triple();
433
        }
434
    }    
422
		// added as it is encountered
423
		nodeStack.push(currentNode);
424
		// Add the node to the vector used by thread for writing XML Index
425
		nodeIndex.addElement(currentNode);
426
		// start parsing triple
427
		try {
428
			if (doctype != null
429
					&& MetaCatUtil.getOptionList(
430
							PropertyService.getProperty("packagedoctype")).contains(doctype)
431
					&& localName.equals("triple")) {
432
				startParseTriple = true;
433
				hasTriple = true;
434
				currentTriple = new Triple();
435
			}
436
		} catch (PropertyNotFoundException pnfe) {
437
			pnfe.printStackTrace();
438
			throw (new SAXException("Error in DBSaxHandler.startElement " + action, pnfe));
439
		}
440
	}               
441
    
435 442

  
436 443
    /** SAX Handler that is called for each XML text node */
437 444
    public void characters(char[] cbuf, int start, int len) throws SAXException

Also available in: Unified diff