Revision 5453
Added by berkley almost 14 years ago
CrudService.java | ||
---|---|---|
399 | 399 |
if(isScienceMetadata) |
400 | 400 |
{ |
401 | 401 |
//update the doc |
402 |
updateDocument(object, obsoletedGuid, guid, sessionData); |
|
402 |
updateDocument(object, obsoletedGuid, guid, sessionData, false);
|
|
403 | 403 |
} |
404 | 404 |
else |
405 | 405 |
{ |
... | ... | |
1405 | 1405 |
Identifier sysMetaGuid = new Identifier(); |
1406 | 1406 |
sysMetaGuid.setValue(DocumentUtil.generateDocumentId(1)); |
1407 | 1407 |
sysmeta.setDateSysMetadataModified(new Date()); |
1408 |
System.out.println("****inserting new system metadata with modified date " + sysmeta.getDateSysMetadataModified()); |
|
1408 |
System.out.println("****inserting new system metadata with modified date " + |
|
1409 |
sysmeta.getDateSysMetadataModified()); |
|
1409 | 1410 |
|
1410 | 1411 |
String xml = new String(serializeSystemMetadata(sysmeta).toByteArray()); |
1411 | 1412 |
System.out.println("sysmeta: " + xml); |
1412 |
String localId = insertDocument(xml, sysMetaGuid, sessionData); |
|
1413 |
String localId = insertDocument(xml, sysMetaGuid, sessionData, true);
|
|
1413 | 1414 |
System.out.println("sysmeta inserted with localId " + localId); |
1414 |
//insert the system metadata doc id into the identifiers table to
|
|
1415 |
//insert the system metadata doc id into the systemmetadata table to
|
|
1415 | 1416 |
//link it to the data or metadata document |
1416 | 1417 |
IdentifierManager.getInstance().createSystemMetadataMapping( |
1417 | 1418 |
sysmeta.getIdentifier().getValue(), sysMetaGuid.getValue()); |
... | ... | |
1431 | 1432 |
String xml = new String(serializeSystemMetadata(sm).toByteArray()); |
1432 | 1433 |
Identifier id = new Identifier(); |
1433 | 1434 |
id.setValue(smId); |
1434 |
String localId = updateDocument(xml, id, null, sessionData); |
|
1435 |
String localId = updateDocument(xml, id, null, sessionData, true);
|
|
1435 | 1436 |
IdentifierManager.getInstance().updateSystemMetadataMapping(sm.getIdentifier().getValue(), localId); |
1436 | 1437 |
} |
1437 | 1438 |
catch(Exception e) |
... | ... | |
1440 | 1441 |
} |
1441 | 1442 |
} |
1442 | 1443 |
|
1444 |
private String insertDocument(String xml, Identifier guid, SessionData sessionData) |
|
1445 |
throws ServiceFailure |
|
1446 |
{ |
|
1447 |
return insertDocument(xml, guid, sessionData, false); |
|
1448 |
} |
|
1449 |
|
|
1443 | 1450 |
/** |
1444 | 1451 |
* insert a document |
1445 | 1452 |
* NOTE: this method shouldn't be used from the update or create() methods. |
1446 | 1453 |
* we shouldn't be putting the science metadata or data objects into memory. |
1447 | 1454 |
*/ |
1448 |
private String insertDocument(String xml, Identifier guid, SessionData sessionData) |
|
1455 |
private String insertDocument(String xml, Identifier guid, SessionData sessionData, |
|
1456 |
boolean isSystemMetadata) |
|
1449 | 1457 |
throws ServiceFailure |
1450 | 1458 |
{ |
1451 |
return insertOrUpdateDocument(xml, guid, sessionData, "insert"); |
|
1459 |
return insertOrUpdateDocument(xml, guid, sessionData, "insert", isSystemMetadata);
|
|
1452 | 1460 |
} |
1453 | 1461 |
|
1454 | 1462 |
/** |
... | ... | |
1467 | 1475 |
* NOTE: this method shouldn't be used from the update or create() methods. |
1468 | 1476 |
* we shouldn't be putting the science metadata or data objects into memory. |
1469 | 1477 |
*/ |
1470 |
private String updateDocument(String xml, Identifier obsoleteGuid, Identifier guid, SessionData sessionData) |
|
1478 |
private String updateDocument(String xml, Identifier obsoleteGuid, |
|
1479 |
Identifier guid, SessionData sessionData, boolean isSystemMetadata) |
|
1471 | 1480 |
throws ServiceFailure |
1472 | 1481 |
{ |
1473 |
return insertOrUpdateDocument(xml, obsoleteGuid, sessionData, "update"); |
|
1482 |
return insertOrUpdateDocument(xml, obsoleteGuid, sessionData, "update", isSystemMetadata);
|
|
1474 | 1483 |
} |
1475 | 1484 |
|
1476 | 1485 |
/** |
1477 | 1486 |
* update a document from a stream |
1478 | 1487 |
*/ |
1479 |
private String updateDocument(InputStream is, Identifier obsoleteGuid, Identifier guid, SessionData sessionData) |
|
1488 |
private String updateDocument(InputStream is, Identifier obsoleteGuid, |
|
1489 |
Identifier guid, SessionData sessionData, boolean isSystemMetadata) |
|
1480 | 1490 |
throws IOException, ServiceFailure |
1481 | 1491 |
{ |
1482 | 1492 |
//HACK: change this eventually. we should not be converting the stream to a string |
1483 | 1493 |
String xml = IOUtils.toString(is); |
1484 |
String localId = updateDocument(xml, obsoleteGuid, guid, sessionData); |
|
1494 |
String localId = updateDocument(xml, obsoleteGuid, guid, sessionData, isSystemMetadata);
|
|
1485 | 1495 |
IdentifierManager im = IdentifierManager.getInstance(); |
1486 | 1496 |
if(guid != null) |
1487 | 1497 |
{ |
... | ... | |
1493 | 1503 |
/** |
1494 | 1504 |
* insert a document, return the id of the document that was inserted |
1495 | 1505 |
*/ |
1496 |
protected String insertOrUpdateDocument(String xml, Identifier guid, SessionData sessionData, String insertOrUpdate) |
|
1506 |
protected String insertOrUpdateDocument(String xml, Identifier guid, |
|
1507 |
SessionData sessionData, String insertOrUpdate, boolean isSystemMetadata) |
|
1497 | 1508 |
throws ServiceFailure { |
1498 | 1509 |
logMetacat.debug("Starting to insert xml document..."); |
1499 | 1510 |
IdentifierManager im = IdentifierManager.getInstance(); |
... | ... | |
1502 | 1513 |
String localId = null; |
1503 | 1514 |
if(insertOrUpdate.equals("insert")) |
1504 | 1515 |
{ |
1505 |
localId = im.generateLocalId(guid.getValue(), 1); |
|
1516 |
localId = im.generateLocalId(guid.getValue(), 1, isSystemMetadata);
|
|
1506 | 1517 |
} |
1507 | 1518 |
else |
1508 | 1519 |
{ |
Also available in: Unified diff
still working on getting guid problems fixed with replication