Revision 2608
Added by Jing Tao about 19 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
794 | 794 |
//register data file into xml_documents table and wite data file |
795 | 795 |
//into file system |
796 | 796 |
DocumentImpl.writeDataFileInReplication(url.openStream(), datafilePath, |
797 |
docName, docType, docid, user,docHomeServer,server); |
|
797 |
docName, docType, docid, user,docHomeServer,server, |
|
798 |
DocumentImpl.DOCUMENTTABLE, false);//false means non-timed replication |
|
798 | 799 |
} |
799 | 800 |
|
800 | 801 |
|
src/edu/ucsb/nceas/metacat/DocumentImplWrapper.java | ||
---|---|---|
80 | 80 |
throws Exception |
81 | 81 |
{ |
82 | 82 |
//we don't need to check validation in replciation |
83 |
// so rule base is null and need validation is false |
|
83 |
// so rule base is null and need validation is false (first false) |
|
84 |
// this method is for force replication. so the table name is xml_documents |
|
85 |
// and timed replication is false (last false) |
|
84 | 86 |
return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, |
85 | 87 |
accnum, user, groups, homeServer, |
86 |
notifyServer, ruleBase, false); |
|
88 |
notifyServer, ruleBase, false, |
|
89 |
DocumentImpl.DOCUMENTTABLE, false); |
|
90 |
// last false means is not timed replication |
|
91 |
|
|
87 | 92 |
} |
93 |
|
|
94 |
/** |
|
95 |
* Constructor with tableName - this doc is in xml_documents or xml_revsions |
|
96 |
* If in xml_revisions, it need a special handler. |
|
97 |
* @param conn |
|
98 |
* @param xml |
|
99 |
* @param pub |
|
100 |
* @param dtd |
|
101 |
* @param action |
|
102 |
* @param accnum |
|
103 |
* @param user |
|
104 |
* @param groups |
|
105 |
* @param homeServer |
|
106 |
* @param notifyServer |
|
107 |
* @param tableName |
|
108 |
* @return |
|
109 |
* @throws Exception |
|
110 |
*/ |
|
111 |
public String writeReplication(DBConnection conn, Reader xml, |
|
112 |
String pub, Reader dtd, String action, |
|
113 |
String accnum, String user, |
|
114 |
String[] groups,String homeServer, |
|
115 |
String notifyServer, String tableName, boolean timedReplication) |
|
116 |
throws Exception |
|
117 |
{ |
|
118 |
//we don't need to check validation in replciation |
|
119 |
// so rule base is null and need validation is false |
|
120 |
return DocumentImpl.writeReplication(conn, xml, pub, dtd, action, |
|
121 |
accnum, user, groups, homeServer, |
|
122 |
notifyServer, ruleBase, false, tableName, timedReplication); |
|
123 |
} |
|
88 | 124 |
}//DocumentImple |
src/edu/ucsb/nceas/metacat/ReplicationHandler.java | ||
---|---|---|
62 | 62 |
//PrintWriter out; |
63 | 63 |
private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter; |
64 | 64 |
|
65 |
|
|
66 |
|
|
65 | 67 |
public ReplicationHandler() |
66 | 68 |
{ |
67 | 69 |
//this.out = o; |
... | ... | |
129 | 131 |
String update; |
130 | 132 |
ReplMessageHandler message = new ReplMessageHandler(); |
131 | 133 |
Vector responses = new Vector(); |
132 |
boolean flag=false; // If a document need to update |
|
133 |
boolean dataFile=false; |
|
134 |
String action = new String(); |
|
135 | 134 |
XMLReader parser; |
136 | 135 |
URL u; |
137 | 136 |
|
... | ... | |
230 | 229 |
MetaCatUtil.debugMessage("Update vector size: "+ updateList.size(), 40); |
231 | 230 |
MetaCatUtil.debugMessage("Delete vector size: "+ deleteList.size(),40); |
232 | 231 |
// go though every element in updated document vector |
233 |
for(int j=0; j<updateList.size(); j++) |
|
234 |
{ |
|
235 |
//initial dataFile is false |
|
236 |
dataFile=false; |
|
237 |
//w is information for one document, information contain |
|
238 |
//docid, rev, server or datafile. |
|
239 |
Vector w = new Vector((Vector)(updateList.elementAt(j))); |
|
240 |
//Check if the vector w contain "datafile" |
|
241 |
//If it has, this document is data file |
|
242 |
if (w.contains((String)util.getOption("datafileflag"))) |
|
243 |
{ |
|
244 |
dataFile=true; |
|
245 |
} |
|
246 |
//System.out.println("w: " + w.toString()); |
|
247 |
// Get docid |
|
248 |
String docid = (String)w.elementAt(0); |
|
249 |
MetaCatUtil.debugMessage("docid: " + docid, 40); |
|
250 |
// Get revision number |
|
251 |
int rev = Integer.parseInt((String)w.elementAt(1)); |
|
252 |
MetaCatUtil.debugMessage("rev: " + rev, 40); |
|
253 |
// Get remote server name (it is may not be doc homeserver because |
|
254 |
// the new hub feature |
|
255 |
String remoteServer = (String)w.elementAt(2); |
|
256 |
remoteServer = remoteServer.trim(); |
|
257 |
|
|
258 |
|
|
259 |
// compare the update rev and local rev to see what need happen |
|
260 |
int localrev = -1; |
|
261 |
try |
|
262 |
{ |
|
263 |
localrev = DocumentImpl.getLatestRevisionNumber(docid); |
|
264 |
} |
|
265 |
catch (SQLException e) |
|
266 |
{ |
|
267 |
MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+ |
|
268 |
" be found because " + e.getMessage(), 45); |
|
269 |
MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+ |
|
270 |
"written because error happend to find it's local revision"); |
|
271 |
continue; |
|
272 |
} |
|
273 |
MetaCatUtil.debugMessage("Local rev for docid "+ docid + " is "+ |
|
274 |
localrev, 45); |
|
275 |
|
|
276 |
//check the revs for an update because this document is in the |
|
277 |
//local DB, it might be out of date. |
|
278 |
if (localrev == -1) |
|
279 |
{ |
|
280 |
//insert this document as new because it is not in the local DB |
|
281 |
action = "INSERT"; |
|
282 |
flag = true; |
|
283 |
} |
|
284 |
else |
|
285 |
{ |
|
286 |
if(localrev == rev) |
|
287 |
{ |
|
288 |
// Local meatacat has the same rev to remote host, don't need |
|
289 |
// update and flag set false |
|
290 |
flag = false; |
|
291 |
} |
|
292 |
else if(localrev < rev) |
|
293 |
{ |
|
294 |
//this document needs to be updated so send an read request |
|
295 |
action = "UPDATE"; |
|
296 |
flag = true; |
|
297 |
} |
|
298 |
} |
|
299 |
|
|
300 |
// this is non-data file |
|
301 |
if(flag && !dataFile) |
|
302 |
{ |
|
303 |
try |
|
304 |
{ |
|
305 |
handleSingleXMLDocument(remoteServer, action, docid); |
|
306 |
} |
|
307 |
catch(Exception e) |
|
308 |
{ |
|
309 |
// skip this document |
|
310 |
continue; |
|
311 |
} |
|
312 |
}//if for non-data file |
|
313 |
|
|
314 |
// this is for data file |
|
315 |
if(flag && dataFile) |
|
316 |
{ |
|
317 |
try |
|
318 |
{ |
|
319 |
handleSingleDataFile(remoteServer, action, docid); |
|
320 |
} |
|
321 |
catch(Exception e) |
|
322 |
{ |
|
323 |
// skip this datafile |
|
324 |
continue; |
|
325 |
} |
|
326 |
|
|
327 |
}//for datafile |
|
328 |
}//for update docs |
|
329 |
|
|
232 |
handleDocList(updateList, DocumentImpl.DOCUMENTTABLE); |
|
330 | 233 |
//handle deleted docs |
331 | 234 |
for(int k=0; k<deleteList.size(); k++) |
332 | 235 |
{ //delete the deleted documents; |
... | ... | |
341 | 244 |
continue; |
342 | 245 |
} |
343 | 246 |
}//for delete docs |
247 |
|
|
248 |
// handle replicate doc in xml_revision |
|
249 |
Vector revisionList = new Vector(message.getRevisionsVect()); |
|
250 |
handleDocList(revisionList, DocumentImpl.REVISIONTABLE); |
|
344 | 251 |
}//for response |
345 | 252 |
|
346 | 253 |
//updated last_checked |
... | ... | |
362 | 269 |
|
363 | 270 |
/* Handle replicate single xml document*/ |
364 | 271 |
private void handleSingleXMLDocument(String remoteserver, String actions, |
365 |
String docId) |
|
272 |
String docId, String tableName)
|
|
366 | 273 |
throws Exception |
367 | 274 |
{ |
368 | 275 |
DBConnection dbConn = null; |
... | ... | |
438 | 345 |
(String)docinfoHash.get("user_owner"), |
439 | 346 |
null, /* null for groups[] */ |
440 | 347 |
docHomeServer, |
441 |
remoteserver);
|
|
348 |
remoteserver, tableName, true);// true is for time replication
|
|
442 | 349 |
MetaCatUtil.debugMessage("Successfully replicated doc " + accnum, 35); |
443 | 350 |
MetacatReplication.replLog("wrote doc " + accnum + " from " + |
444 | 351 |
remoteserver); |
... | ... | |
463 | 370 |
|
464 | 371 |
/* Handle replicate single xml document*/ |
465 | 372 |
private void handleSingleDataFile(String remoteserver, String actions, |
466 |
String docId) |
|
373 |
String docId, String tableName)
|
|
467 | 374 |
throws Exception |
468 | 375 |
{ |
469 | 376 |
MetaCatUtil.debugMessage("Try to replicate data file: "+docId, 40); |
... | ... | |
515 | 422 |
if ( input != null) |
516 | 423 |
{ |
517 | 424 |
DocumentImpl.writeDataFileInReplication(input, |
518 |
datafilePath, |
|
519 |
docName,docType, |
|
520 |
accnum, user, |
|
521 |
docHomeServer, |
|
522 |
remoteserver); |
|
425 |
datafilePath, |
|
426 |
docName,docType, |
|
427 |
accnum, user, |
|
428 |
docHomeServer, |
|
429 |
remoteserver, |
|
430 |
tableName, |
|
431 |
true);//true means timed replication |
|
523 | 432 |
MetaCatUtil.debugMessage("Successfully to write datafile " + docId, 30); |
524 | 433 |
MetacatReplication.replLog("wrote datafile " + accnum + " from " + |
525 | 434 |
remoteserver); |
... | ... | |
1001 | 910 |
System.out.println("Time is " + s); |
1002 | 911 |
return s; |
1003 | 912 |
} |
913 |
|
|
914 |
|
|
915 |
/* |
|
916 |
* This method will go through the docid list both in xml_Documents table |
|
917 |
* and in xml_revisions table |
|
918 |
* @author tao |
|
919 |
*/ |
|
920 |
private void handleDocList(Vector docList, String tableName) |
|
921 |
{ |
|
922 |
boolean dataFile=false; |
|
923 |
for(int j=0; j<docList.size(); j++) |
|
924 |
{ |
|
925 |
//initial dataFile is false |
|
926 |
dataFile=false; |
|
927 |
//w is information for one document, information contain |
|
928 |
//docid, rev, server or datafile. |
|
929 |
Vector w = new Vector((Vector)(docList.elementAt(j))); |
|
930 |
//Check if the vector w contain "datafile" |
|
931 |
//If it has, this document is data file |
|
932 |
if (w.contains((String)util.getOption("datafileflag"))) |
|
933 |
{ |
|
934 |
dataFile=true; |
|
935 |
} |
|
936 |
//System.out.println("w: " + w.toString()); |
|
937 |
// Get docid |
|
938 |
String docid = (String)w.elementAt(0); |
|
939 |
MetaCatUtil.debugMessage("docid: " + docid, 40); |
|
940 |
// Get revision number |
|
941 |
int rev = Integer.parseInt((String)w.elementAt(1)); |
|
942 |
MetaCatUtil.debugMessage("rev: " + rev, 40); |
|
943 |
// Get remote server name (it is may not be doc homeserver because |
|
944 |
// the new hub feature |
|
945 |
String remoteServer = (String)w.elementAt(2); |
|
946 |
remoteServer = remoteServer.trim(); |
|
947 |
|
|
948 |
try |
|
949 |
{ |
|
950 |
if (tableName.equals(DocumentImpl.DOCUMENTTABLE)) |
|
951 |
{ |
|
952 |
handleDocInXMLDocuments(docid, rev, remoteServer, dataFile); |
|
953 |
} |
|
954 |
else if (tableName.equals(DocumentImpl.REVISIONTABLE)) |
|
955 |
{ |
|
956 |
handleDocInXMLRevisions(docid, rev, remoteServer, dataFile); |
|
957 |
} |
|
958 |
else |
|
959 |
{ |
|
960 |
continue; |
|
961 |
} |
|
962 |
|
|
963 |
} |
|
964 |
catch (Exception e) |
|
965 |
{ |
|
966 |
MetaCatUtil.debugMessage("error to handle update doc in "+ |
|
967 |
tableName +" in time replication"+e.getMessage(), 30); |
|
968 |
continue; |
|
969 |
} |
|
970 |
|
|
971 |
}//for update docs |
|
972 |
|
|
973 |
} |
|
974 |
|
|
975 |
/* |
|
976 |
* This method will handle doc in xml_documents table. |
|
977 |
*/ |
|
978 |
private void handleDocInXMLDocuments(String docid, int rev, String remoteServer, boolean dataFile) |
|
979 |
throws Exception |
|
980 |
{ |
|
981 |
// compare the update rev and local rev to see what need happen |
|
982 |
int localrev = -1; |
|
983 |
String action = null; |
|
984 |
boolean flag = false; |
|
985 |
try |
|
986 |
{ |
|
987 |
localrev = DocumentImpl.getLatestRevisionNumber(docid); |
|
988 |
} |
|
989 |
catch (SQLException e) |
|
990 |
{ |
|
991 |
MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+ |
|
992 |
" be found because " + e.getMessage(), 45); |
|
993 |
MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+ |
|
994 |
"written because error happend to find it's local revision"); |
|
995 |
throw new Exception (e.getMessage()); |
|
996 |
} |
|
997 |
MetaCatUtil.debugMessage("Local rev for docid "+ docid + " is "+ |
|
998 |
localrev, 45); |
|
999 |
|
|
1000 |
//check the revs for an update because this document is in the |
|
1001 |
//local DB, it might be out of date. |
|
1002 |
if (localrev == -1) |
|
1003 |
{ |
|
1004 |
//insert this document as new because it is not in the local DB |
|
1005 |
action = "INSERT"; |
|
1006 |
flag = true; |
|
1007 |
} |
|
1008 |
else |
|
1009 |
{ |
|
1010 |
if(localrev == rev) |
|
1011 |
{ |
|
1012 |
// Local meatacat has the same rev to remote host, don't need |
|
1013 |
// update and flag set false |
|
1014 |
flag = false; |
|
1015 |
} |
|
1016 |
else if(localrev < rev) |
|
1017 |
{ |
|
1018 |
//this document needs to be updated so send an read request |
|
1019 |
action = "UPDATE"; |
|
1020 |
flag = true; |
|
1021 |
} |
|
1022 |
} |
|
1023 |
|
|
1024 |
// this is non-data file |
|
1025 |
if(flag && !dataFile) |
|
1026 |
{ |
|
1027 |
try |
|
1028 |
{ |
|
1029 |
handleSingleXMLDocument(remoteServer, action, docid, DocumentImpl.DOCUMENTTABLE); |
|
1030 |
} |
|
1031 |
catch(Exception e) |
|
1032 |
{ |
|
1033 |
// skip this document |
|
1034 |
throw e; |
|
1035 |
} |
|
1036 |
}//if for non-data file |
|
1037 |
|
|
1038 |
// this is for data file |
|
1039 |
if(flag && dataFile) |
|
1040 |
{ |
|
1041 |
try |
|
1042 |
{ |
|
1043 |
handleSingleDataFile(remoteServer, action, docid, DocumentImpl.DOCUMENTTABLE); |
|
1044 |
} |
|
1045 |
catch(Exception e) |
|
1046 |
{ |
|
1047 |
// skip this datafile |
|
1048 |
throw e; |
|
1049 |
} |
|
1050 |
|
|
1051 |
}//for datafile |
|
1052 |
} |
|
1053 |
|
|
1054 |
/* |
|
1055 |
* This method will handle doc in xml_documents table. |
|
1056 |
*/ |
|
1057 |
private void handleDocInXMLRevisions(String docid, int rev, String remoteServer, boolean dataFile) |
|
1058 |
throws Exception |
|
1059 |
{ |
|
1060 |
// compare the update rev and local rev to see what need happen |
|
1061 |
Vector localrev = null; |
|
1062 |
String action = "INSERT"; |
|
1063 |
boolean flag = false; |
|
1064 |
try |
|
1065 |
{ |
|
1066 |
localrev = DBUtil.getRevListFromRevisionTable(docid); |
|
1067 |
} |
|
1068 |
catch (SQLException e) |
|
1069 |
{ |
|
1070 |
MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+ |
|
1071 |
" be found because " + e.getMessage(), 45); |
|
1072 |
MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+ |
|
1073 |
"written because error happend to find it's local revision"); |
|
1074 |
throw new Exception (e.getMessage()); |
|
1075 |
} |
|
1076 |
MetaCatUtil.debugMessage("rev list in xml_revision table for docid "+ docid + " is "+ |
|
1077 |
localrev.toString(), 45); |
|
1078 |
|
|
1079 |
// if the rev is not in the xml_revision, we need insert it |
|
1080 |
if (!localrev.contains(new Integer(rev))) |
|
1081 |
{ |
|
1082 |
flag = true; |
|
1083 |
} |
|
1084 |
|
|
1085 |
// this is non-data file |
|
1086 |
if(flag && !dataFile) |
|
1087 |
{ |
|
1088 |
try |
|
1089 |
{ |
|
1090 |
handleSingleXMLDocument(remoteServer, action, docid, DocumentImpl.REVISIONTABLE); |
|
1091 |
} |
|
1092 |
catch(Exception e) |
|
1093 |
{ |
|
1094 |
// skip this document |
|
1095 |
throw e; |
|
1096 |
} |
|
1097 |
}//if for non-data file |
|
1098 |
|
|
1099 |
// this is for data file |
|
1100 |
if(flag && dataFile) |
|
1101 |
{ |
|
1102 |
try |
|
1103 |
{ |
|
1104 |
handleSingleDataFile(remoteServer, action, docid, DocumentImpl.REVISIONTABLE); |
|
1105 |
} |
|
1106 |
catch(Exception e) |
|
1107 |
{ |
|
1108 |
// skip this datafile |
|
1109 |
throw e; |
|
1110 |
} |
|
1111 |
|
|
1112 |
}//for datafile |
|
1113 |
} |
|
1114 |
|
|
1004 | 1115 |
} |
1005 | 1116 |
|
src/edu/ucsb/nceas/metacat/ReplMessageHandler.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
package edu.ucsb.nceas.metacat; |
30 | 30 |
|
31 |
import java.sql.*; |
|
32 |
import java.util.Stack; |
|
31 |
|
|
33 | 32 |
import java.util.Vector; |
34 |
import java.util.Enumeration; |
|
35 |
import java.util.EmptyStackException; |
|
36 | 33 |
|
37 | 34 |
import org.xml.sax.Attributes; |
38 | 35 |
import org.xml.sax.SAXException; |
39 |
import org.xml.sax.SAXParseException; |
|
40 |
import org.xml.sax.ext.DeclHandler; |
|
41 |
import org.xml.sax.ext.LexicalHandler; |
|
42 | 36 |
import org.xml.sax.helpers.DefaultHandler; |
43 | 37 |
|
44 | 38 |
/** |
... | ... | |
50 | 44 |
private Vector updates = new Vector(); |
51 | 45 |
private Vector indivUpdate = new Vector(); |
52 | 46 |
private Vector indivDelete = new Vector(); |
47 |
private Vector indivRevision = new Vector(); |
|
53 | 48 |
private Vector deletes = new Vector(); |
49 |
private Vector revisions = new Vector(); |
|
54 | 50 |
private String server; |
55 | 51 |
private String dataFile; |
56 | 52 |
private boolean update = false; |
57 | 53 |
private boolean delete = false; |
54 |
private boolean revision = false; |
|
58 | 55 |
String currentTag = new String(); |
59 | 56 |
StringBuffer textBuffer = null; |
60 | 57 |
|
... | ... | |
80 | 77 |
indivDelete = new Vector(); |
81 | 78 |
delete = true; |
82 | 79 |
} |
80 |
else if (localName.equals("revisionDocument")) |
|
81 |
{ |
|
82 |
indivRevision = new Vector(); |
|
83 |
revision = true; |
|
84 |
} |
|
85 |
|
|
83 | 86 |
} |
84 | 87 |
|
85 | 88 |
/** |
... | ... | |
88 | 91 |
public void endElement(String uri, String localName, String qName) |
89 | 92 |
throws SAXException |
90 | 93 |
{ |
91 |
if(currentTag.equals("docid") && update)
|
|
94 |
if(currentTag.equals("docid") && update) |
|
92 | 95 |
{ |
93 | 96 |
indivUpdate.add(textBuffer.toString()); |
94 | 97 |
} |
... | ... | |
96 | 99 |
{ |
97 | 100 |
indivDelete.add(textBuffer.toString()); |
98 | 101 |
} |
102 |
else if (currentTag.equals("docid") && revision) |
|
103 |
{ |
|
104 |
indivRevision.add(textBuffer.toString()); |
|
105 |
} |
|
99 | 106 |
|
100 | 107 |
if(currentTag.equals("rev") && update) |
101 | 108 |
{ |
... | ... | |
107 | 114 |
indivDelete.add(textBuffer.toString()); |
108 | 115 |
indivDelete.add(server); |
109 | 116 |
} |
117 |
else if(currentTag.equals("rev") && revision) |
|
118 |
{ |
|
119 |
indivRevision.add(textBuffer.toString()); |
|
120 |
indivRevision.add(server); |
|
121 |
} |
|
110 | 122 |
|
111 | 123 |
if(currentTag.equals("date_updated") && update) |
112 | 124 |
{ |
... | ... | |
118 | 130 |
indivDelete.add(textBuffer.toString()); |
119 | 131 |
indivDelete.add(server); |
120 | 132 |
} |
133 |
else if(currentTag.equals("date_updated") && revision) |
|
134 |
{ |
|
135 |
indivRevision.add(textBuffer.toString()); |
|
136 |
indivRevision.add(server); |
|
137 |
} |
|
121 | 138 |
|
122 | 139 |
if(currentTag.equals("server")) |
123 | 140 |
{ |
... | ... | |
128 | 145 |
if (currentTag.equals("datafile")) |
129 | 146 |
{ |
130 | 147 |
dataFile = textBuffer.toString(); |
131 |
indivUpdate.add(dataFile); |
|
148 |
if (update) |
|
149 |
{ |
|
150 |
indivUpdate.add(dataFile); |
|
151 |
} |
|
152 |
else if (revision) |
|
153 |
{ |
|
154 |
indivRevision.add(dataFile); |
|
155 |
} |
|
156 |
|
|
157 |
|
|
132 | 158 |
} |
133 | 159 |
|
134 | 160 |
if(localName.equals("updatedDocument")) |
... | ... | |
141 | 167 |
deletes.add(new Vector(indivDelete)); |
142 | 168 |
delete = false; |
143 | 169 |
} |
170 |
else if (localName.equals("revisionDocument")) |
|
171 |
{ |
|
172 |
revisions.add(new Vector(indivRevision)); |
|
173 |
revision = false; |
|
174 |
} |
|
144 | 175 |
} |
145 | 176 |
|
146 | 177 |
/** |
... | ... | |
160 | 191 |
{ |
161 | 192 |
return deletes; |
162 | 193 |
} |
194 |
|
|
195 |
public Vector getRevisionsVect() |
|
196 |
{ |
|
197 |
return revisions; |
|
198 |
} |
|
163 | 199 |
} |
src/edu/ucsb/nceas/metacat/Eml200SAXHandler.java | ||
---|---|---|
681 | 681 |
MetaCatUtil.debugMessage("DOCTYPE-b: " + doctype, 30); |
682 | 682 |
} |
683 | 683 |
rootNode.writeNodename(docname); |
684 |
System.out.println("here!!!!!!!!!!!!!!!!!!1"); |
|
684 | 685 |
try { |
685 | 686 |
// for validated XML Documents store a reference to XML DB |
686 | 687 |
// Catalog |
... | ... | |
710 | 711 |
catalogid = rs.getString(1); |
711 | 712 |
} |
712 | 713 |
stmt.close(); |
714 |
System.out.println("here!!!!!!!!!!!!!!!!!!2"); |
|
713 | 715 |
}//try |
714 | 716 |
finally { |
715 | 717 |
// Return dbconnection |
... | ... | |
720 | 722 |
//create documentImpl object by the constructor which can |
721 | 723 |
// specify |
722 | 724 |
//the revision |
723 |
currentDocument = new DocumentImpl(connection, rootNode |
|
725 |
if (!super.getIsRevisionDoc()) |
|
726 |
{ |
|
727 |
|
|
728 |
currentDocument = new DocumentImpl(connection, rootNode |
|
724 | 729 |
.getNodeID(), docname, doctype, docid, revision, |
725 | 730 |
action, user, this.pub, catalogid, this.serverCode); |
731 |
} |
|
732 |
else |
|
733 |
{ |
|
734 |
|
|
735 |
currentDocument = new DeletedDocumentImpl(connection, rootNode |
|
736 |
.getNodeID(), docname, doctype, docid, revision, |
|
737 |
action, user, this.pub, catalogid, this.serverCode); |
|
738 |
} |
|
726 | 739 |
|
727 | 740 |
} catch (Exception ane) { |
728 | 741 |
throw (new SAXException( |
729 | 742 |
"Error in EMLSaxHandler.startElement " + action, |
730 | 743 |
ane)); |
731 | 744 |
} |
745 |
|
|
732 | 746 |
} |
733 | 747 |
//================================================================== |
734 | 748 |
|
... | ... | |
1666 | 1680 |
throw new SAXException("user deleted some inline block it couldn't"); |
1667 | 1681 |
} |
1668 | 1682 |
|
1669 |
// write access rule to xml_access table which include both top level |
|
1670 |
// and additional level(data access level). It also write access subtree |
|
1671 |
// info into xml_accesssubtree about the top access, additional access |
|
1672 |
// and some third place access modules which are referenced by top |
|
1673 |
// level or additional level |
|
1674 |
writeAccessRuleToDB(); |
|
1683 |
if (!super.getIsRevisionDoc()) |
|
1684 |
{ |
|
1685 |
// write access rule to xml_access table which include both top level |
|
1686 |
// and additional level(data access level). It also write access subtree |
|
1687 |
// info into xml_accesssubtree about the top access, additional access |
|
1688 |
// and some third place access modules which are referenced by top |
|
1689 |
// level or additional level |
|
1690 |
writeAccessRuleToDB(); |
|
1675 | 1691 |
|
1676 |
//delete relation table |
|
1677 |
deleteRelations(); |
|
1678 |
//write relations |
|
1679 |
for (int i = 0; i < onlineDataFileIdInRelationVector.size(); i++) { |
|
1692 |
//delete relation table
|
|
1693 |
deleteRelations();
|
|
1694 |
//write relations
|
|
1695 |
for (int i = 0; i < onlineDataFileIdInRelationVector.size(); i++) {
|
|
1680 | 1696 |
String id = (String) onlineDataFileIdInRelationVector.elementAt(i); |
1681 | 1697 |
writeOnlineDataFileIdIntoRelationTable(id); |
1698 |
} |
|
1682 | 1699 |
} |
1683 | 1700 |
|
1684 | 1701 |
// clean the subtree record |
... | ... | |
2295 | 2312 |
pstmt.setString(1, docid); |
2296 | 2313 |
MetaCatUtil.debugMessage("Docid in access-subtreetable: " + docid, |
2297 | 2314 |
35); |
2298 |
pstmt.setString(2, revision);
|
|
2315 |
pstmt.setInt(2, (new Integer(revision)).intValue());
|
|
2299 | 2316 |
MetaCatUtil.debugMessage("rev in accesssubtreetable: " + revision, |
2300 | 2317 |
35); |
2301 | 2318 |
pstmt.setString(3, level); |
src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java | ||
---|---|---|
449 | 449 |
//create documentImpl object by the constructor which can |
450 | 450 |
// specify |
451 | 451 |
//the revision |
452 |
currentDocument = new DocumentImpl(connection, rootNode |
|
452 |
if (!super.getIsRevisionDoc()) |
|
453 |
{ |
|
454 |
currentDocument = new DocumentImpl(connection, rootNode |
|
453 | 455 |
.getNodeID(), docname, doctype, docid, revision, |
454 | 456 |
action, user, this.pub, catalogid, this.serverCode); |
457 |
} |
|
458 |
else |
|
459 |
{ |
|
460 |
currentDocument = new DeletedDocumentImpl(connection, rootNode |
|
461 |
.getNodeID(), docname, doctype, docid, revision, |
|
462 |
action, user, this.pub, catalogid, this.serverCode); |
|
463 |
} |
|
455 | 464 |
|
456 | 465 |
} catch (Exception ane) { |
457 | 466 |
throw (new SAXException( |
... | ... | |
1409 | 1418 |
40); |
1410 | 1419 |
throw new SAXException(PERMISSIONERROR); |
1411 | 1420 |
} |
1412 |
|
|
1413 |
// write access rule to db |
|
1414 |
writeAccessRuleToDB(); |
|
1415 |
|
|
1416 |
//delete relation table |
|
1417 |
deleteRelations(); |
|
1418 |
//write relations |
|
1419 |
for (int i = 0; i < onlineDataFileIdInRelationVector.size(); i++) { |
|
1420 |
String id = (String) onlineDataFileIdInRelationVector.elementAt(i); |
|
1421 |
writeOnlineDataFileIdIntoRelationTable(id); |
|
1421 |
if (!super.getIsRevisionDoc()) |
|
1422 |
{ |
|
1423 |
// write access rule to db |
|
1424 |
writeAccessRuleToDB(); |
|
1425 |
//delete relation table |
|
1426 |
deleteRelations(); |
|
1427 |
//write relations |
|
1428 |
for (int i = 0; i < onlineDataFileIdInRelationVector.size(); i++) { |
|
1429 |
String id = (String) onlineDataFileIdInRelationVector.elementAt(i); |
|
1430 |
writeOnlineDataFileIdIntoRelationTable(id); |
|
1431 |
} |
|
1422 | 1432 |
} |
1433 |
|
|
1423 | 1434 |
|
1424 | 1435 |
} |
1425 | 1436 |
|
Also available in: Unified diff
Add code to handle deleted document replication.