50 |
50 |
public class DBSAXHandler extends DefaultHandler
|
51 |
51 |
implements LexicalHandler, DeclHandler, Runnable {
|
52 |
52 |
|
53 |
|
private boolean atFirstElement;
|
|
53 |
protected boolean atFirstElement;
|
54 |
54 |
private boolean processingDTD;
|
55 |
|
private String docname = null;
|
56 |
|
private String doctype;
|
57 |
|
private String systemid;
|
|
55 |
protected String docname = null;
|
|
56 |
protected String doctype;
|
|
57 |
protected String systemid;
|
58 |
58 |
private boolean stackCreated = false;
|
59 |
|
private Stack nodeStack;
|
60 |
|
private Vector nodeIndex;
|
61 |
|
private DBConnection connection = null;
|
62 |
|
private DocumentImpl currentDocument;
|
63 |
|
private DBSAXNode rootNode;
|
64 |
|
private String action = null;
|
65 |
|
private String docid = null;
|
66 |
|
private String revision = null;
|
67 |
|
private String user = null;
|
68 |
|
private String[] groups = null;
|
69 |
|
private String pub = null;
|
70 |
|
private Thread xmlIndex;
|
|
59 |
protected Stack nodeStack;
|
|
60 |
protected Vector nodeIndex;
|
|
61 |
protected DBConnection connection = null;
|
|
62 |
protected DocumentImpl currentDocument;
|
|
63 |
protected DBSAXNode rootNode;
|
|
64 |
protected String action = null;
|
|
65 |
protected String docid = null;
|
|
66 |
protected String revision = null;
|
|
67 |
protected String user = null;
|
|
68 |
protected String[] groups = null;
|
|
69 |
protected String pub = null;
|
|
70 |
protected Thread xmlIndex;
|
71 |
71 |
private boolean endDocument = false;
|
72 |
|
private int serverCode = 1;
|
73 |
|
private Hashtable namespaces = new Hashtable();
|
|
72 |
protected int serverCode = 1;
|
|
73 |
protected Hashtable namespaces = new Hashtable();
|
74 |
74 |
|
75 |
75 |
private static final int MAXDATACHARS = 4000;
|
|
76 |
protected static final long INDEXDELAY = 10000;
|
76 |
77 |
// DOCTITLE attr cleared from the db
|
77 |
78 |
// private static final int MAXTITLELEN = 1000;
|
78 |
79 |
|
... | ... | |
301 |
302 |
namespaces = new Hashtable();
|
302 |
303 |
|
303 |
304 |
// Add all of the attributes
|
304 |
|
for (int i=0; i<atts.getLength(); i++) {
|
305 |
|
currentNode.setAttribute(atts.getQName(i), atts.getValue(i), docid);
|
|
305 |
for (int i=0; i<atts.getLength(); i++)
|
|
306 |
{
|
|
307 |
String attributeName = atts.getQName(i);
|
|
308 |
String attributeValue = atts.getValue(i);
|
|
309 |
currentNode.setAttribute(attributeName, attributeValue, docid);
|
|
310 |
|
|
311 |
// To handle name space and schema location if the attribute name is
|
|
312 |
// xsi:schemaLocation. If the name space is in not in catalog table
|
|
313 |
// it will be regeistered.
|
|
314 |
if (attributeName != null &&
|
|
315 |
attributeName.indexOf(MetaCatServlet.SCHEMALOCATIONKEYWORD) != -1)
|
|
316 |
{
|
|
317 |
SchemaLocationResolver resolver =
|
|
318 |
new SchemaLocationResolver(attributeValue);
|
|
319 |
resolver.resolveNameSpace();
|
|
320 |
|
|
321 |
}
|
306 |
322 |
}
|
307 |
323 |
|
308 |
324 |
// Add the node to the stack, so that any text data can be
|
... | ... | |
336 |
352 |
//key relationship between xml_documents and xml_index is temporarily
|
337 |
353 |
//broken causing multiple problems.
|
338 |
354 |
boolean inxmldoc = false;
|
|
355 |
long startTime = System.currentTimeMillis();
|
339 |
356 |
while(!inxmldoc)
|
340 |
357 |
{
|
341 |
358 |
String xmlDocumentsCheck = "select distinct docid from xml_documents";
|
... | ... | |
361 |
378 |
inxmldoc = true;
|
362 |
379 |
}
|
363 |
380 |
}
|
|
381 |
doccheckRS.close();
|
364 |
382 |
xmlDocCheck.close();
|
|
383 |
// make sure the while loop will be ended in reseaonable time
|
|
384 |
long stopTime = System.currentTimeMillis();
|
|
385 |
if ((stopTime - startTime) > INDEXDELAY)
|
|
386 |
{
|
|
387 |
throw new Exception("Couldn't find the docid for index build in" +
|
|
388 |
"reseaonable time!");
|
|
389 |
}
|
365 |
390 |
}
|
366 |
391 |
|
367 |
392 |
// Going through the elements of the document and writing its Index
|
... | ... | |
393 |
418 |
|
394 |
419 |
}
|
395 |
420 |
|
396 |
|
// if it is an access file
|
397 |
|
else if ( MetaCatUtil.getOptionList(
|
398 |
|
MetaCatUtil.getOption("accessdoctype")).contains(doctype) )
|
399 |
|
{
|
400 |
|
// write ACL for the package
|
401 |
|
//runAccessControlList(dbConn, docid);
|
|
421 |
|
402 |
422 |
|
403 |
|
}
|
404 |
|
|
405 |
|
|
406 |
|
//dbconn.close();
|
407 |
|
|
408 |
423 |
} catch (Exception e) {
|
409 |
424 |
try {
|
410 |
425 |
dbConn.rollback();
|
411 |
426 |
//dbconn.close();
|
412 |
427 |
} catch (SQLException sqle) {}
|
413 |
|
System.out.println("Error in DBSAXHandler.run " + e.getMessage());
|
414 |
|
e.printStackTrace();
|
|
428 |
MetaCatUtil.debugMessage("Error in DBSAXHandler.run " +
|
|
429 |
e.getMessage(), 30);
|
|
430 |
|
415 |
431 |
}
|
416 |
432 |
finally
|
417 |
433 |
{
|
Add code to call SchemaLocationResolver.