Revision 5441
Added by berkley almost 14 years ago
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) |
Also available in: Unified diff
added functionality to set access permissions to system metadata the same as the document that it describes