Project

General

Profile

« Previous | Next » 

Revision 5208

Added by daigle almost 15 years ago

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

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
92 92
import edu.ucsb.nceas.metacat.shared.BaseException;
93 93
import edu.ucsb.nceas.metacat.shared.HandlerException;
94 94
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
95
import edu.ucsb.nceas.metacat.spatial.SpatialFeatureSchema;
95 96
import edu.ucsb.nceas.metacat.spatial.SpatialHarvester;
96 97
import edu.ucsb.nceas.metacat.spatial.SpatialQuery;
97 98
import edu.ucsb.nceas.metacat.util.AuthUtil;
......
413 414
			 * If spatial option is turned on and set to regenerate the spatial
414 415
			 * cache on restart, trigger the harvester regeneratation method
415 416
			 */
416
			if (PropertyService.getProperty("spatial.runSpatialOption").equals("true")
417
					&& PropertyService.getProperty("spatial.regenerateCacheOnRestart").equals("true")) {
417
			if (PropertyService.getProperty("spatial.runSpatialOption").equals("true")) {
418
//					&& PropertyService.getProperty("spatial.regenerateCacheOnRestart").equals("true")) {
418 419

  
419 420
				// Begin timer
420 421
				long before = System.currentTimeMillis();
421 422

  
422
				// regenerate the entire spatial cache
423
				// may be expensive with many documents
424
				SpatialHarvester sh = new SpatialHarvester();
425
				sh.regenerate();
426
				sh.destroy();
423
				// if either the point or polygon shape files do not exist, then regenerate the entire spatial cache
424
				// this may be expensive with many documents
425
				if( FileUtil.getFileStatus(SpatialFeatureSchema.pointShpUri) == FileUtil.DOES_NOT_EXIST) {		
426
					SpatialHarvester sh = new SpatialHarvester();
427
					sh.regenerate();
428
					sh.destroy();
429
				}
427 430

  
428 431
				// After running the first time, we want to to set
429 432
				// regenerateCacheOnRestart to false
430 433
				// so that it does not regenerate the cache every time tomcat is
431 434
				// restarted
432
				PropertyService.setProperty("spatial.regenerateCacheOnRestart", "false");
435
//				PropertyService.setProperty("spatial.regenerateCacheOnRestart", "false");
433 436

  
434 437
				// End timer
435 438
				long after = System.currentTimeMillis();
......
2397 2400
                    serialNumber = dbConn.getCheckOutSerialNumber();
2398 2401
                    
2399 2402
                    // write the document to the database and disk
2400
                    try {
2401
                        String accNumber = docid[0];
2402
                        logMetacat.debug("MetaCatServlet.handleInsertOrUpdateAction - " + doAction + " "
2403
                                + accNumber + "...");
2404
                        if (accNumber.equals("")) {
2405
                            accNumber = null;
2406
                        }
2407

  
2403
                    String accNumber = docid[0];
2404
                    logMetacat.debug("MetaCatServlet.handleInsertOrUpdateAction - " + doAction + " "
2405
                            + accNumber + "...");
2406
                    if (accNumber == null || accNumber.equals("")) {
2407
                        logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - writing with null acnumber");
2408 2408
                        newdocid = documentWrapper.write(dbConn, doctext[0], pub, dtd,
2409
                                doAction, accNumber, user, groups);
2410
                                
2411
                        EventLog.getInstance().log(request.getRemoteAddr(),
2412
                                user, accNumber, action[0]);
2413
                    } catch (NullPointerException npe) {
2414
                      // MCD this seems a bit dubious, since many things can throw npe
2415
                      logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - writing with null acnumber");
2416
                        newdocid = documentWrapper.write(dbConn, doctext[0], pub, dtd,
2417 2409
                                doAction, null, user, groups);
2418 2410
                        EventLog.getInstance().log(request.getRemoteAddr(),
2419 2411
                                user, "", action[0]);
2420
                    }
2412
                    } else
2413
	                    newdocid = documentWrapper.write(dbConn, doctext[0], pub, dtd,
2414
	                            doAction, accNumber, user, groups);
2415
	                            
2416
	                    EventLog.getInstance().log(request.getRemoteAddr(),
2417
	                            user, accNumber, action[0]);
2421 2418
                } finally {
2422 2419
                    // Return db connection
2423 2420
                    DBConnectionPool.returnDBConnection(dbConn, serialNumber);
......
2436 2433
                output += "<error>";
2437 2434
                output += npe.getMessage();
2438 2435
                output += "</error>";
2439
                logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - Error in writing eml document to the database" + npe.getMessage());
2436
                logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - Null pointer error when writing eml document to the database: " + npe.getMessage());
2440 2437
                npe.printStackTrace();
2441 2438
            }
2442 2439
        } catch (Exception e) {
......
2445 2442
            output += "<error>";
2446 2443
            output += e.getMessage();
2447 2444
            output += "</error>";
2448
            logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - Error in writing eml document to the database" + e.getMessage());
2445
            logMetacat.warn("MetaCatServlet.handleInsertOrUpdateAction - General error when writing eml document to the database: " + e.getMessage());
2449 2446
            e.printStackTrace();
2450 2447
        }
