Project

General

Profile

« Previous | Next » 

Revision 8903

Added by Jing Tao about 10 years ago

Added the code to inform users the pid was deleted in the NotFound exception.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
930 930
        systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);        
931 931

  
932 932
        if (systemMetadata == null ) {
933
            throw new NotFound("1420", "Couldn't find an object identified by " + pid.getValue());
933
            String error ="";
934
            String localId = null;
935
            try {
936
                localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
937
              
938
             } catch (Exception e) {
939
                logMetacat.warn("Couldn't find the local id for the pid "+pid.getValue());
940
            }
941
            
942
            if(localId != null && EventLog.getInstance().isDeleted(localId)) {
943
                error = DELETEDMESSAGE;
944
            }
945
            throw new NotFound("1420", "Couldn't find an object identified by " + pid.getValue()+". "+error);
934 946
        }
935 947
        checksum = systemMetadata.getChecksum();
936 948
        
......
1399 1411
          
1400 1412
      } else {
1401 1413
          logMetacat.debug("System metadata for identifier " + pid.getValue() +
1402
          " is null.");          
1403
          throw new NotFound("4874", "Couldn't find an object identified by " + pid.getValue());
1414
          " is null.");
1415
          String error ="";
1416
          String localId = null;
1417
          try {
1418
              localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
1419
            
1420
           } catch (Exception e) {
1421
              logMetacat.warn("Couldn't find the local id for the pid "+pid.getValue());
1422
          }
1404 1423
          
1424
          if(localId != null && EventLog.getInstance().isDeleted(localId)) {
1425
              error = DELETEDMESSAGE;
1426
          }
1427
          throw new NotFound("4874", "Couldn't find an object identified by " + pid.getValue()+". "+error);
1428
          
1405 1429
      }
1406 1430

  
1407 1431
    } catch (RuntimeException e) {
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
92 92
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
93 93

  
94 94
public abstract class D1NodeService {
95
    
96
  public static final String DELETEDMESSAGE = "The object with the PID has been deleted from the node.";
95 97
  
96 98
  private static Logger logMetacat = Logger.getLogger(D1NodeService.class);
97 99

  
......
576 578
      try {
577 579
        inputStream = handler.read(localId);
578 580
      } catch (Exception e) {
581
        String error ="";
582
        if(EventLog.getInstance().isDeleted(localId)) {
583
              error=DELETEDMESSAGE;
584
        }
579 585
        throw new NotFound("1020", "The object specified by " + 
580 586
            pid.getValue() +
581 587
            "could not be returned due to error: " +
582
            e.getMessage());
588
            e.getMessage()+". "+error);
583 589
      }
584 590
    }
585 591

  
......
712 718
        
713 719
        // It wasn't in the map
714 720
        if ( systemMetadata == null ) {
715
            throw new NotFound("1420", "No record found for: " + pid.getValue());
721
            String error ="";
722
            String localId = null;
723
            try {
724
                localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
725
              
726
             } catch (Exception e) {
727
                logMetacat.warn("Couldn't find the local id for the pid "+pid.getValue());
728
            }
729
            
730
            if(localId != null && EventLog.getInstance().isDeleted(localId)) {
731
                error = DELETEDMESSAGE;
732
            }
733
            throw new NotFound("1420", "No record found for: " + pid.getValue()+". "+error);
716 734
        }
717 735
        
718 736
        return systemMetadata;
......
998 1016
        }
999 1017
        
1000 1018
        if(localId != null && EventLog.getInstance().isDeleted(localId)) {
1001
            error = error + ". The object with the PID has been deleted from the node.";
1019
            error = error + ". "+DELETEDMESSAGE;
1002 1020
        }
1003 1021
        throw new NotFound("1800", error);
1004 1022
    }

Also available in: Unified diff