Project

General

Profile

« Previous | Next » 

Revision 220

Added by Matt Jones over 24 years ago

Fixed bug where TEXT nodes couldn't be longer than 4000 characters, which
is the maximum length of a VARCHAR2 field in Oracle. Now, if text
exceeds the field length, I break the text up into a series of TEXT
nodes each of the max field length, and the remainder in the last
TEXT node. The only problem with this is that our current search
algorithms only will find phrases within a single TEXT nodes, so if
the search term spans the node boundary, the search algorithm will not
return a hit. I expect this is extremely rare, basically inconsequential.

View differences:

src/edu/ucsb/nceas/metacat/DBSAXHandler.java
43 43
   private String       action = null;
44 44
   private String       docid = null;
45 45

  
46
   private static final int MAXDATACHARS = 4000;
47

  
46 48
   /** Construct an instance of the handler class 
47 49
    *
48 50
    * @param conn the JDBC connection to which information is written
......
153 155
   public void characters(char[] cbuf, int start, int len) {
154 156
     MetaCatUtil.debugMessage("CHARACTERS");
155 157
     DBSAXNode currentNode = (DBSAXNode)nodeStack.peek();
156
     String data = new String(cbuf, start, len);
158
     String data = null;
159
     int leftover = len;
160
     int offset = start;
161
     boolean moredata = true;
162
    
163
     // This loop deals with the case where there are more characters 
164
     // than can fit in a single database text field (limit is 
165
     // MAXDATACHARS).  If the text to be inserted exceeds MAXDATACHARS,
166
     // write a series of nodes that are MAXDATACHARS long, and then the
167
     // final node contains the remainder
168
     while (moredata) {
169
       if (leftover > MAXDATACHARS) {
170
         data = new String(cbuf, offset, MAXDATACHARS);
171
         leftover -= MAXDATACHARS;
172
         offset += MAXDATACHARS;
173
       } else {
174
         data = new String(cbuf, offset, leftover);
175
         moredata = false;
176
       }
157 177

  
158
     // Write the content of the node to the database
159
     currentNode.writeChildNodeToDB("TEXT", null, data);
178
       // Write the content of the node to the database
179
       currentNode.writeChildNodeToDB("TEXT", null, data);
180
     }
160 181
   }
161 182

  
162 183
   /** 
......
329 350

  
330 351
/**
331 352
 * '$Log$
353
 * 'Revision 1.29  2000/06/27 04:31:07  jones
354
 * 'Fixed bugs associated with the new UPDATE and DELETE functions of
355
 * 'DBWriter.  There were problematic interactions between some static
356
 * 'variables used in DBEntityResolver and the way in which the
357
 * 'Servlet objects are re-used across multiple client invocations.
358
 * '
359
 * 'Generally cleaned up error reporting.  Now all errors and success
360
 * 'results are reported as XML documents from MetaCatServlet.  Need
361
 * 'to make the command line tools do the same.
362
 * '
332 363
 * 'Revision 1.28  2000/06/26 10:35:05  jones
333 364
 * 'Merged in substantial changes to DBWriter and associated classes and to
334 365
 * 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE

Also available in: Unified diff