2451 2448
        
src/edu/ucsb/nceas/metacat/DBSAXNode.java
124 124
      writeDTDNodeToDB(DocumentImpl.SYSTEMID, systemId, docid);
125 125
    }
126 126
  }
127

  
127
  
128 128
  /** creates SQL code and inserts new node into DB connection */
129 129
  public long writeChildNodeToDB(String nodetype, String nodename,
130 130
                                 String data, String docid)
131
                                 throws SAXException {
132
    String limitedData = null;
133
    int leftover = 0;
134
    if (data != null) {
135
    	leftover = data.length();
136
    }
137
    int offset = 0;
138
    boolean moredata = true;
139
    long endNodeId = -1;
140

  
141
    // This loop deals with the case where there are more characters
142
    // than can fit in a single database text field (limit is
143
    // MAXDATACHARS). If the text to be inserted exceeds MAXDATACHARS,
144
    // write a series of nodes that are MAXDATACHARS long, and then the
145
    // final node contains the remainder
146
    while (moredata) {
147
        if (leftover > DBSAXHandler.MAXDATACHARS) {
148
        	limitedData = data.substring(offset, DBSAXHandler.MAXDATACHARS);
149
            leftover -= DBSAXHandler.MAXDATACHARS;
150
            offset += DBSAXHandler.MAXDATACHARS;
151
        } else {
152
        	limitedData = data;
153
            moredata = false;
154
        }
155
        endNodeId =  writeChildNodeToDBDataLimited(nodetype, nodename,
156
              limitedData, docid);
157
    }
158
    
159
    return endNodeId;
160
  }
161

  
162
  /** creates SQL code and inserts new node into DB connection */
163
  public long writeChildNodeToDBDataLimited(String nodetype, String nodename,
164
                                 String data, String docid)
131 165
                                 throws SAXException
132 166
  {
133 167
    long nid = -1;
......
144 178

  
145 179
        // Increase DBConnection usage count
146 180
        connection.increaseUsageCount(1);
147
        logMetacat.info("INSERTING DOCNAME: " + nodename);
181
        logMetacat.debug("DBSAXNode.writeChildNodeToDBDataLimited - inserting doc name: " + nodename);
148 182
      } else {
149 183
          if(data != null && !data.trim().equals("")
150 184
             && !data.trim().equals("NaN") && !data.trim().equalsIgnoreCase("Infinity")){
......
184 218
        pstmt.setString(3, null);
185 219
      }
186 220
      pstmt.setString(4, docid);
187
      if (nodetype == "DOCUMENT") {
188
        // moved it to separate method updateRootNodeID
189
        //pstmt.setLong(4, nid);
190
      } else {
221
      if (nodetype != "DOCUMENT") {
191 222
        if (nodetype == "ELEMENT") {
192 223
          pstmt.setLong(5, getRootNodeID());
193 224
          pstmt.setLong(6, getParentID());
......
201 232
        }
202 233
      }
203 234
      // Do the insertion
204
      logMetacat.debug("SQL insert: " + pstmt.toString());
235
      logMetacat.debug("DBSAXNode.writeChildNodeToDBDataLimited - SQL insert: " + pstmt.toString());
205 236
      pstmt.execute();
206 237
      pstmt.close();
207 238

  
208 239
      // get the generated unique id afterward
209 240
      nid = DatabaseService.getDBAdapter().getUniqueID(connection.getConnections(), "xml_nodes");
210
      //should incease connection usage!!!!!!
241
      //should increase connection usage!!!!!!
211 242

  
212 243

  
213 244
      if (nodetype.equals("DOCUMENT")) {
......
225 256

  
226 257
      }
227 258

  
228
    } catch (SQLException e) {
229
      logMetacat.error("Error in DBSaxNode.writeChildNodeToDB");
230
      logMetacat.error("Error inserting node: (" + nodetype + ", " +
231
                                                     nodename + ", " +
232
                                                     data + ")" );
233
      logMetacat.error(e.getMessage());
234
      e.printStackTrace(System.err);
235
      throw new SAXException(e.getMessage());
259
    } catch (SQLException sqle) {
260
      logMetacat.error("DBSAXNode.writeChildNodeToDBDataLimited - SQL error inserting node: " + 
261
    		  "(" + nodetype + ", " + nodename + ", " + data + ") : " + sqle.getMessage());
262
      sqle.printStackTrace(System.err);
263
      throw new SAXException(sqle.getMessage());
236 264
    }
237 265
    return nid;
238 266
  }
