Project

General

Profile

« Previous | Next » 

Revision 9343

Added by Jing Tao over 8 years ago

The setReplicationPolicy method only apply to the pids whose authoritative member node has v2 MNStorage.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
107 107

  
108 108
  /* the logger instance */
109 109
  private Logger logMetacat = null;
110
  public final static String V2V1MISSMATCH = "The Coordinating Node is not authorized to make systemMetadata changes on this object. Please make changes directly on the authoritative Member Node.";
110 111

  
111 112
  /**
112 113
   * singleton accessor
......
152 153
          
153 154
      }
154 155
      
156
      //only allow pid to be passed
157
      String serviceFailure = "4882";
158
      String notFound = "4884";
159
      checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
160
              "No object could be found for given PID: "+pid.getValue());
161
      
155 162
      /*String serviceFailureCode = "4882";
156 163
      Identifier sid = getPIDForSID(pid, serviceFailureCode);
157 164
      if(sid != null) {
......
188 195
                  throw new NotFound("4884", "Couldn't find an object identified by " + pid.getValue());
189 196
                  
190 197
              }
191

  
198
              D1NodeVersionChecker checker = new D1NodeVersionChecker(systemMetadata.getAuthoritativeMemberNode());
199
              String version = checker.getVersion("MNStorage");
200
              if(version == null) {
201
                  throw new ServiceFailure("4882", "Couldn't determine the version of the MNStorge for the "+pid.getValue());
202
              } else if (version.equalsIgnoreCase(D1NodeVersionChecker.V2)) {
203
                  //we don't apply this method to an object whose authoritative node is v2
204
                  throw new NotAuthorized("4881", V2V1MISSMATCH);
205
              } else if (!version.equalsIgnoreCase(D1NodeVersionChecker.V1)) {
206
                  //we don't understand this version (it is not v1 or v2)
207
                  throw new InvalidRequest("4883", "The version of the MNStorage is "+version+" for the authoritative member node of the object "+pid.getValue()+". We don't support it.");
208
              }
192 209
              // does the request have the most current system metadata?
193 210
              if ( systemMetadata.getSerialVersion().longValue() != serialVersion ) {
194 211
                 String msg = "The requested system metadata version number " + 
src/edu/ucsb/nceas/metacat/dataone/v1/CNodeService.java
162 162
			ReplicationPolicy policy, long serialVersion) throws NotImplemented, NotFound,
163 163
			NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
164 164
			VersionMismatch {
165
	    String serviceFailure = "4882";
166
        String notFound = "4884";
167
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
168
                "No object could be found for given PID: "+pid.getValue());
169 165
		return impl.setReplicationPolicy(session, pid, policy, serialVersion);
170 166

  
171 167
	}
......
174 170
	public boolean setReplicationStatus(Identifier pid,
175 171
			NodeReference targetNode, ReplicationStatus status, BaseException failure) 
176 172
			throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized, InvalidRequest, NotFound {
177
	    String serviceFailure = "4700";
178
        String notFound = "4740";
179
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
180
                "No object could be found for given PID: "+pid.getValue());
181 173
		return impl.setReplicationStatus(null, pid, targetNode, status, failure);
182 174
	}
183 175

  

Also available in: Unified diff