Project

General

Profile

« Previous | Next » 

Revision 9066

Added by Jing Tao over 9 years ago

The the code to handle sids on the v2 api - setReplicationPolicy, setReplicationStatus, setAccessPolicy and setObsoletedBy.

View differences:

CNodeService.java
138 138
      throws NotImplemented, NotFound, NotAuthorized, ServiceFailure, 
139 139
      InvalidRequest, InvalidToken, VersionMismatch {
140 140
      
141
      // do we have a valid pid?
142
      if (pid == null || pid.getValue().trim().equals("")) {
143
          throw new InvalidRequest("4883", "The provided identifier was invalid.");
144
          
145
      }
146
      
147
      String serviceFailureCode = "4882";
148
      Identifier sid = getPIDForSID(pid, serviceFailureCode);
149
      if(sid != null) {
150
          pid = sid;
151
      }
141 152
      // The lock to be used for this identifier
142 153
      Lock lock = null;
143 154
      
......
621 632
			Identifier obsoletedByPid, long serialVersion)
622 633
			throws NotImplemented, NotFound, NotAuthorized, ServiceFailure,
623 634
			InvalidRequest, InvalidToken, VersionMismatch {
635
      
636
      // do we have a valid pid?
637
      if (pid == null || pid.getValue().trim().equals("")) {
638
          throw new InvalidRequest("4942", "The provided identifier was invalid.");
639
          
640
      }
641
      
642
      String serviceFailureCode = "4941";
643
      Identifier sid = getPIDForSID(pid, serviceFailureCode);
644
      if(sid != null) {
645
          pid = sid;
646
      }
647
      
648
      // do we have a valid pid?
649
      if (obsoletedByPid == null || obsoletedByPid.getValue().trim().equals("")) {
650
          throw new InvalidRequest("4942", "The provided obsoletedByPid was invalid.");
651
          
652
      }
653
      
654
      try {
655
          if(IdentifierManager.getInstance().systemMetadataSIDExists(obsoletedByPid)) {
656
              throw new InvalidRequest("4942", "The provided obsoletedByPid "+obsoletedByPid.getValue()+" is an existing SID. However, it must NOT be an SID.");
657
          }
658
      } catch (SQLException ee) {
659
          throw new ServiceFailure("4941", "Couldn't determine if the obsoletedByPid "+obsoletedByPid.getValue()+" is an SID or not. The id shouldn't be an SID.");
660
      }
661
      
624 662

  
625 663
		// The lock to be used for this identifier
626 664
		Lock lock = null;
......
719 757
	  if (session == null) {
720 758
		  throw new NotAuthorized("4720", "Session cannot be null");
721 759
	  }
760
	  
761
	// do we have a valid pid?
762
      if (pid == null || pid.getValue().trim().equals("")) {
763
          throw new InvalidRequest("4730", "The provided identifier was invalid.");
764
          
765
      }
722 766
      
767
      String serviceFailureCode = "4700";
768
      Identifier sid = getPIDForSID(pid, serviceFailureCode);
769
      if(sid != null) {
770
          pid = sid;
771
      }
772
      
723 773
      // The lock to be used for this identifier
724 774
      Lock lock = null;
725 775
      
......
1576 1626
      throws InvalidToken, ServiceFailure, NotFound, NotAuthorized, 
1577 1627
      NotImplemented, InvalidRequest, VersionMismatch {
1578 1628
      
1629
   // do we have a valid pid?
1630
      if (pid == null || pid.getValue().trim().equals("")) {
1631
          throw new InvalidRequest("4402", "The provided identifier was invalid.");
1632
          
1633
      }
1634
      
1635
      String serviceFailureCode = "4430";
1636
      Identifier sid = getPIDForSID(pid, serviceFailureCode);
1637
      if(sid != null) {
1638
          pid = sid;
1639
      }
1579 1640
      // The lock to be used for this identifier
1580 1641
      Lock lock = null;
1581 1642
      SystemMetadata systemMetadata = null;

Also available in: Unified diff