......
297 325
    {
298 326

  
299 327
      PreparedStatement pstmt;
300
      logMetacat.info("Insert dtd into db: "+nodename +" "+data);
328
      logMetacat.info("DBSAXNode.writeDTDNodeToDB - Insert dtd into db: "+nodename +" "+data);
301 329
      if(data != null && !data.trim().equals("")){
302 330
            try{
303 331
                double numberData = Double.parseDouble(data);
src/edu/ucsb/nceas/metacat/util/DocumentUtil.java
65 65
        try {
66 66
        	separator = PropertyService.getProperty("document.accNumSeparator").charAt(0);
67 67
        } catch (PropertyNotFoundException pnfe) {
68
        	logMetacat.error("Could not retrieve account number separator. " 
68
        	logMetacat.error("DocumentUtil() - Could not retrieve account number separator. " 
69 69
        			+ "Separator set to '.' : " + pnfe.getMessage());
70 70
        }
71 71
    }
......
82 82
        int count = 0; //keep track how many & was found
83 83
        Vector list = new Vector();// keep index number for &
84 84
        if (url == null) {
85
            logMetacat.info("url is null and null will be returned");
85
            logMetacat.debug("DocumentUtil.getDocIdWithRevFromOnlineURL - url is null and null will be returned");
86 86
            return docid;
87 87
        }
88 88
        // the first element in list is 0
......
95 95
                // get substring beween two &
96 96
                String str = url.substring(
97 97
                        ((Integer) list.elementAt(count - 1)).intValue(), i);
98
                logMetacat.info("substring between two & is: " + str);
98
                logMetacat.debug("DocumentUtil.getDocIdWithRevFromOnlineURL - substring between two & is: " + str);
99 99
                //if the subString contains docid, we got it
100 100
                if (str.indexOf(DOCID) != -1) {
101 101
                    //get index of '="
......
110 110
        // and
111 111
        // the end of string
112 112
        if (!find) {
113
            logMetacat.info("Checking the last substring");
113
            logMetacat.debug("DocumentUtil.getDocIdWithRevFromOnlineURL - Checking the last substring");
114 114
            String str = url.substring(((Integer) list.elementAt(count))
115 115
                    .intValue() + 1, url.length());
116
            logMetacat.info("Last substring is: " + str);
116
            logMetacat.debug("DocumentUtil.getDocIdWithRevFromOnlineURL - Last substring is: " + str);
117 117
            if (str.indexOf(DOCID) != -1) {
118 118
                //get index of '="
119 119
                int start = getIndexForGivenChar(str, '=') + 1;
......
122 122
                find = true;
123 123
            }//if
124 124
        }//if
125
        logMetacat.info("The docid from online url is:" + docid);
125
        logMetacat.debug("DocumentUtil.getDocIdWithRevFromOnlineURL - The docid from online url is:" + docid);
126 126
        return docid.trim();
127 127
    }
128 128

  
......
145 145
        int end   = identifier.length();
146 146
        accessionNumber = identifier.substring(start, end);
147 147
      }
148
      logMetacat.warn("The accession number from url is " +
148
      logMetacat.warn("DocumentUtil.getAccessionNumberFromEcogridIdentifier - The accession number from url is " +
149 149
                                 accessionNumber);
150 150
      return accessionNumber;
151 151
    }
......
155 155
        int index = -1;
156 156
        // make sure str is not null
157 157
        if (str == null) {
158
            logMetacat.info(
158
            logMetacat.debug("DocumentUtil.getIndexForGivenChar - " +
159 159
                    "The given str is null and -1 will be returned");
160 160
            return index;
161 161
        }
......
167 167
                break;
168 168
            }//if
169 169
        }//for
170
        logMetacat.info("the index for char " + character + " is: "
171
                + index);
170
        logMetacat.info("DocumentUtil.getIndexForGivenChar - the index for char " + 
171
        		character + " is: " + index);
172 172
        return index;
173 173
    }
