Project

General

Profile

« Previous | Next » 

Revision 5208

Added by daigle about 14 years ago

Move the chunking of large test element data to centralized location in DBSAXNode.writeChildNodeToDB(). Beff up logging

View differences:

Eml200SAXHandler.java
28 28
package edu.ucsb.nceas.metacat;
29 29

  
30 30
import java.io.BufferedReader;
31
import java.io.BufferedWriter;
32 31
import java.io.File;
33 32
import java.io.FileReader;
34 33
import java.io.FileWriter;
......
387 386
            // Bind the values to the query
388 387
            pstmt.setString(1, docid);
389 388
            pstmt.setString(2, TOPLEVEL);
389
            logMetacat.debug("Eml200SAXHandler.getTopAccessSubTreeFromDB - executing SQL: " + pstmt.toString());
390 390
            pstmt.execute();
391 391

  
392 392
            // Get result set
......
573 573
        // for element <eml:eml...> qname is "eml:eml", local name is "eml"
574 574
        // for element <acl....> both qname and local name is "eml"
575 575
        // uri is namesapce
576
        logMetacat.info("Start ELEMENT(qName) " + qName);
577
        logMetacat.info("Start ELEMENT(localName) " + localName);
578
        logMetacat.info("Start ELEMENT(uri) " + uri);
576
        logMetacat.debug("Start ELEMENT(qName) " + qName);
577
        logMetacat.debug("Start ELEMENT(localName) " + localName);
578
        logMetacat.debug("Start ELEMENT(uri) " + uri);
579 579

  
580 580
        DBSAXNode parentNode = null;
581 581
        DBSAXNode currentNode = null;
......
744 744
                    //the revision
745 745
                    if (!super.getIsRevisionDoc())
746 746
                    {
747
                       
747
                       logMetacat.debug("EML200SaxHandler.startElement - creating new DocumentImple for " + docid);
748 748
                       currentDocument = new DocumentImpl(connection, rootNode
749 749
                            .getNodeID(), docname, doctype, docid, revision,
750 750
                            action, user, this.pub, catalogid, this.serverCode, 
......
753 753
                   
754 754

  
755 755
                } catch (Exception ane) {
756
                    throw (new SAXException(
757
                            "Error in EMLSaxHandler.startElement " + action,
758
                            ane));
756
                    throw (new SAXException("EML200SaxHandler.startElement - error with action " + 
757
                    		action + " : " + ane.getMessage()));
759 758
                }
760 759
                
761 760
            }
......
1619 1618
        logMetacat.info("IGNORABLEWHITESPACE");
1620 1619
        if (!handleInlineData) {
1621 1620
            DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
1622
            String data = null;
1623
            int leftover = len;
1624
            int offset = start;
1625
            boolean moredata = true;
1621
            String data = new String(cbuf, start, len);
1626 1622

  
1627
            // This loop deals with the case where there are more characters
1628
            // than can fit in a single database text field (limit is
1629
            // MAXDATACHARS). If the text to be inserted exceeds MAXDATACHARS,
1630
            // write a series of nodes that are MAXDATACHARS long, and then the
1631
            // final node contains the remainder
1632
            while (moredata) {
1633
                if (leftover > MAXDATACHARS) {
1634
                    data = new String(cbuf, offset, MAXDATACHARS);
1635
                    leftover -= MAXDATACHARS;
1636
                    offset += MAXDATACHARS;
1637
                } else {
1638
                    data = new String(cbuf, offset, leftover);
1639
                    moredata = false;
1640
                }
1641

  
1642
                //compare whitespace if need
1643
                /*if (startCriticalSubTree) {
1644
                    compareWhiteSpace(currentUnChangedableSubtreeNodeStack,
1645
                            data, PERMISSIONERROR);
1646
                }//if*/
1647

  
1648 1623
                //compare whitespace in access top module
1649 1624
                if (processTopLeverAccess && needCheckingAccessModule) {
1650 1625
                    /*compareWhiteSpace(currentUnchangableAccessModuleNodeStack,
......
1661 1636
                }
1662 1637
                endNodeId = currentNode.writeChildNodeToDB("TEXT", null, data,
1663 1638
                        docid);
1664
            }
1665 1639
        } else {
1666 1640
            //This is inline data write to file directly
1667 1641
            StringBuffer inlineWhiteSpace = new StringBuffer(new String(cbuf,
......
2327 2301
            logMetacat.info("Start node id is: " + startNodeId);
2328 2302
            pstmt.setLong(6, endNodeId);
2329 2303
            logMetacat.info("End node id is: " + endNodeId);
2330
            logMetacat.debug("running sql: " + pstmt.toString());
2304
            logMetacat.debug("Eml200SAXHandler.writeAccessSubTreeIntoDB - executing SQL: " + pstmt.toString());
2331 2305
            pstmt.execute();
2332 2306
            pstmt.close();
2333 2307
        }//try
......
2589 2563
            //bind variable
2590 2564
            pStmt.setString(1, docid);
2591 2565
            //execute query
2566
            logMetacat.debug("Eml200SAXHandler.deleteRelations - executing SQL: " + pStmt.toString());
2592 2567
            pStmt.execute();
2593 2568
            pStmt.close();
2594 2569
        }//try
......
2625 2600
            pStmt.setString(4, RELATION);
2626 2601
            pStmt.setString(5, dataId);
2627 2602
            //execute query
2603
            logMetacat.debug("Eml200SAXHandler.writeOnlineDataFileIdIntoRelationTable - executing SQL: " + pStmt.toString());
2628 2604
            pStmt.execute();
2629 2605
            pStmt.close();
2630 2606
        }//try

Also available in: Unified diff