Revision 955
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
63 | 63 |
private DBSAXNode rootNode; |
64 | 64 |
private String action = null; |
65 | 65 |
private String docid = null; |
66 |
private String revision = null; |
|
66 | 67 |
private String user = null; |
67 | 68 |
private String[] groups = null; |
68 | 69 |
private String pub = null; |
... | ... | |
92 | 93 |
stackCreated = true; |
93 | 94 |
} |
94 | 95 |
} |
95 |
|
|
96 |
/** Construct an instance of the handler class
|
|
96 |
|
|
97 |
/** Construct an instance of the handler class |
|
97 | 98 |
* |
98 | 99 |
* @param conn the JDBC connection to which information is written |
99 | 100 |
* @param action - "INSERT" or "UPDATE" |
... | ... | |
105 | 106 |
* resides. |
106 | 107 |
* |
107 | 108 |
*/ |
108 |
public DBSAXHandler(Connection conn, String action, String docid, |
|
109 |
String user, String[] groups, String pub, int serverCode)
|
|
109 |
public DBSAXHandler(Connection conn, String action, String docid,
|
|
110 |
String user, String[] groups, String pub, int serverCode) |
|
110 | 111 |
{ |
111 | 112 |
this(conn); |
112 | 113 |
this.action = action; |
... | ... | |
116 | 117 |
this.pub = pub; |
117 | 118 |
this.serverCode = serverCode; |
118 | 119 |
this.xmlIndex = new Thread(this); |
120 |
} |
|
121 |
|
|
122 |
/** Construct an instance of the handler class |
|
123 |
* In this constructor, user can specify the version need to upadate |
|
124 |
* |
|
125 |
* @param conn the JDBC connection to which information is written |
|
126 |
* @param action - "INSERT" or "UPDATE" |
|
127 |
* @param docid to be inserted or updated into JDBC connection |
|
128 |
* @param revision, the user specified the revision need to be update |
|
129 |
* @param user the user connected to MetaCat servlet and owns the document |
|
130 |
* @param groups the groups to which user belongs |
|
131 |
* @param pub flag for public "read" access on document |
|
132 |
* @param serverCode the serverid from xml_replication on which this document |
|
133 |
* resides. |
|
134 |
* |
|
135 |
*/ |
|
136 |
public DBSAXHandler(Connection conn, String action, String docid, |
|
137 |
String revision, String user, String[] groups, String pub, int serverCode) |
|
138 |
{ |
|
139 |
this(conn); |
|
140 |
this.action = action; |
|
141 |
this.docid = docid; |
|
142 |
this.revision = revision; |
|
143 |
this.user = user; |
|
144 |
this.groups = groups; |
|
145 |
this.pub = pub; |
|
146 |
this.serverCode = serverCode; |
|
147 |
this.xmlIndex = new Thread(this); |
|
119 | 148 |
} |
120 | 149 |
|
121 | 150 |
/** SAX Handler that receives notification of beginning of the document */ |
... | ... | |
198 | 227 |
} |
199 | 228 |
stmt.close(); |
200 | 229 |
} |
230 |
|
|
231 |
//create documentImpl object by the constructor which can specify |
|
232 |
//the revision |
|
201 | 233 |
currentDocument = new DocumentImpl(conn, rootNode.getNodeID(), |
202 |
docname, doctype, docid, action, user, |
|
234 |
docname, doctype, docid, revision, action, user,
|
|
203 | 235 |
this.pub, catalogid, this.serverCode); |
236 |
|
|
237 |
|
|
204 | 238 |
} catch (Exception ane) { |
205 | 239 |
throw (new SAXException("Error in DBSaxHandler.startElement " + |
206 | 240 |
action, ane)); |
... | ... | |
261 | 295 |
while(!inxmldoc) |
262 | 296 |
{ |
263 | 297 |
String xmlDocumentsCheck = "select distinct docid from xml_documents"; |
264 |
PreparedStatement xmlDocCheck = dbconn.prepareStatement(xmlDocumentsCheck); |
|
298 |
PreparedStatement xmlDocCheck = |
|
299 |
dbconn.prepareStatement(xmlDocumentsCheck); |
|
265 | 300 |
xmlDocCheck.execute(); |
266 | 301 |
ResultSet doccheckRS = xmlDocCheck.getResultSet(); |
267 | 302 |
boolean tableHasRows = doccheckRS.next(); |
... | ... | |
381 | 416 |
// When validation is turned "off" white spaces are not reported here, |
382 | 417 |
// but through characters() callback |
383 | 418 |
MetaCatUtil.debugMessage("IGNORABLEWHITESPACE"); |
384 |
//System.out.println("Whitespace:" + len + "x" + new String(cbuf, start, len) + "x"); |
|
419 |
|
|
385 | 420 |
|
386 | 421 |
DBSAXNode currentNode = (DBSAXNode)nodeStack.peek(); |
387 | 422 |
String data = null; |
Also available in: Unified diff
A constructor was added to this class. In this constructor, user can specify the revision number he want to update. And the number can be passed into a DocumentImpl object constructor in startElement method. But the number should be greater than current number in database.