Revision 5441
Added by berkley over 14 years ago
src/edu/ucsb/nceas/metacat/util/MetacatPopulator.java | ||
---|---|---|
120 | 120 |
String response = streamToString(is); |
121 | 121 |
//System.out.println("response: " + response); |
122 | 122 |
Vector<Document> docs = parseResponse(response); |
123 |
|
|
124 |
|
|
123 | 125 |
printHeader("Parsing source results"); |
124 | 126 |
D1Client d1 = new D1Client(destinationUrl + "/"); |
127 |
printHeader("Processing " + docs.size() + " results."); |
|
125 | 128 |
printHeader("logging in to the destination " + destinationUrl); |
126 | 129 |
AuthToken authtoken = d1.login(username, password); |
127 | 130 |
for(int i=0; i<docs.size(); i++) |
... | ... | |
247 | 250 |
|
248 | 251 |
//submitter |
249 | 252 |
Principal p = new Principal(); |
250 |
p.setValue(""); |
|
253 |
p.setValue("unknown");
|
|
251 | 254 |
sm.setSubmitter(p); |
252 | 255 |
sm.setRightsHolder(p); |
253 | 256 |
try |
... | ... | |
398 | 401 |
int start = doc.indexOf(field); |
399 | 402 |
int end = doc.indexOf(fieldend); |
400 | 403 |
String s = doc.substring(start + field.length(), end); |
401 |
System.out.println("field: " + fieldname + " : " + s); |
|
404 |
//System.out.println("field: " + fieldname + " : " + s);
|
|
402 | 405 |
return s; |
403 | 406 |
} |
404 | 407 |
|
src/edu/ucsb/nceas/metacat/dataone/CrudService.java | ||
---|---|---|
330 | 330 |
} |
331 | 331 |
|
332 | 332 |
// For Metadata and Data, insert the system metadata into the object store too |
333 |
insertSystemMetadata(sysmeta, sessionData); |
|
333 |
String sysMetaLocalId = insertSystemMetadata(sysmeta, sessionData); |
|
334 |
//get the document info. add any access params for the sysmeta too |
|
335 |
try |
|
336 |
{ |
|
337 |
Hashtable<String, Object> h = im.getDocumentInfo(sysMetaLocalId); |
|
338 |
Vector v = (Vector)h.get("access"); |
|
339 |
for(int i=0; i<v.size(); i++) |
|
340 |
{ |
|
341 |
Hashtable ah = (Hashtable)v.elementAt(i); |
|
342 |
String principal = (String)ah.get("principal_name"); |
|
343 |
String permission = (String)ah.get("permission"); |
|
344 |
String permissionType = (String)ah.get("permission_type"); |
|
345 |
String permissionOrder = (String)ah.get("permission_order"); |
|
346 |
this.setAccess(token, guid, principal, permission, permissionType, permissionOrder, false); |
|
347 |
} |
|
348 |
} |
|
349 |
catch(Exception e) |
|
350 |
{ |
|
351 |
logMetacat.error("Error setting permissions on System Metadata object " + |
|
352 |
" with id " + sysMetaLocalId + ": " + e.getMessage()); |
|
353 |
} |
|
354 |
|
|
355 |
|
|
334 | 356 |
logMetacat.debug("Returning from CrudService.create()"); |
335 | 357 |
EventLog.getInstance().log(metacatUrl, |
336 | 358 |
username, localId, "create"); |
... | ... | |
1324 | 1346 |
} |
1325 | 1347 |
|
1326 | 1348 |
/** |
1327 |
* insert a systemMetadata doc |
|
1349 |
* insert a systemMetadata doc, return the localId of the sysmeta
|
|
1328 | 1350 |
*/ |
1329 |
private void insertSystemMetadata(SystemMetadata sysmeta, SessionData sessionData)
|
|
1351 |
private String insertSystemMetadata(SystemMetadata sysmeta, SessionData sessionData)
|
|
1330 | 1352 |
throws ServiceFailure |
1331 | 1353 |
{ |
1332 | 1354 |
logMetacat.debug("Starting to insert SystemMetadata..."); |
... | ... | |
1345 | 1367 |
//link it to the data or metadata document |
1346 | 1368 |
IdentifierManager.getInstance().createSystemMetadataMapping( |
1347 | 1369 |
sysmeta.getIdentifier().getValue(), sysMetaGuid.getValue()); |
1370 |
return localId; |
|
1348 | 1371 |
} |
1349 | 1372 |
|
1350 | 1373 |
/** |
... | ... | |
1608 | 1631 |
throws Exception |
1609 | 1632 |
{ |
1610 | 1633 |
IdentifierManager im = IdentifierManager.getInstance(); |
1611 |
Hashtable<String, String> docInfo = im.getDocumentInfo(localId);
|
|
1634 |
Hashtable<String, Object> docInfo = im.getDocumentInfo(localId);
|
|
1612 | 1635 |
|
1613 | 1636 |
//get the document text |
1614 | 1637 |
int rev = im.getLatestRevForLocalId(localId); |
... | ... | |
1621 | 1644 |
sm.setIdentifier(identifier); |
1622 | 1645 |
|
1623 | 1646 |
//set the object format |
1624 |
String doctype = docInfo.get("doctype"); |
|
1625 |
ObjectFormat format = ObjectFormat.convert(docInfo.get("doctype")); |
|
1647 |
String doctype = (String)docInfo.get("doctype");
|
|
1648 |
ObjectFormat format = ObjectFormat.convert((String)docInfo.get("doctype"));
|
|
1626 | 1649 |
if(format == null) |
1627 | 1650 |
{ |
1628 | 1651 |
if(doctype.trim().equals("BIN")) |
... | ... | |
1650 | 1673 |
|
1651 | 1674 |
//submitter |
1652 | 1675 |
Principal p = new Principal(); |
1653 |
p.setValue(docInfo.get("user_owner")); |
|
1676 |
p.setValue((String)docInfo.get("user_owner"));
|
|
1654 | 1677 |
sm.setSubmitter(p); |
1655 | 1678 |
sm.setRightsHolder(p); |
1656 | 1679 |
try |
1657 | 1680 |
{ |
1658 |
Date dateCreated = parseMetacatDate(docInfo.get("date_created")); |
|
1681 |
Date dateCreated = parseMetacatDate((String)docInfo.get("date_created"));
|
|
1659 | 1682 |
sm.setDateUploaded(dateCreated); |
1660 |
Date dateUpdated = parseMetacatDate(docInfo.get("date_updated")); |
|
1683 |
Date dateUpdated = parseMetacatDate((String)docInfo.get("date_updated"));
|
|
1661 | 1684 |
sm.setDateSysMetadataModified(dateUpdated); |
1662 | 1685 |
} |
1663 | 1686 |
catch(Exception e) |
src/edu/ucsb/nceas/metacat/IdentifierManager.java | ||
---|---|---|
87 | 87 |
* @return |
88 | 88 |
* @throws McdbDocNotFoundException |
89 | 89 |
*/ |
90 |
public Hashtable<String, String> getDocumentInfo(String localId)
|
|
90 |
public Hashtable<String, Object> getDocumentInfo(String localId)
|
|
91 | 91 |
throws McdbDocNotFoundException |
92 | 92 |
{ |
93 |
Hashtable<String, String> h = new Hashtable<String, String>();
|
|
93 |
Hashtable<String, Object> h = new Hashtable<String, Object>();
|
|
94 | 94 |
String sql = "select docname, doctype, user_owner, user_updated, " + |
95 | 95 |
"server_location, rev, date_created, date_updated from " + |
96 | 96 |
"xml_documents where docid like '" + localId + "'"; |
... | ... | |
132 | 132 |
DBConnectionPool.returnDBConnection(dbConn, serialNumber); |
133 | 133 |
throw new McdbDocNotFoundException("Could not find document " + localId); |
134 | 134 |
} |
135 |
|
|
136 |
String sql2 = "select principal_name, permission, perm_type, perm_order from xml_acccess " + |
|
137 |
"where docid like '" + localId + "'"; |
|
138 |
PreparedStatement stmt2 = dbConn.prepareStatement(sql2); |
|
139 |
ResultSet rs2 = stmt2.executeQuery(); |
|
140 |
Vector accessVector = new Vector(); |
|
141 |
if(rs.next()) |
|
142 |
{ |
|
143 |
Hashtable accessHash = new Hashtable(); |
|
144 |
String principal_name = rs.getString(1); |
|
145 |
String permission = rs.getString(2); |
|
146 |
String permissionType = rs.getString(3); |
|
147 |
String permissionOrder = rs.getString(4); |
|
148 |
accessHash.put("principal_name", principal_name); |
|
149 |
accessHash.put("permission", permission); |
|
150 |
accessHash.put("permission_type", permissionType); |
|
151 |
accessHash.put("permission_order", permissionOrder); |
|
152 |
accessVector.add(accessHash); |
|
153 |
} |
|
154 |
h.put("access", accessVector); |
|
135 | 155 |
} |
136 | 156 |
catch (SQLException e) |
137 | 157 |
{ |
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java | ||
---|---|---|
1173 | 1173 |
//try to open a https stream to test if the request server's public key |
1174 | 1174 |
//in the key store, this is security issue |
1175 | 1175 |
String testUrl = "https://" + server + "?server=" |
1176 |
+ MetacatUtil.getLocalReplicationServerName() + "&action=test"; |
|
1177 |
System.out.println("running test: " + testUrl); |
|
1176 |
+ MetacatUtil.getLocalReplicationServerName() + "&action=test"; |
|
1178 | 1177 |
logReplication.info("Running trust test: " + testUrl); |
1179 | 1178 |
URL u = new URL(testUrl); |
1180 | 1179 |
String test = ReplicationService.getURLContent(u); |
1181 |
logReplication.info("trust test returned: " + test); |
|
1182 |
System.out.println("trust test returned: " + test); |
|
1180 |
logReplication.info("Ouput from test is '" + test + "'"); |
|
1183 | 1181 |
//couldn't pass the test |
1184 | 1182 |
if (test.indexOf("successfully") == -1) { |
1183 |
logReplication.error("Trust test failed."); |
|
1185 | 1184 |
response.setContentType("text/xml"); |
1186 | 1185 |
out.println("<error>Couldn't pass the trust test</error>"); |
1187 | 1186 |
out.close(); |
1188 | 1187 |
return; |
1189 | 1188 |
} |
1189 |
logReplication.info("Trust test succeeded."); |
|
1190 | 1190 |
|
1191 | 1191 |
// Check if local host configure to replicate xml documents to remote |
1192 | 1192 |
// server. If not send back a error message |
... | ... | |
1784 | 1784 |
* @throws java.io.IOException |
1785 | 1785 |
*/ |
1786 | 1786 |
public static String getURLContent(URL u) throws java.io.IOException { |
1787 |
logReplication.info("Getting url content from " + u.toString()); |
|
1787 | 1788 |
char istreamChar; |
1788 | 1789 |
int istreamInt; |
1789 | 1790 |
logReplication.info("ReplicationService.getURLContent - Before open the stream" + u.toString()); |
Also available in: Unified diff
added functionality to set access permissions to system metadata the same as the document that it describes