Revision 1035
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
787 | 787 |
* <!ELEMENT server (#PCDATA)> |
788 | 788 |
* <!ELEMENT updates ((updatedDocument | deleteDocument)*)> |
789 | 789 |
* <!ELEMENT updatedDocument (docid, rev, datafile*)> |
790 |
* <!ELEMENT deletedDocument (docid, rev, datafile*)>
|
|
790 |
* <!ELEMENT deletedDocument (docid, rev)> |
|
791 | 791 |
* <!ELEMENT docid (#PCDATA)> |
792 | 792 |
* <!ELEMENT rev (#PCDATA)> |
793 | 793 |
* <!ELEMENT datafile (#PCDATA)> |
... | ... | |
826 | 826 |
pstmt.execute(); |
827 | 827 |
ResultSet rs = pstmt.getResultSet(); |
828 | 828 |
boolean tablehasrows = rs.next(); |
829 |
//If metacat configed not to replicate data file
|
|
830 |
if (!(util.getOption("replicationdata")).equals("on"))
|
|
829 |
//If metacat configed to replicate data file |
|
830 |
if ((util.getOption("replicationdata")).equals("on")) |
|
831 | 831 |
{ |
832 | 832 |
while(tablehasrows) |
833 | 833 |
{ |
834 | 834 |
String recordDoctype = rs.getString(3); |
835 |
Vector packagedoctypes = MetaCatUtil.getOptionList( |
|
836 |
MetaCatUtil.getOption("packagedoctype")); |
|
837 |
if(!packagedoctypes.contains(recordDoctype)) |
|
838 |
{ //if this is a package file, put it at the end |
|
839 |
//because if a package file is read before all of the files it |
|
840 |
//refers to are loaded then there is an error |
|
841 |
if (!recordDoctype.equals("BIN")) |
|
842 |
{ |
|
843 |
//for non-data file document |
|
844 |
doclist.append("<updatedDocument>"); |
|
845 |
doclist.append("<docid>").append(rs.getString(1)); |
|
846 |
doclist.append("</docid><rev>").append(rs.getInt(2)); |
|
847 |
doclist.append("</rev>"); |
|
848 |
doclist.append("</updatedDocument>"); |
|
849 |
} |
|
850 |
else |
|
851 |
{ |
|
852 |
//for data file document, in datafile attributes |
|
853 |
//we put "datafile" value there |
|
854 |
doclist.append("<updatedDocument>"); |
|
855 |
doclist.append("<docid>").append(rs.getString(1)); |
|
856 |
doclist.append("</docid><rev>").append(rs.getInt(2)); |
|
857 |
doclist.append("</rev>"); |
|
858 |
doclist.append("<datafile>"); |
|
859 |
doclist.append(MetaCatUtil.getOption("datafileflag")); |
|
860 |
doclist.append("</datafile>"); |
|
861 |
doclist.append("</updatedDocument>"); |
|
862 |
} |
|
863 |
} |
|
864 |
else |
|
865 |
{ //the package files are saved to be put into the xml later. |
|
866 |
Vector v = new Vector(); |
|
867 |
v.add(new String(rs.getString(1))); |
|
868 |
v.add(new Integer(rs.getInt(2))); |
|
869 |
packageFiles.add(new Vector(v)); |
|
870 |
} |
|
871 |
tablehasrows = rs.next(); |
|
872 |
}//while |
|
873 |
}//if |
|
874 |
else //metacat was configured not to send data file |
|
875 |
{ |
|
876 |
while(tablehasrows) |
|
877 |
{ |
|
878 |
String recordDoctype = rs.getString(3); |
|
835 | 879 |
if(!recordDoctype.equals("BIN")) |
836 | 880 |
{ //don't replicate data files |
837 | 881 |
Vector packagedoctypes = MetaCatUtil.getOptionList( |
... | ... | |
856 | 900 |
}//if |
857 | 901 |
tablehasrows = rs.next(); |
858 | 902 |
}//while |
859 |
}//if |
|
860 |
else //metacat should send data file too |
|
861 |
{ |
|
862 |
|
|
863 |
} |
|
903 |
}//else |
|
864 | 904 |
|
865 | 905 |
pstmt = conn.prepareStatement(delsql.toString()); |
866 | 906 |
pstmt.execute(); |
Also available in: Unified diff
Add a new attribute in updated doc list: data file. So from this attribute, we can tell which document is a data file.