Revision 779
Added by bojilova about 23 years ago
DocumentImpl.java | ||
---|---|---|
831 | 831 |
boolean validate) |
832 | 832 |
throws Exception |
833 | 833 |
{ |
834 |
int rev = 1; |
|
835 |
String docid = null; |
|
836 |
MetaCatUtil util = new MetaCatUtil(); |
|
837 |
String sep = util.getOption("accNumSeparator"); |
|
838 |
|
|
834 |
// int rev = 1;
|
|
835 |
// String docid = null;
|
|
836 |
// MetaCatUtil util = new MetaCatUtil();
|
|
837 |
// String sep = util.getOption("accNumSeparator");
|
|
838 |
/* |
|
839 | 839 |
if ( accnum != null ) { |
840 | 840 |
// check the correctness of accnum; |
841 | 841 |
// split accnum in docid and rev in order to |
... | ... | |
846 | 846 |
rev = (new Integer(id.getRev())).intValue(); |
847 | 847 |
sep = id.getSeparator(); |
848 | 848 |
} |
849 |
|
|
849 |
*/ |
|
850 |
// OLD |
|
850 | 851 |
// Determine if the docid,rev are OK for INSERT or UPDATE |
851 | 852 |
// Generate new docid on INSERT, if one is not provided. |
852 |
AccessionNumber ac = new AccessionNumber(conn); |
|
853 |
docid = ac.generate(docid, java.lang.String.valueOf(rev), action); |
|
853 |
//AccessionNumber ac = new AccessionNumber(conn);
|
|
854 |
//docid = ac.generate(docid, java.lang.String.valueOf(rev), action);
|
|
854 | 855 |
|
856 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
|
857 |
AccessionNumber ac = new AccessionNumber(conn, accnum, action); |
|
858 |
String docid = ac.getDocid(); |
|
859 |
String rev = ac.getRev(); |
|
860 |
|
|
855 | 861 |
MetaCatUtil.debugMessage("action: " + action + " servercode: " + |
856 | 862 |
serverCode + " override: " + override); |
857 | 863 |
|
... | ... | |
863 | 869 |
//merge the differences manually. |
864 | 870 |
int istreamInt; |
865 | 871 |
char istreamChar; |
866 |
// NOT NEEDED |
|
867 |
//DocumentImpl newdoc = new DocumentImpl(conn, docid); |
|
868 |
//updaterev = newdoc.getRev(); |
|
869 |
//String updaterev = rev; |
|
872 |
DocumentIdentifier id = new DocumentIdentifier(accnum); |
|
873 |
String updaterev = id.getRev(); |
|
870 | 874 |
String server = MetacatReplication.getServer(serverCode); |
871 | 875 |
MetacatReplication.replLog("attempting to lock " + accnum); |
872 | 876 |
URL u = new URL("http://" + server + "?action=getlock&updaterev=" + |
873 |
rev + "&docid=" + docid); |
|
877 |
updaterev + "&docid=" + docid);
|
|
874 | 878 |
System.out.println("sending message: " + u.toString()); |
875 | 879 |
String serverResStr = MetacatReplication.getURLContent(u); |
876 | 880 |
String openingtag = serverResStr.substring(0, serverResStr.indexOf(">")+1); |
... | ... | |
899 | 903 |
//to come get a copy from here. |
900 | 904 |
ForceReplicationHandler frh = new ForceReplicationHandler(docid); |
901 | 905 |
|
902 |
rev++; |
|
903 |
return (docid + sep + rev); |
|
906 |
// OLD |
|
907 |
//rev++; |
|
908 |
//return (docid + sep + rev); |
|
909 |
return (accnum); |
|
904 | 910 |
} |
905 | 911 |
|
906 | 912 |
else if(openingtag.equals("<filelocked>")) |
... | ... | |
934 | 940 |
throw new Exception("User " + user + |
935 | 941 |
" does not have permission to update XML Document #" + accnum); |
936 | 942 |
} |
937 |
rev++; |
|
943 |
//rev++;
|
|
938 | 944 |
} |
939 | 945 |
|
940 | 946 |
try |
... | ... | |
959 | 965 |
ForceReplicationHandler frh = new ForceReplicationHandler(docid, action); |
960 | 966 |
} |
961 | 967 |
|
962 |
return (docid + sep + rev); |
|
968 |
//return (docid + sep + rev); |
|
969 |
return(accnum); |
|
963 | 970 |
} |
964 | 971 |
|
965 | 972 |
/** |
... | ... | |
972 | 979 |
String user, String group ) |
973 | 980 |
throws Exception |
974 | 981 |
{ |
975 |
DocumentIdentifier id = new DocumentIdentifier(accnum); |
|
976 |
String docid = id.getIdentifier(); |
|
977 |
String rev = id.getRev(); |
|
982 |
// OLD |
|
983 |
//DocumentIdentifier id = new DocumentIdentifier(accnum); |
|
984 |
//String docid = id.getIdentifier(); |
|
985 |
//String rev = id.getRev(); |
|
978 | 986 |
|
987 |
// OLD |
|
979 | 988 |
// Determine if the docid,rev are OK for DELETE |
980 |
AccessionNumber ac = new AccessionNumber(conn); |
|
981 |
docid = ac.generate(docid, rev, "DELETE"); |
|
989 |
//AccessionNumber ac = new AccessionNumber(conn);
|
|
990 |
//docid = ac.generate(docid, rev, "DELETE");
|
|
982 | 991 |
|
992 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
|
993 |
AccessionNumber ac = new AccessionNumber(conn, accnum, "DELETE"); |
|
994 |
String docid = ac.getDocid(); |
|
995 |
String rev = ac.getRev(); |
|
996 |
|
|
997 |
|
|
983 | 998 |
// check for 'write' permission for 'user' to delete this document |
984 | 999 |
if ( !hasPermission(conn, user, group, docid) ) { |
985 | 1000 |
throw new Exception("User " + user + |
Also available in: Unified diff
changes according to bug# 234 - metacat accession # handling, done