174 174

  
......
184 184
    {
185 185
        String docId = null;
186 186
        if (str == null) {
187
            logMetacat.info(
188
                    "The given str is null and null will be returned"
187
            logMetacat.debug(
188
                    "DocumentUtil.getDocIdFromString - The given str is null and null will be returned"
189 189
                            + " in getDocIdfromString");
190 190
            return docId;
191 191
        } //make sure docid is not null
......
305 305
        if (accessionNumber == null) { return docid; }
306 306
        int indexOfLastSeperator = accessionNumber.lastIndexOf(separator);
307 307
        docid = accessionNumber.substring(0, indexOfLastSeperator);
308
        logMetacat.info("after parsing accessionnumber, docid is "
308
        logMetacat.debug("DocumentUtil.getDocIdFromAccessionNumber - after parsing accession number, docid is "
309 309
                + docid);
310 310
        return docid;
311 311
    }
......
324 324
        accessionNumber = accessionNumber.substring(0, indexOfLastSeperator);
325 325
        indexOfLastSeperator = accessionNumber.lastIndexOf(separator);
326 326
        docid = accessionNumber.substring(0, indexOfLastSeperator) + version;
327
        logMetacat.info("after parsing accessionnumber, docid is "
327
        logMetacat.debug("DocumentUtil.getInlineDataIdWithoutRev - after parsing accessionnumber, docid is "
328 328
                                 + docid);
329 329

  
330 330
        return docid;
......
349 349
        if (docid == null) {
350 350
            docid = getDocIdFromAccessionNumber(str);
351 351
        }
352
        logMetacat.info("The docid get from smart docid getor is "
352
        logMetacat.debug("DocumentUtil.getSmartDocId - The docid get from smart docid getor is "
353 353
                + docid);
354 354
        return docid;
355 355
    }
......
369 369
        rev = accessionNumber.substring(indexOfLastSeperator + 1,
370 370
                accessionNumber.length());
371 371
        revNumber = Integer.parseInt(rev);
372
        logMetacat.info("after parsing accessionnumber, rev is "
372
        logMetacat.debug("DocumentUtil.getRevisionFromAccessionNumber - after parsing accessionnumber, rev is "
373 373
                + revNumber);
374 374
        return revNumber;
375 375
    }
......
398 398
            }
399 399
        }
400 400

  
401
        logMetacat.info("Docid without rev from inlinedata id: "
401
        logMetacat.debug("DocumentUtil.getDocIdWithoutRevFromInlineDataID - Docid without rev from inlinedata id: "
402 402
                + docidWithoutRev);
403 403
        return docidWithoutRev;
404 404

  
src/edu/ucsb/nceas/metacat/DBSAXHandler.java
115 115

  
116 116
//    protected Stack textBufferStack = new Stack();
117 117

  
118
    protected static final int MAXDATACHARS = 4000;
118
    public static final int MAXDATACHARS = 4000;
119 119

  
120 120
    //protected static final int MAXDATACHARS = 50;
121 121

  
......
223 223
    /** SAX Handler that receives notification of beginning of the document */
224 224
    public void startDocument() throws SAXException
225 225
    {
226
        logMetacat.info("start Document");
226
        logMetacat.debug("DBSaxHandler.startDocument - starting document");
227 227

  
228 228
        // Create the document node representation as root
229 229
        rootNode = new DBSAXNode(connection, this.docid);
......
234 234

  
235 235
    /** SAX Handler that receives notification of end of the document */
236 236
	public void endDocument() throws SAXException {
237
		logMetacat.info("end Document");
237
		logMetacat.debug("DBSaxHandler.endDocument - ending document");
238 238
		// Starting new thread for writing XML Index.
239 239
		// It calls the run method of the thread.
240 240

  
......
253 253
				}
254 254
			}
255 255
		} catch (Exception e) {
256
			logMetacat.error("Failed to write triples into relation table"
256
			logMetacat.error("DBSaxHandler.endDocument - Failed to write triples into relation table"
257 257
					+ e.getMessage());
258 258
			throw new SAXException("Failed to write triples into relation table "
259 259
					+ e.getMessage());
......
274 274
    public void startPrefixMapping(String prefix, String uri)
275 275
            throws SAXException
276 276
    {
277
        logMetacat.info("NAMESPACE");
277
        logMetacat.debug("DBSaxHandler.startPrefixMapping - Starting namespace");
278 278

  
279 279
        namespaces.put(prefix, uri);
280 280
    }
......
286 286
        // for element <eml:eml...> qname is "eml:eml", local name is "eml"
287 287
        // for element <acl....> both qname and local name is "eml"
288 288
        // uri is namespace
289
        logMetacat.info("Start ELEMENT(qName) " + qName);
290
        logMetacat.info("Start ELEMENT(localName) " + localName);
291
        logMetacat.info("Start ELEMENT(uri) " + uri);
289
        logMetacat.debug("DBSaxHandler.startElement - Start ELEMENT(qName) " + qName);
290
        logMetacat.debug("DBSaxHandler.startElement - Start ELEMENT(localName) " + localName);
291
        logMetacat.debug("DBSaxHandler.startElement - Start ELEMENT(uri) " + uri);
292 292

  
293 293
        DBSAXNode parentNode = null;
294 294
        DBSAXNode currentNode = null;
......
328 328
                } else {
329 329
                    doctype = docname;
330 330
                }
331
                logMetacat.info("DOCNAME-a: " + docname);
332
                logMetacat.info("DOCTYPE-a: " + doctype);
331
                logMetacat.debug("DBSaxHandler.startElement - DOCNAME-a: " + docname);
332
                logMetacat.debug("DBSaxHandler.startElement - DOCTYPE-a: " + doctype);
333 333
            } else if (doctype == null) {
334 334
                // because docname is not null and it is declared in dtd
335 335
                // so could not be in schema, no namespace
336 336
                doctype = docname;
337
                logMetacat.info("DOCTYPE-b: " + doctype);
337
                logMetacat.debug("DBSaxHandler.startElement - DOCTYPE-b: " + doctype);
338 338
            }
339 339
           
340 340
            rootNode.writeNodename(docname);
......
467 467
    /** SAX Handler that is called for each XML text node */
468 468
    public void characters(char[] cbuf, int start, int len) throws SAXException
469 469
    {
470
        logMetacat.info("CHARACTERS");
470
        logMetacat.debug("DBSaxHandler.characters - starting characters");
471 471
        // buffer all text nodes for same element. This is for if text was split
472 472
        // into different nodes
473 473
        textBuffer.append(new String(cbuf, start, len));
......
476 476
        // if text buffer .size is greater than max, write it to db.
477 477
        // so we can save memory
478 478
        if (textBuffer.length() > MAXDATACHARS) {
479
            logMetacat.info("Write text into DB in charaters"
479
            logMetacat.debug("DBSaxHandler.characters - Write text into DB in charaters"
480 480
                    + " when text buffer size is greater than maxmum number");
481 481
            DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
482 482
            endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
......
496 496
        // When validation is turned "on", white spaces are reported here
497 497
        // When validation is turned "off" white spaces are not reported here,
498 498
        // but through characters() callback
499
        logMetacat.info("IGNORABLEWHITESPACE");
499
        logMetacat.debug("DBSaxHandler.ignorableWhitespace - in ignorableWhitespace");
500 500

  
501 501
        DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
502
        String data = null;
503
        int leftover = len;
504
        int offset = start;
505
        boolean moredata = true;
506 502

  
507
        // This loop deals with the case where there are more characters
508
        // than can fit in a single database text field (limit is
509
        // MAXDATACHARS). If the text to be inserted exceeds MAXDATACHARS,
510
        // write a series of nodes that are MAXDATACHARS long, and then the
511
        // final node contains the remainder
512
        while (moredata) {
513
            if (leftover > MAXDATACHARS) {
514
                data = new String(cbuf, offset, MAXDATACHARS);
515
                leftover -= MAXDATACHARS;
516
                offset += MAXDATACHARS;
517
            } else {
518
                data = new String(cbuf, offset, leftover);
519
                moredata = false;
520
            }
521

  
522 503
            // Write the content of the node to the database
523
            endNodeId = currentNode.writeChildNodeToDB("TEXT", null, data,
504
            endNodeId = currentNode.writeChildNodeToDB("TEXT", null, new String(cbuf, start, len),
524 505
                    docid);
525
        }
526 506
    }
527 507

  
528 508
    /**
......
532 512
    public void processingInstruction(String target, String data)
533 513
            throws SAXException
534 514
    {
535
        logMetacat.info("PI");
515
        logMetacat.debug("DBSaxHandler.processingInstruction - in processing instructions");
536 516
        DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
537 517
        endNodeId = currentNode.writeChildNodeToDB("PI", target, data, docid);
538 518
    }
......
541 521
    public void endElement(String uri, String localName, String qName)
542 522
            throws SAXException
543 523
    {
544
        logMetacat.info("End ELEMENT " + qName);
524
        logMetacat.debug("DBSaxHandler.endElement - End element " + qName);
545 525

  
546 526
        // write buffered text nodes into db (so no splited)
547 527
        DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
......
550 530
        // into the buffer, write the buffer to data base. The reason we put
551 531
        // write database here is for xerces some time split text node
552 532
        if (hitTextNode) {
553
            logMetacat.info("Write text into DB in End Element");
533
            logMetacat.debug("DBSaxHandler.endElement - Write text into DB in End Element");
554 534
            endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
555 535
                    currentNode);
556 536

  
......
608 588
        // we don't put the dtd node into node stack
609 589
        DBSAXNode dtdNode = new DBSAXNode(connection, name, publicId, systemId,
610 590
                currentNode, currentNode.getRootNodeID(), docid);
611
        logMetacat.info("Start DTD");
612
        logMetacat.info("Setting processingDTD to true");
613
        logMetacat.info("DOCNAME: " + docname);
614
        logMetacat.info("DOCTYPE: " + doctype);
615
        logMetacat.info("  SYSID: " + systemid);
591
        logMetacat.debug("DBSaxHandler.startDTD - Start DTD");
592
        logMetacat.debug("DBSaxHandler.startDTD - Setting processingDTD to true");
593
        logMetacat.debug("DBSaxHandler.startDTD - DOCNAME: " + docname);
594
        logMetacat.debug("DBSaxHandler.startDTD - DOCTYPE: " + doctype);
595
        logMetacat.debug("DBSaxHandler.startDTD - SYSID: " + systemid);
616 596
    }
617 597

  
618 598
    /**
......
622 602
    {
623 603

  
624 604
        processingDTD = false;
625
        logMetacat.info("Setting processingDTD to false");
626
        logMetacat.info("end DTD");
605
        logMetacat.debug("DBSaxHandler.endDTD - Setting processingDTD to false");
606
        logMetacat.debug("DBSaxHandler.endDTD - end DTD");
627 607
    }
628 608

  
629 609
    /**
......
631 611
     */
632 612
    public void comment(char[] ch, int start, int length) throws SAXException
633 613
    {
634
        logMetacat.info("COMMENT");
614
        logMetacat.debug("DBSaxHandler.comment - starting comment");
635 615
        if (!processingDTD) {
636 616
            DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
637 617
            endNodeId = currentNode.writeChildNodeToDB("COMMENT", null,
......
644 624
     */
645 625
    public void startCDATA() throws SAXException
646 626
    {
647
        logMetacat.info("start CDATA");
627
        logMetacat.debug("DBSaxHandler.startCDATA - starting CDATA");
648 628
    }
649 629

  
650 630
    /**
......
652 632
     */
653 633
    public void endCDATA() throws SAXException
654 634
    {
655
        logMetacat.info("end CDATA");
635
        logMetacat.debug("DBSaxHandler.endCDATA - end CDATA");
656 636
    }
657 637

  
658 638
    /**
......
660 640
     */
661 641
    public void startEntity(String name) throws SAXException
662 642
    {
663
        logMetacat.info("start ENTITY: " + name);
643
        logMetacat.debug("DBSaxHandler.startEntity - starting entity: " + name);
664 644
        //System.out.println("start ENTITY: " + name);
665 645
        if (name.equals("[dtd]")) {
666 646
            processingDTD = true;
......
672 652
     */
673 653
    public void endEntity(String name) throws SAXException
674 654
    {
675
        logMetacat.info("end ENTITY: " + name);
655
        logMetacat.debug("DBSaxHandler.endEntity - ending entity: " + name);
676 656
        //System.out.println("end ENTITY: " + name);
677 657
        if (name.equals("[dtd]")) {
678 658
            processingDTD = false;
......
686 666
            throws org.xml.sax.SAXException
687 667
    {
688 668
        //System.out.println("ELEMENTDECL: " + name + " " + model);
689
        logMetacat.info("ELEMENTDECL: " + name + " " + model);
669
        logMetacat.debug("DBSaxHandler.elementDecl - element declaration: " + name + " " + model);
690 670
    }
691 671

  
692 672
    /**
......
699 679
        //System.out.println("ATTRIBUTEDECL: " + eName + " "
700 680
        //                        + aName + " " + type + " " + valueDefault + " "
701 681
        //                        + value);
702
        logMetacat.info("ATTRIBUTEDECL: " + eName + " " + aName + " "
682
        logMetacat.debug("DBSaxHandler.attributeDecl - attribute declaration: " + eName + " " + aName + " "
703 683
                + type + " " + valueDefault + " " + value);
704 684
    }
705 685

  
......
710 690
            throws org.xml.sax.SAXException
711 691
    {
712 692
        //System.out.println("INTERNENTITYDECL: " + name + " " + value);
713
        logMetacat.info("INTERNENTITYDECL: " + name + " " + value);
693
        logMetacat.debug("DBSaxHandler.internalEntityDecl - internal entity declaration: " + name + " " + value);
714 694
    }
715 695

  
716 696
    /**
......
721 701
    {
722 702
        //System.out.println("EXTERNENTITYDECL: " + name + " " + publicId
723 703
        //                              + " " + systemId);
724
        logMetacat.info("EXTERNENTITYDECL: " + name + " " + publicId
704
        logMetacat.debug("DBSaxHandler.externalEntityDecl - external entity declaration: " + name + " " + publicId
725 705
                + " " + systemId);
726 706
        // it processes other external entity, not the DTD;
727 707
        // it doesn't signal for the DTD here
......
737 717
     */
738 718
    public void fatalError(SAXParseException exception) throws SAXException
739 719
    {
740
        logMetacat.fatal("FATALERROR: " + exception.getMessage());
720
        logMetacat.fatal("DBSaxHandler.fatalError - " + exception.getMessage());
741 721
        throw (new SAXException("Fatal processing error.", exception));
742 722
    }
743 723

  
......
746 726
     */
747 727
    public void error(SAXParseException exception) throws SAXException
748 728
    {
749
        logMetacat.error("ERROR: " + exception.getMessage());
729
        logMetacat.error("DBSaxHandler.error - " + exception.getMessage());
750 730
        throw (new SAXException("Error in processing EML.", exception));
751 731
    }
752 732

  
......
755 735
     */
756 736
    public void warning(SAXParseException exception) throws SAXException
757 737
    {
758
        logMetacat.warn("WARNING: " + exception.getMessage());
738
        logMetacat.warn("DBSaxHandler.warning - " + exception.getMessage());
759 739
        throw (new SAXException("Warning.", exception));
760 740
    }
761 741

  
......
806 786
        // Check parameter
807 787
        if (strBuffer == null || node == null) { return nodeId; }
808 788
        boolean moredata = true;
809
        String data = null;
810 789

  
811 790
        String normalizedData = strBuffer.toString();
812
        logMetacat.debug("Before normalize in write process === "+normalizedData);
791
        logMetacat.debug("DBSAXHandler.writeTextForDBSAXNode - Before normalize in write process: " + normalizedData);
813 792
        String afterNormalize = MetacatUtil.normalize(normalizedData);
814
        logMetacat.debug("After normalize in write process === "+afterNormalize);
793
        logMetacat.debug("DBSAXHandler.writeTextForDBSAXNode - After normalize in write process: " + afterNormalize);
815 794
        strBuffer = new StringBuffer(afterNormalize);;
816 795

  
817 796
        int bufferSize = strBuffer.length();
......
819 798

  
820 799
        // if there are some cotent in buffer, write it
821 800
        if (bufferSize > 0) {
822
            logMetacat.info("Write text into DB");
823
            // This loop deals with the case where there are more characters
824
            // than can fit in a single database text field (limit is
825
            // MAXDATACHARS). If the text to be inserted exceeds MAXDATACHARS,
826
            // write a series of nodes that are MAXDATACHARS long, and then the
827
            // final node contains the remainder
828
            while (moredata) {
829
                bufferSize = strBuffer.length();
830
                if (bufferSize > MAXDATACHARS) {
831
                    data = strBuffer.substring(start, MAXDATACHARS);
832
                    // cut the stringbuffer part that already written into db
833
                    strBuffer = strBuffer.delete(start, MAXDATACHARS);
834
                } else {
835
                    data = strBuffer.substring(start, bufferSize);
836
                    moredata = false;
837
                }
801
            logMetacat.debug("DBSAXHandler.writeTextForDBSAXNode - Write text into DB");
838 802

  
839 803
                // Write the content of the node to the database
840
                nodeId = node.writeChildNodeToDB("TEXT", null, data, docid);
841
            }//while
804
                nodeId = node.writeChildNodeToDB("TEXT", null, new String(strBuffer), docid);
842 805
        }//if
843 806
        return nodeId;
844 807
    }
src/edu/ucsb/nceas/metacat/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
src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java
431 431
					}
432 432
					
433 433
					if (revList.size() > 0) {
434
						throw (new SAXException("Doc ID " + docid + " was deleted and cannot be updated."));
434
						throw (new SAXException("EML210SaxHandler.startElement - Doc ID " + docid + " was deleted and cannot be updated."));
435 435
					} else {
436
						throw (new SAXException("Doc ID " + docid + " was not found and cannot be updated.")); 
436
						throw (new SAXException("EML210SaxHandler.startElement - Doc ID " + docid + " was not found and cannot be updated.")); 
437 437
					}
438 438
				} catch (Exception e) {
439
					throw (new SAXException("Error in EMLSaxHandler.startElement "
440
							+ action, e));
439
                    throw (new SAXException("EML210SaxHandler.startElement - error with action " + 
440
                    		action + " : " + e.getMessage()));
441 441
				}
442 442
			}
443 443

  
......
1139 1139
		logMetacat.debug("IGNORABLEWHITESPACE");
1140 1140
		if (!handleInlineData) {
1141 1141
			DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
1142
			String data = null;
1143
			int leftover = len;
1144
			int offset = start;
1145
			boolean moredata = true;
1146

  
1147
			// This loop deals with the case where there are more characters
1148
			// than can fit in a single database text field (limit is
1149
			// MAXDATACHARS). If the text to be inserted exceeds MAXDATACHARS,
1150
			// write a series of nodes that are MAXDATACHARS long, and then the
1151
			// final node contains the remainder
1152
			while (moredata) {
1153
				if (leftover > MAXDATACHARS) {
1154
					data = new String(cbuf, offset, MAXDATACHARS);
1155
					leftover -= MAXDATACHARS;
1156
					offset += MAXDATACHARS;
1157
				} else {
1158
					data = new String(cbuf, offset, leftover);
1159
					moredata = false;
1160
				}
1161

  
1142
				String data = new String(cbuf, start, len);
1162 1143
				// compare whitespace in access top module
1163 1144
				if (processTopLevelAccess && needToCheckAccessModule) {
1164 1145
					compareWhiteSpace(currentUnchangeableAccessModuleNodeStack, data,
......
1174 1155

  
1175 1156
				}
1176 1157
				endNodeId = currentNode.writeChildNodeToDB("TEXT", null, data, docid);
1177
			}
1178 1158
		} else {
1179 1159
			// This is inline data write to file directly
1180 1160
			StringBuffer inlineWhiteSpace = new StringBuffer(new String(cbuf, start, len));

Also available in: Unified diff