Project

General

Profile

« Previous | Next » 

Revision 9320

Added by Jing Tao about 9 years ago

Change some exceptions from the InvalidSystem to the InvalidRequest in the updateSystemMetadata method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
1639 1639
          
1640 1640
          BigInteger newVersion = sysmeta.getSerialVersion();
1641 1641
          if(newVersion == null) {
1642
              throw new InvalidSystemMetadata("4956", "The serial version can't be null in the new system metadata");
1642
              throw new InvalidRequest("4869", "The serial version can't be null in the new system metadata");
1643 1643
          }
1644 1644
          BigInteger currentVersion = currentSysmeta.getSerialVersion();
1645 1645
          if(currentVersion != null && newVersion.compareTo(currentVersion) <= 0) {
1646
              throw new InvalidSystemMetadata("4956", "The serial version in the new system metadata is "+newVersion.toString()+
1646
              throw new InvalidRequest("4869", "The serial version in the new system metadata is "+newVersion.toString()+
1647 1647
                      " which is less than or equals the previous version "+currentVersion.toString()+". This is illegal in the updateSystemMetadata method.");
1648 1648
          }
1649 1649
          Identifier currentSid = currentSysmeta.getSeriesId();
......
1651 1651
              //new sid must match the current sid
1652 1652
              Identifier newSid = sysmeta.getSeriesId();
1653 1653
              if (!isValidIdentifier(newSid)) {
1654
                  throw new InvalidSystemMetadata("4956", "The series id in the system metadata is invalid in the request.");
1654
                  throw new InvalidRequest("4869", "The series id in the system metadata is invalid in the request.");
1655 1655
              } else {
1656 1656
                  if(!newSid.getValue().equals(currentSid.getValue())) {
1657
                      throw new InvalidSystemMetadata("4956", "The series id "+newSid.getValue() +" in the system metadata doesn't match the current sid "+currentSid.getValue());
1657
                      throw new InvalidRequest("4869", "The series id "+newSid.getValue() +" in the system metadata doesn't match the current sid "+currentSid.getValue());
1658 1658
                  }
1659 1659
              }
1660 1660
          } else {
......
1711 1711
	/*
1712 1712
	 * Check if the newMeta modifies an immutable field. 
1713 1713
	 */
1714
	private void checkModifiedImmutableFields(SystemMetadata orgMeta, SystemMetadata newMeta) throws InvalidRequest, InvalidSystemMetadata{
1714
	private void checkModifiedImmutableFields(SystemMetadata orgMeta, SystemMetadata newMeta) throws InvalidRequest{
1715 1715
	    if(orgMeta != null && newMeta != null) {
1716 1716
	        if(newMeta.getIdentifier() == null) {
1717
	            throw new InvalidSystemMetadata("4956", "The new version of the system metadata is invalid since the identifier is null");
1717
	            throw new InvalidRequest("4869", "The new version of the system metadata is invalid since the identifier is null");
1718 1718
	        }
1719 1719
	        if(!orgMeta.getIdentifier().equals(newMeta.getIdentifier())) {
1720 1720
	            throw new InvalidRequest("4869","The request is trying to modify an immutable field in the SystemMeta: the new system meta's identifier "+newMeta.getIdentifier().getValue()+" is "+
1721 1721
	                  "different to the orginal one "+orgMeta.getIdentifier().getValue());
1722 1722
	        }
1723 1723
	        if(newMeta.getSize() == null) {
1724
	            throw new InvalidSystemMetadata("4956", "The new version of the system metadata is invalid since the size is null");
1724
	            throw new InvalidRequest("4869", "The new version of the system metadata is invalid since the size is null");
1725 1725
	        }
1726 1726
	        if(!orgMeta.getSize().equals(newMeta.getSize())) {
1727 1727
	            throw new InvalidRequest("4869", "The request is trying to modify an immutable field in the SystemMeta: the new system meta's size "+newMeta.getSize().longValue()+" is "+

Also available in: Unified diff