Revision 4449
Added by ben leinfelder about 16 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
678 | 678 |
serialNumber=dbConn.getCheckOutSerialNumber(); |
679 | 679 |
// write the document to local database |
680 | 680 |
DocumentImplWrapper wrapper = new DocumentImplWrapper(parserBase, false); |
681 |
wrapper.writeReplication(dbConn, new StringReader(xmldoc), null, null, |
|
682 |
dbaction, docid, user, null, homeServer, |
|
683 |
server, createdDate, updatedDate); |
|
681 |
//try this independently so we can set |
|
682 |
Exception writeException = null; |
|
683 |
try { |
|
684 |
wrapper.writeReplication(dbConn, new StringReader(xmldoc), null, null, |
|
685 |
dbaction, docid, user, null, homeServer, |
|
686 |
server, createdDate, updatedDate); |
|
687 |
} |
|
688 |
catch (Exception e) { |
|
689 |
writeException = e; |
|
690 |
} |
|
684 | 691 |
|
685 |
//process extra access rules |
|
692 |
//process extra access rules before dealing with the write exception (doc exist already)
|
|
686 | 693 |
Vector accessControlList = (Vector) docinfoHash.get("accessControl"); |
687 | 694 |
if (accessControlList != null) { |
688 | 695 |
for (int i = 0; i < accessControlList.size(); i++) { |
689 | 696 |
AccessControlForSingleFile acfsf = (AccessControlForSingleFile) accessControlList.get(i); |
690 | 697 |
acfsf.insertPermissions(); |
698 |
MetacatReplication.replLog("document " + docid + " permissions added to DB"); |
|
691 | 699 |
} |
692 | 700 |
} |
693 | 701 |
|
702 |
if (writeException != null) { |
|
703 |
throw writeException; |
|
704 |
} |
|
705 |
|
|
694 | 706 |
MetacatReplication.replLog("document " + docid + " added to DB with " + |
695 | 707 |
"action " + dbaction); |
696 | 708 |
EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction); |
... | ... | |
836 | 848 |
+MetaCatUtil.getLocalReplicationServerName() |
837 | 849 |
+"&action=readdata&docid=" + docid); |
838 | 850 |
String datafilePath = PropertyService.getProperty("application.datafilepath"); |
851 |
|
|
852 |
Exception writeException = null; |
|
839 | 853 |
//register data file into xml_documents table and wite data file |
840 | 854 |
//into file system |
841 |
DocumentImpl.writeDataFileInReplication(url.openStream(), datafilePath, |
|
855 |
try { |
|
856 |
DocumentImpl.writeDataFileInReplication(url.openStream(), datafilePath, |
|
842 | 857 |
docName, docType, docid, user,docHomeServer,server, |
843 | 858 |
DocumentImpl.DOCUMENTTABLE, false, createdDate, updatedDate); |
859 |
} |
|
860 |
catch (Exception e) { |
|
861 |
writeException = e; |
|
862 |
} |
|
844 | 863 |
//process extra access rules |
845 | 864 |
Vector accessControlList = (Vector) docinfoHash.get("accessControl"); |
846 | 865 |
if (accessControlList != null) { |
847 | 866 |
for (int i = 0; i < accessControlList.size(); i++) { |
848 | 867 |
AccessControlForSingleFile acfsf = (AccessControlForSingleFile) accessControlList.get(i); |
849 | 868 |
acfsf.insertPermissions(); |
869 |
MetacatReplication.replLog("datafile " + docid + " permissions added to DB"); |
|
850 | 870 |
} |
851 | 871 |
} |
852 | 872 |
|
853 |
//false means non-timed replication |
|
873 |
if (writeException != null) { |
|
874 |
throw writeException; |
|
875 |
} |
|
876 |
|
|
877 |
//false means non-timed replication |
|
854 | 878 |
MetacatReplication.replLog("datafile " + docid + " added to DB with " + |
855 | 879 |
"action " + dbaction); |
856 | 880 |
EventLog.getInstance().log(request.getRemoteAddr(), REPLICATIONUSER, docid, dbaction); |
857 | 881 |
} |
858 |
|
|
859 |
|
|
860 |
|
|
861 | 882 |
|
862 | 883 |
} |
863 | 884 |
catch(Exception e) |
Also available in: Unified diff
in cases when only access control is being modified, we can temporarily ignore the exception thrown my the write method, insert the updated access control rules, then deal with the write exception. this occurs when the docid remains the same (no revision increase) but the permissions have been altered.