Project

General

Profile

« Previous | Next » 

Revision 9280

Added by Jing Tao over 9 years ago

Fixed a possible null exception in the updateSystemmetadata method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
1619 1619
              ") does not match identifier in system metadata (" +
1620 1620
              sysmeta.getIdentifier().getValue() + ").");
1621 1621
      }
1622
      //compare serial version.
1622 1623
      
1623 1624
      //check the sid
1624 1625
      SystemMetadata currentSysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
......
1652 1653
                  checkSidInModifyingSystemMetadata(sysmeta, "4956", "4868");
1653 1654
              }
1654 1655
          }
1655
      }
1656
      checkModifiedImmutableFields(currentSysmeta, sysmeta);
1657
      checkOneTimeSettableSysmMetaFields(currentSysmeta, sysmeta);
1658
      if(currentSysmeta.getObsoletes() == null && sysmeta.getObsoletes() != null) {
1659
          //we are setting a value to the obsoletes field, so we should make sure if there is not object obsoletes the value
1660
          String obsoletes = existsInObsoletes(sysmeta.getObsoletes());
1661
          if( obsoletes != null) {
1662
              throw new InvalidSystemMetadata("4956", "There is an object with id "+obsoletes +
1663
                      " already obsoletes the pid "+sysmeta.getObsoletes().getValue() +". You can't set the object "+pid.getValue()+" to obsolete the pid "+sysmeta.getObsoletes().getValue()+" again.");
1656
          checkModifiedImmutableFields(currentSysmeta, sysmeta);
1657
          checkOneTimeSettableSysmMetaFields(currentSysmeta, sysmeta);
1658
          if(currentSysmeta.getObsoletes() == null && sysmeta.getObsoletes() != null) {
1659
              //we are setting a value to the obsoletes field, so we should make sure if there is not object obsoletes the value
1660
              String obsoletes = existsInObsoletes(sysmeta.getObsoletes());
1661
              if( obsoletes != null) {
1662
                  throw new InvalidSystemMetadata("4956", "There is an object with id "+obsoletes +
1663
                          " already obsoletes the pid "+sysmeta.getObsoletes().getValue() +". You can't set the object "+pid.getValue()+" to obsolete the pid "+sysmeta.getObsoletes().getValue()+" again.");
1664
              }
1664 1665
          }
1666
          
1667
          if(currentSysmeta.getObsoletedBy() == null && sysmeta.getObsoletedBy() != null) {
1668
              //we are setting a value to the obsoletedBy field, so we should make sure that the no another object obsoletes the pid we are updating. 
1669
              String obsoletedBy = existsInObsoletedBy(sysmeta.getObsoletedBy());
1670
              if( obsoletedBy != null) {
1671
                  throw new InvalidSystemMetadata("4956", "There is an object with id "+obsoletedBy +
1672
                          " already is obsoleted by the pid "+sysmeta.getObsoletedBy().getValue() +". You can't set the pid "+pid.getValue()+" to be obsoleted by the pid "+sysmeta.getObsoletedBy().getValue()+" again.");
1673
              }
1674
          }
1665 1675
      }
1666 1676
      
1667
      if(currentSysmeta.getObsoletedBy() == null && sysmeta.getObsoletedBy() != null) {
1668
          //we are setting a value to the obsoletedBy field, so we should make sure that the no another object obsoletes the pid we are updating. 
1669
          String obsoletedBy = existsInObsoletedBy(sysmeta.getObsoletedBy());
1670
          if( obsoletedBy != null) {
1671
              throw new InvalidSystemMetadata("4956", "There is an object with id "+obsoletedBy +
1672
                      " already is obsoleted by the pid "+sysmeta.getObsoletedBy().getValue() +". You can't set the pid "+pid.getValue()+" to be obsoleted by the pid "+sysmeta.getObsoletedBy().getValue()+" again.");
1673
          }
1674
      }
1675 1677
      // do the actual update
1676 1678
      this.updateSystemMetadata(sysmeta);
1677 1679
      

Also available in: Unified diff