Revision 10140
Added by Jing Tao about 8 years ago
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java | ||
---|---|---|
457 | 457 |
//localId = im.getLocalId(pid.getValue()); |
458 | 458 |
|
459 | 459 |
} catch (IOException e) { |
460 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
460 |
removeSystemMetaAndIdentifier(pid); |
|
461 | 461 |
String msg = "The Node is unable to create the object "+pid.getValue() + |
462 | 462 |
" There was a problem converting the object to XML"; |
463 | 463 |
logMetacat.error(msg, e); |
464 | 464 |
throw new ServiceFailure("1190", msg + ": " + e.getMessage()); |
465 | 465 |
|
466 | 466 |
} catch (ServiceFailure e) { |
467 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
467 |
removeSystemMetaAndIdentifier(pid); |
|
468 | 468 |
logMetacat.error("D1NodeService.create - the node couldn't create the object "+pid.getValue()+" since "+e.getMessage(), e); |
469 | 469 |
throw e; |
470 | 470 |
} catch (Exception e) { |
471 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
471 |
removeSystemMetaAndIdentifier(pid); |
|
472 | 472 |
logMetacat.error("The node is unable to create the object: "+pid.getValue()+ " since " + e.getMessage(), e); |
473 | 473 |
throw new ServiceFailure("1190", "The node is unable to create the object: " +pid.getValue()+" since "+ e.getMessage()); |
474 | 474 |
} |
... | ... | |
479 | 479 |
try { |
480 | 480 |
localId = insertDataObject(object, pid, session); |
481 | 481 |
} catch (ServiceFailure e) { |
482 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
482 |
removeSystemMetaAndIdentifier(pid); |
|
483 | 483 |
throw e; |
484 | 484 |
} catch (Exception e) { |
485 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
485 |
removeSystemMetaAndIdentifier(pid); |
|
486 | 486 |
throw new ServiceFailure("1190", "The node is unable to create the object "+pid.getValue()+" since " + e.getMessage()); |
487 | 487 |
} |
488 | 488 |
|
... | ... | |
495 | 495 |
// setting the resulting identifier failed. We will check if the object does exist. |
496 | 496 |
try { |
497 | 497 |
if (localId == null || !IdentifierManager.getInstance().objectFileExists(localId, isScienceMetadata) ) { |
498 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
498 |
removeSystemMetaAndIdentifier(pid); |
|
499 | 499 |
throw new ServiceFailure("1190", "The Node is unable to create the object. "+pid.getValue()); |
500 | 500 |
} |
501 | 501 |
} catch (PropertyNotFoundException e) { |
502 |
removeSystemMetaAndIdentifier(pid, localId);
|
|
502 |
removeSystemMetaAndIdentifier(pid); |
|
503 | 503 |
throw new ServiceFailure("1190", "The Node is unable to create the object. "+pid.getValue() + " since "+e.getMessage()); |
504 | 504 |
} |
505 | 505 |
|
... | ... | |
524 | 524 |
/* |
525 | 525 |
* Roll-back method when inserting data object fails. |
526 | 526 |
*/ |
527 |
protected void removeSystemMetaAndIdentifier(Identifier id, String localId){
|
|
527 |
protected void removeSystemMetaAndIdentifier(Identifier id){ |
|
528 | 528 |
if(id != null) { |
529 | 529 |
logMetacat.debug("D1NodeService.removeSystemMeta - the system metadata of object "+id.getValue()+" will removed from both hazelcast and db tables since the object creation failed"); |
530 | 530 |
HazelcastService.getInstance().getSystemMetadataMap().remove(id); |
531 | 531 |
logMetacat.info("D1NodeService.removeSystemMeta - the system metadata of object "+id.getValue()+" has been removed from both hazelcast and db tables since the object creation failed"); |
532 | 532 |
try { |
533 |
if(localId != null && !localId.trim().equals("") && IdentifierManager.getInstance().mappingExists(id.getValue())) { |
|
533 |
if(IdentifierManager.getInstance().mappingExists(id.getValue())) { |
|
534 |
String localId = IdentifierManager.getInstance().getLocalId(id.getValue()); |
|
534 | 535 |
IdentifierManager.getInstance().removeMapping(id.getValue(), localId); |
535 | 536 |
logMetacat.info("D1NodeService.removeSystemMeta - the identifier "+id.getValue()+" and local id "+localId+" have been removed from the identifier table since the object creation failed"); |
536 | 537 |
} |
537 | 538 |
} catch (Exception e) { |
538 |
logMetacat.warn("D1NodeService.removeSysteMeta - can't decide if the mapping of the pid "+id.getValue()+" and local id "+localId+" exists on the identifier table.");
|
|
539 |
logMetacat.warn("D1NodeService.removeSysteMeta - can't decide if the mapping of the pid "+id.getValue()+" exists on the identifier table."); |
|
539 | 540 |
} |
540 | 541 |
} |
541 | 542 |
} |
Also available in: Unified diff
Change the condition that remove identifier from the identifier table in the method removeSystemMetaAndIdentifier.