Revision 5322
Added by berkley over 14 years ago
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
1014 | 1014 |
// TODO MCD, this should read from disk as well? |
1015 | 1015 |
//*** This is a metadata doc, to be returned in a skin/custom format. |
1016 | 1016 |
//*** Add param to indicate if public has read access or not. |
1017 |
logMetacat.debug("User: \n" + user); |
|
1017 | 1018 |
if (!user.equals("public")) { |
1018 | 1019 |
if (DocumentImpl.hasReadPermission("public", null, docid)) |
1019 | 1020 |
params.put("publicRead", new String[] {"true"}); |
src/edu/ucsb/nceas/metacat/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 |
} |
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java | ||
---|---|---|
54 | 54 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
55 | 55 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
56 | 56 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
57 |
import edu.ucsb.nceas.metacat.IdentifierManager; |
|
58 |
import edu.ucsb.nceas.metacat.McdbDocNotFoundException; |
|
57 | 59 |
import edu.ucsb.nceas.utilities.FileUtil; |
58 | 60 |
import edu.ucsb.nceas.utilities.GeneralPropertyException; |
59 | 61 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
... | ... | |
526 | 528 |
String user = (String) docinfoHash.get("user_owner"); |
527 | 529 |
// Get home server of this docid |
528 | 530 |
String homeServer = (String) docinfoHash.get("home_server"); |
531 |
String guid = (String) docinfoHash.get("guid"); |
|
532 |
logReplication.debug("GUID: " + guid); |
|
529 | 533 |
String createdDate = (String) docinfoHash.get("date_created"); |
530 | 534 |
String updatedDate = (String) docinfoHash.get("date_updated"); |
531 | 535 |
logReplication.info("ReplicationService.handleForceReplicateRequest - homeServer: " + homeServer); |
... | ... | |
871 | 875 |
StringBuffer sb = new StringBuffer(); |
872 | 876 |
|
873 | 877 |
try { |
878 |
IdentifierManager idman = IdentifierManager.getInstance(); |
|
874 | 879 |
|
875 | 880 |
DocumentImpl doc = new DocumentImpl(docid); |
876 | 881 |
sb.append("<documentinfo><docid>").append(docid); |
877 |
sb.append("</docid><docname>").append(doc.getDocname()); |
|
882 |
sb.append("</docid>"); |
|
883 |
try |
|
884 |
{ |
|
885 |
sb.append("<guid>").append(idman.getGUID(doc.getDocID(), doc.getRev())).append("</guid>"); |
|
886 |
} |
|
887 |
catch(McdbDocNotFoundException e) |
|
888 |
{ |
|
889 |
//do nothing, there was no guid for this document |
|
890 |
} |
|
891 |
sb.append("<docname>").append(doc.getDocname()); |
|
878 | 892 |
sb.append("</docname><doctype>").append(doc.getDoctype()); |
879 | 893 |
sb.append("</doctype>"); |
880 | 894 |
sb.append("<user_owner>").append(doc.getUserowner()); |
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