Revision 476
Added by bojilova about 24 years ago
src/edu/ucsb/nceas/metacat/AccessionNumber.java | ||
---|---|---|
90 | 90 |
localId = getLocalId(accNumber, sep); |
91 | 91 |
} |
92 | 92 |
|
93 |
// register unique acc #
|
|
93 |
// INSERT
|
|
94 | 94 |
if ( action.equals("INSERT")) { |
95 |
if ( accNumber == null ) |
|
95 |
// get a unique Acc# |
|
96 |
if ( accNumber == null ) { |
|
96 | 97 |
return put(defaultGlobalName, null, sep); |
97 |
else |
|
98 |
// Acc# is not used; return it |
|
99 |
} else if ( !accNumberUsed(globalName, localId) ) { |
|
98 | 100 |
return put(globalName, localId, sep); |
101 |
// Acc# is used; throw an exception to prevent the insertion |
|
102 |
} else { |
|
103 |
throw |
|
104 |
new AccessionNumberException("Accession number is already in use."); |
|
105 |
} |
|
106 |
// UPDATE or DELETE |
|
99 | 107 |
} else if ( action.equals("UPDATE") || action.equals("DELETE")) { |
108 |
// Acc# is not provided; throw an exception to prevent the action |
|
100 | 109 |
if ( accNumber == null ) { |
101 | 110 |
throw (new AccessionNumberException("Accession number is " + |
102 | 111 |
"required.")); |
112 |
// Acc# is not current (not in xml_documents); throw an exception |
|
103 | 113 |
} else if (!accNumberIsCurrent(accNumber)) { |
104 | 114 |
throw (new AccessionNumberException("Document " + |
105 | 115 |
"not found for accession #: " + accNumber)); |
116 |
// Acc# is current; return it |
|
106 | 117 |
} else { |
107 |
return (globalName + sep + localId);
|
|
118 |
return accNumber;
|
|
108 | 119 |
} |
109 | 120 |
} |
110 | 121 |
|
... | ... | |
135 | 146 |
try { |
136 | 147 |
if ( localId == null ) |
137 | 148 |
l = new Integer(get(globalName) + 1); |
138 |
else if ( accNumberUsed(globalName, localId) ) |
|
139 |
l = new Integer(get(globalName) + 1); |
|
149 |
//else if ( accNumberUsed(globalName, localId) )
|
|
150 |
// l = new Integer(get(globalName) + 1);
|
|
140 | 151 |
else |
141 | 152 |
l = new Integer(localId); |
142 | 153 |
|
... | ... | |
256 | 267 |
|
257 | 268 |
/** |
258 | 269 |
* '$Log$ |
270 |
* 'Revision 1.13 2000/09/20 20:15:58 bojilova |
|
271 |
* 'change Assession# generation to use the same db connection |
|
272 |
* ' |
|
259 | 273 |
* 'Revision 1.12 2000/08/30 18:19:41 bojilova |
260 | 274 |
* 'cleared static methods in AccessionNumber classes for fixing bug found |
261 | 275 |
* 'when multiple requests to the servlet at a time. |
Also available in: Unified diff
Changed to prevent the insertion if the provided Accession# is in use as Dan suggested.