Revision 5352
Added by berkley over 14 years ago
CrudService.java | ||
---|---|---|
327 | 327 |
|
328 | 328 |
try { |
329 | 329 |
IdentifierManager im = IdentifierManager.getInstance(); |
330 |
System.out.println("looking up systemmetadata id for guid " + guid.getValue()); |
|
331 | 330 |
final String localId = im.getSystemMetadataId(guid.getValue()); |
332 |
System.out.println("localId: " + localId); |
|
333 | 331 |
|
334 | 332 |
// Read system metadata from metacat's db |
335 | 333 |
final InputStreamFromOutputStream<String> objectStream = |
... | ... | |
387 | 385 |
|
388 | 386 |
//find the old systemmetadata (sm.old) document id (the one linked to obsoletedGuid) |
389 | 387 |
SystemMetadata sm = getSystemMetadata(token, obsoletedGuid); |
390 |
System.out.println("CS: got sm for obsoleteGuid: " + obsoletedGuid.getValue()); |
|
391 | 388 |
//change sm.old's obsoletedBy field |
392 | 389 |
List l = sm.getObsoletedByList(); |
393 | 390 |
l.add(guid); |
394 | 391 |
sm.setObsoletedByList(l); |
395 |
System.out.println("CS: set obsoletedBy to id: " + ((Identifier)l.get(0)).getValue()); |
|
396 | 392 |
//update sm.old |
397 |
System.out.println("CS: updating system metadata..."); |
|
398 | 393 |
updateSystemMetadata(sm, sessionData); |
399 |
System.out.println("CS: updated system metadata."); |
|
394 |
|
|
400 | 395 |
//change the obsoletes field of the new systemMetadata (sm.new) to point to the id of the old one |
401 |
System.out.println("CS: Adding obsoleteGuid to new sysmeta"); |
|
402 | 396 |
sysmeta.addObsolete(obsoletedGuid); |
403 | 397 |
//insert sm.new |
404 |
System.out.println("CS: inserting new sysmeta"); |
|
405 | 398 |
insertSystemMetadata(sysmeta, sessionData); |
406 |
//call update with sm.new.object.id for object |
|
407 |
//System.out.println("CS: updating old sm"); |
|
408 |
//updateSystemMetadata(sm, sessionData); |
|
409 |
System.out.println("CS: updating doc"); |
|
399 |
|
|
400 |
//update the doc |
|
410 | 401 |
updateDocument(object, obsoletedGuid, guid, sessionData); |
411 |
System.out.println("CS: Done updating document."); |
|
412 | 402 |
return guid; |
413 | 403 |
} |
414 | 404 |
catch(Exception e) |
... | ... | |
584 | 574 |
String localId = insertDocument(xml, sysMetaGuid, sessionData); |
585 | 575 |
//insert the system metadata doc id into the identifiers table to |
586 | 576 |
//link it to the data or metadata document |
587 |
System.out.println("mapping systemmetadata id to docid in im.insertSystemMetadata"); |
|
588 | 577 |
IdentifierManager.getInstance().createSystemMetadataMapping(sysmeta.getIdentifier().getValue(), sysMetaGuid.getValue()); |
589 | 578 |
} |
590 | 579 |
|
... | ... | |
596 | 585 |
{ |
597 | 586 |
try |
598 | 587 |
{ |
599 |
System.out.println("Updating SystemMetadata with id " + sm.getIdentifier().getValue()); |
|
600 | 588 |
String smId = IdentifierManager.getInstance().getSystemMetadataId(sm.getIdentifier().getValue()); |
601 |
System.out.println("smId: " + smId); |
|
602 | 589 |
sm.setDateSysMetadataModified(new Date()); |
603 | 590 |
String xml = new String(serializeSystemMetadata(sm).toByteArray()); |
604 | 591 |
Identifier id = new Identifier(); |
605 | 592 |
id.setValue(smId); |
606 |
System.out.println("updating sysmeta doc with new id " + id.getValue()); |
|
607 | 593 |
String localId = updateDocument(xml, id, null, sessionData); |
608 |
System.out.println("new updated localId: " + localId); |
|
609 |
System.out.println("CS: updateDocument returned localId: " + localId); |
|
610 | 594 |
IdentifierManager.getInstance().updateSystemMetadataMapping(sm.getIdentifier().getValue(), localId); |
611 | 595 |
} |
612 | 596 |
catch(Exception e) |
... | ... | |
706 | 690 |
action[0] = insertOrUpdate; |
707 | 691 |
params.put("action", action); |
708 | 692 |
String[] docid = new String[1]; |
709 |
System.out.println(insertOrUpdate + "ing with localId " + localId); |
|
710 | 693 |
docid[0] = localId; |
711 | 694 |
params.put("docid", docid); |
712 | 695 |
String[] doctext = new String[1]; |
Also available in: Unified diff
removed system.outs