Project

General

Profile

« Previous | Next » 

Revision 9274

Added by Jing Tao almost 9 years ago

Check the obosoletedBy and Obsoletes only can be set once.

View differences:

D1NodeService.java
1651 1651
          }
1652 1652
      }
1653 1653
      checkModifiedImmutableFields(currentSysmeta, sysmeta);
1654
      checkOneTimeSettableSysmMetaFields(currentSysmeta, sysmeta);
1654 1655
      // do the actual update
1655 1656
      this.updateSystemMetadata(sysmeta);
1656 1657
      
......
1716 1717
	        
1717 1718
	    }
1718 1719
	}
1720
	
1721
	/*
1722
	 * Some fields in the system metadata, such as obsoletes or obsoletedBy can be set only once. 
1723
	 * After set, they are not allowed to be changed.
1724
	 */
1725
	private void checkOneTimeSettableSysmMetaFields(SystemMetadata orgMeta, SystemMetadata newMeta) throws InvalidRequest {
1726
	    if(orgMeta.getObsoletedBy() != null ) {
1727
	        if(newMeta.getObsoletedBy() == null || !orgMeta.getObsoletedBy().equals(newMeta.getObsoletedBy())) {
1728
	            throw new InvalidRequest("4869", "The request is trying to reset the obsoletedBy field in the SystemMeta. Once the obsoletedBy filed is set, you can't change it again.");
1729
	        }
1730
        }
1731
	    if(orgMeta.getObsoletes() != null) {
1732
	        if(newMeta.getObsoletes() == null || !orgMeta.getObsoletes().equals(newMeta.getObsoletes())) {
1733
	            throw new InvalidRequest("4869", "The request is trying to reset the obsoletes field in the SystemMeta. Once the obsoletedBy filed is set, you can't change it again.");
1734
	        }
1735
	    }
1736
	}
1719 1737
  
1720 1738
  /**
1721 1739
   * Given a Permission, returns a list of all permissions that it encompasses

Also available in: Unified diff