Revision 5322
Added by berkley almost 14 years ago
IdentifierManager.java | ||
---|---|---|
232 | 232 |
|
233 | 233 |
return localId; |
234 | 234 |
} |
235 |
|
|
236 |
/** |
|
237 |
* given a local identifer, look up the guid. Throw McdbDocNotFoundException |
|
238 |
* if the docid, rev is not found in the identifiers table |
|
239 |
* |
|
240 |
* @param docid the docid to look up |
|
241 |
* @param rev the revision of the docid to look up |
|
242 |
* @return String containing the mapped guid |
|
243 |
* @throws McdbDocNotFoundException if the docid, rev is not found |
|
244 |
*/ |
|
245 |
public String getGUID(String docid, int rev) |
|
246 |
throws McdbDocNotFoundException |
|
247 |
{ |
|
248 |
String query = "select guid from identifier where docid = ? and rev = ?"; |
|
249 |
String guid = null; |
|
250 |
|
|
251 |
DBConnection dbConn = null; |
|
252 |
int serialNumber = -1; |
|
253 |
try { |
|
254 |
// Get a database connection from the pool |
|
255 |
dbConn = DBConnectionPool.getDBConnection("Identifier.getGUID"); |
|
256 |
serialNumber = dbConn.getCheckOutSerialNumber(); |
|
257 |
|
|
258 |
// Execute the insert statement |
|
259 |
PreparedStatement stmt = dbConn.prepareStatement(query); |
|
260 |
stmt.setString(1, docid); |
|
261 |
stmt.setInt(2, rev); |
|
262 |
ResultSet rs = stmt.executeQuery(); |
|
263 |
if (rs.next()) { |
|
264 |
guid = rs.getString(1); |
|
265 |
|
|
266 |
} else { |
|
267 |
throw new McdbDocNotFoundException("Document not found:" + guid); |
|
268 |
} |
|
269 |
stmt.close(); |
|
270 |
} catch (SQLException e) { |
|
271 |
logMetacat.error("Error while looking up the guid: " |
|
272 |
+ e.getMessage()); |
|
273 |
} finally { |
|
274 |
// Return database connection to the pool |
|
275 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
|
276 |
} |
|
277 |
|
|
278 |
return guid; |
|
279 |
} |
|
235 | 280 |
} |
Also available in: Unified diff
added a method in IdentifierManager to get a guid from a docid and rev. added fields in the documentinfo replication document to pass the guid. now need to handle the guid and insert it into the table if its found