Revision 826
Added by bojilova over 23 years ago
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
158 | 158 |
String qName, Attributes atts) |
159 | 159 |
throws SAXException { |
160 | 160 |
MetaCatUtil.debugMessage("Start ELEMENT " + qName); |
161 |
System.out.println("Start ELEMENT " + uri); |
|
162 |
System.out.println("Start ELEMENT " + qName); |
|
163 |
System.out.println("Start ELEMENT " + localName); |
|
161 | 164 |
|
162 | 165 |
DBSAXNode parentNode = null; |
163 | 166 |
DBSAXNode currentNode = null; |
... | ... | |
208 | 211 |
} |
209 | 212 |
|
210 | 213 |
// Create the current node representation |
211 |
currentNode = new DBSAXNode(conn, qName, parentNode, |
|
214 |
currentNode = new DBSAXNode(conn, qName, localName, parentNode,
|
|
212 | 215 |
currentDocument.getRootNodeID(),docid, |
213 | 216 |
currentDocument.getDoctype()); |
214 | 217 |
|
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
431 | 431 |
out.print(">"); |
432 | 432 |
previousNodeWasElement = false; |
433 | 433 |
} |
434 |
out.print("</" + currentElement.nodename + ">" ); |
|
434 |
if ( currentElement.nodeprefix != null ) { |
|
435 |
out.print("</" + currentElement.nodeprefix + ":" + |
|
436 |
currentElement.nodename + ">" ); |
|
437 |
} else { |
|
438 |
out.print("</" + currentElement.nodename + ">" ); |
|
439 |
} |
|
435 | 440 |
currentElement = (NodeRecord)openElements.peek(); |
436 | 441 |
} |
437 | 442 |
} |
... | ... | |
462 | 467 |
openElements.push(currentNode); |
463 | 468 |
util.debugMessage("\n PUSHED: " + currentNode.nodename); |
464 | 469 |
previousNodeWasElement = true; |
465 |
out.print("<" + currentNode.nodename); |
|
470 |
if ( currentNode.nodeprefix != null ) { |
|
471 |
out.print("<" + currentNode.nodeprefix + ":" + currentNode.nodename); |
|
472 |
} else { |
|
473 |
out.print("<" + currentNode.nodename); |
|
474 |
} |
|
466 | 475 |
|
467 | 476 |
// Handle the ATTRIBUTE nodes |
468 | 477 |
} else if (currentNode.nodetype.equals("ATTRIBUTE")) { |
469 |
out.print(" " + currentNode.nodename + "=\"" |
|
470 |
+ currentNode.nodedata + "\""); |
|
478 |
if ( currentNode.nodeprefix != null ) { |
|
479 |
out.print(" " + currentNode.nodeprefix + ":" + currentNode.nodename + |
|
480 |
"=\"" + currentNode.nodedata + "\""); |
|
481 |
} else { |
|
482 |
out.print(" " + currentNode.nodename + "=\"" + |
|
483 |
currentNode.nodedata + "\""); |
|
484 |
} |
|
471 | 485 |
|
472 | 486 |
// Handle the NAMESPACE nodes |
473 | 487 |
} else if (currentNode.nodetype.equals("NAMESPACE")) { |
... | ... | |
512 | 526 |
{ |
513 | 527 |
NodeRecord currentElement = (NodeRecord)openElements.pop(); |
514 | 528 |
util.debugMessage("\n POPPED: " + currentElement.nodename); |
515 |
out.print("</" + currentElement.nodename + ">" ); |
|
529 |
if ( currentElement.nodeprefix != null ) { |
|
530 |
out.print("</" + currentElement.nodeprefix + ":" + |
|
531 |
currentElement.nodename + ">" ); |
|
532 |
} else { |
|
533 |
out.print("</" + currentElement.nodename + ">" ); |
|
534 |
} |
|
516 | 535 |
} |
517 | 536 |
out.flush(); |
518 | 537 |
} |
... | ... | |
671 | 690 |
long nodeindex = 0; |
672 | 691 |
String nodetype = null; |
673 | 692 |
String nodename = null; |
693 |
String nodeprefix = null; |
|
674 | 694 |
String nodedata = null; |
675 | 695 |
|
676 | 696 |
try { |
677 | 697 |
pstmt = |
678 | 698 |
conn.prepareStatement("SELECT nodeid,parentnodeid,nodeindex, " + |
679 |
"nodetype,nodename,"+ |
|
699 |
"nodetype,nodename,nodeprefix,"+
|
|
680 | 700 |
"replace(" + |
681 | 701 |
"replace(" + |
682 | 702 |
"replace(nodedata,'&','&') " + |
... | ... | |
696 | 716 |
nodeindex = rs.getLong(3); |
697 | 717 |
nodetype = rs.getString(4); |
698 | 718 |
nodename = rs.getString(5); |
699 |
nodedata = rs.getString(6); |
|
719 |
nodeprefix = rs.getString(6); |
|
720 |
nodedata = rs.getString(7); |
|
700 | 721 |
|
701 | 722 |
// add the data to the node record list hashtable |
702 |
NodeRecord currentRecord = new NodeRecord(nodeid, parentnodeid,
|
|
703 |
nodeindex, nodetype, nodename, nodedata);
|
|
723 |
NodeRecord currentRecord = new NodeRecord(nodeid,parentnodeid,nodeindex,
|
|
724 |
nodetype, nodename, nodeprefix, nodedata);
|
|
704 | 725 |
nodeRecordList.add(currentRecord); |
705 | 726 |
|
706 | 727 |
// Advance to the next node |
... | ... | |
709 | 730 |
pstmt.close(); |
710 | 731 |
|
711 | 732 |
} catch (SQLException e) { |
712 |
throw new McdbException("Error accessing database connection from " +
|
|
713 |
"DocumentImpl.getNodeRecordList ", e);
|
|
733 |
throw new McdbException("Error in DocumentImpl.getNodeRecordList " +
|
|
734 |
e.getMessage());
|
|
714 | 735 |
} |
715 | 736 |
|
716 | 737 |
if (nodeRecordList != null) { |
... | ... | |
1055 | 1076 |
//force replicate out the new document to each server in our server list. |
1056 | 1077 |
if(serverCode == 1) |
1057 | 1078 |
{ //start the thread to replicate this new document out to the other servers |
1058 |
ForceReplicationHandler frh = new ForceReplicationHandler(docid, action); |
|
1079 |
// ForceReplicationHandler frh = new ForceReplicationHandler(docid, action);
|
|
1059 | 1080 |
} |
1060 | 1081 |
|
1061 | 1082 |
//return (docid + sep + rev); |
src/edu/ucsb/nceas/metacat/DBSAXNode.java | ||
---|---|---|
67 | 67 |
* @param tagname the name of the node |
68 | 68 |
* @param parentNode the parent node for this node being created |
69 | 69 |
*/ |
70 |
public DBSAXNode (Connection conn, String tagname, DBSAXNode parentNode, |
|
71 |
long rootnodeid, String docid, String doctype) |
|
72 |
throws SAXException { |
|
70 |
public DBSAXNode (Connection conn, String qName, String lName, |
|
71 |
DBSAXNode parentNode, long rootnodeid, |
|
72 |
String docid, String doctype) |
|
73 |
throws SAXException { |
|
73 | 74 |
|
74 |
super(tagname);
|
|
75 |
super(lName);
|
|
75 | 76 |
this.conn = conn; |
76 | 77 |
this.parentNode = parentNode; |
77 | 78 |
setParentID(parentNode.getNodeID()); |
78 | 79 |
setRootNodeID(rootnodeid); |
79 | 80 |
setDocID(docid); |
80 | 81 |
setNodeIndex(parentNode.incChildNum()); |
81 |
writeChildNodeToDB("ELEMENT", getTagName(), null, docid);
|
|
82 |
writeChildNodeToDB("ELEMENT", qName, null, docid);
|
|
82 | 83 |
//No writing XML Index from here. New Thread used instead. |
83 | 84 |
//updateNodeIndex(docid, doctype); |
84 | 85 |
} |
... | ... | |
92 | 93 |
if (nodetype == "DOCUMENT") { |
93 | 94 |
pstmt = conn.prepareStatement( |
94 | 95 |
"INSERT INTO xml_nodes " + |
95 |
"(nodetype, nodename, docid) " + |
|
96 |
"VALUES (?, ?, ?)"); |
|
96 |
"(nodetype, nodename, nodeprefix, docid) " +
|
|
97 |
"VALUES (?, ?, ?, ?)");
|
|
97 | 98 |
MetaCatUtil.debugMessage("INSERTING DOCNAME: " + nodename); |
98 | 99 |
} else { |
99 | 100 |
pstmt = conn.prepareStatement( |
100 | 101 |
"INSERT INTO xml_nodes " + |
101 |
"(nodetype, nodename, docid, " + |
|
102 |
"(nodetype, nodename, nodeprefix, docid, " +
|
|
102 | 103 |
"rootnodeid, parentnodeid, nodedata, nodeindex) " + |
103 |
"VALUES (?, ?, ?, ?, ?, ?, ?)"); |
|
104 |
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
|
104 | 105 |
} |
105 | 106 |
|
106 | 107 |
// Bind the values to the query |
107 | 108 |
pstmt.setString(1, nodetype); |
108 |
pstmt.setString(2, nodename); |
|
109 |
pstmt.setString(3, docid); |
|
109 |
int idx; |
|
110 |
if ( nodename != null && (idx = nodename.indexOf(":")) != -1 ) { |
|
111 |
pstmt.setString(2, nodename.substring(idx+1)); |
|
112 |
pstmt.setString(3, nodename.substring(0,idx)); |
|
113 |
} else { |
|
114 |
pstmt.setString(2, nodename); |
|
115 |
pstmt.setString(3, null); |
|
116 |
} |
|
117 |
pstmt.setString(4, docid); |
|
110 | 118 |
if (nodetype == "DOCUMENT") { |
111 | 119 |
// moved it to separate method updateRootNodeID |
112 | 120 |
//pstmt.setLong(4, nid); |
113 | 121 |
} else { |
114 | 122 |
if (nodetype == "ELEMENT") { |
115 |
pstmt.setLong(4, getRootNodeID());
|
|
116 |
pstmt.setLong(5, getParentID());
|
|
117 |
pstmt.setString(6, data);
|
|
118 |
pstmt.setInt(7, getNodeIndex());
|
|
123 |
pstmt.setLong(5, getRootNodeID());
|
|
124 |
pstmt.setLong(6, getParentID());
|
|
125 |
pstmt.setString(7, data);
|
|
126 |
pstmt.setInt(8, getNodeIndex());
|
|
119 | 127 |
} else { |
120 |
pstmt.setLong(4, getRootNodeID());
|
|
121 |
pstmt.setLong(5, getNodeID());
|
|
122 |
pstmt.setString(6, data);
|
|
123 |
pstmt.setInt(7, incChildNum());
|
|
128 |
pstmt.setLong(5, getRootNodeID());
|
|
129 |
pstmt.setLong(6, getNodeID());
|
|
130 |
pstmt.setString(7, data);
|
|
131 |
pstmt.setInt(8, incChildNum());
|
|
124 | 132 |
} |
125 | 133 |
} |
126 | 134 |
// Do the insertion |
src/edu/ucsb/nceas/metacat/NodeRecord.java | ||
---|---|---|
35 | 35 |
public long parentnodeid; |
36 | 36 |
public long nodeindex; |
37 | 37 |
public String nodename = null; |
38 |
public String nodeprefix = null; |
|
38 | 39 |
public String nodetype = null; |
39 | 40 |
public String nodedata = null; |
40 | 41 |
|
... | ... | |
42 | 43 |
* Constructor |
43 | 44 |
*/ |
44 | 45 |
public NodeRecord(long nodeid, long parentnodeid, long nodeindex, |
45 |
String nodetype, String nodename, String nodedata) { |
|
46 |
String nodetype, String nodename, String nodeprefix, |
|
47 |
String nodedata) { |
|
46 | 48 |
this.nodeid = nodeid; |
47 | 49 |
this.parentnodeid = parentnodeid; |
48 | 50 |
this.nodeindex = nodeindex; |
49 | 51 |
this.nodename = nodename; |
52 |
this.nodeprefix = nodeprefix; |
|
50 | 53 |
this.nodetype = nodetype; |
51 | 54 |
this.nodedata = nodedata; |
52 | 55 |
} |
Also available in: Unified diff
changes to store namespace prefixes separately from the local names of nodes (elements and attributes)
in xml_nodes.nodeprefix column