Project

General

Profile

« Previous | Next » 

Revision 9036

Added by Jing Tao almost 10 years ago

Looking for sid for the method describe.

View differences:

src/edu/ucsb/nceas/metacat/dataone/v1/MNodeService.java
259 259
	@Override
260 260
	public DescribeResponse describe(Identifier pid) throws InvalidToken,
261 261
			NotAuthorized, NotImplemented, ServiceFailure, NotFound {
262
	    String serviceFailure = "1030";
263
        String notFound = "1020";
264
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
265
                "No system metadata could be found for given PID: "+pid.getValue());
262 266
		return impl.describe(null, pid);
263 267
	}
264 268

  
......
267 271
	public DescribeResponse describe(Session session, Identifier pid)
268 272
			throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
269 273
			NotFound {
274
	    String serviceFailure = "1030";
275
        String notFound = "1020";
276
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
277
                "No system metadata could be found for given PID: "+pid.getValue());
270 278
		return impl.describe(session, pid);
271 279
	}
272 280

  
......
275 283
			NotImplemented, ServiceFailure, NotFound, InsufficientResources {
276 284
	    String serviceFailure = "1030";
277 285
        String notFound = "1020";
278
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, notFound);
286
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
287
                "The object specified by "+pid.getValue()+" does not exist at this node.");
279 288
		return impl.get(null, pid);
280 289
	}
281 290

  
......
286 295
			InsufficientResources {
287 296
	    String serviceFailure = "1030";
288 297
        String notFound = "1020";
289
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, notFound);
298
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
299
                "The object specified by "+pid.getValue()+" does not exist at this node.");
290 300
		return impl.get(session, pid);
291 301
	}
292 302

  
src/edu/ucsb/nceas/metacat/dataone/v1/CNodeService.java
194 194
	@Override
195 195
	public DescribeResponse describe(Identifier pid) throws InvalidToken,
196 196
			NotAuthorized, NotImplemented, ServiceFailure, NotFound {
197
	    String serviceFailure = "4931";
198
        String notFound = "4933";
199
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
200
                "No system metadata could be found for given PID: "+pid.getValue());
197 201
		return impl.describe(null, pid);
198 202
	}
199 203

  
......
202 206
	public DescribeResponse describe(Session session, Identifier pid)
203 207
			throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
204 208
			NotFound {
209
	    String serviceFailure = "4931";
210
        String notFound = "4933";
211
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
212
                "No system metadata could be found for given PID: "+pid.getValue());
205 213
		return impl.describe(session, pid);
206 214
	}
207 215

  
......
210 218
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
211 219
        String serviceFailure = "1030";
212 220
        String notFound = "1020";
213
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, notFound);
221
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
222
                "The object specified by "+pid.getValue()+" does not exist at this node");
214 223
		return impl.get(null, pid);
215 224
	}
216 225

  
......
220 229
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
221 230
	    String serviceFailure = "1030";
222 231
        String notFound = "1020";
223
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, notFound);
232
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
233
                "The object specified by "+pid.getValue()+" does not exist at this node");
224 234
		return impl.get(session, pid);
225 235
	}
226 236

  
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
169 169
   */
170 170
  public DescribeResponse describe(Session session, Identifier pid) 
171 171
      throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
172
      
173
      String serviceFailureCode = "4931";
174
      Identifier sid = getPIDForSID(pid, serviceFailureCode);
175
      if(sid != null) {
176
          pid = sid;
177
      }
172 178

  
173 179
    // get system metadata and construct the describe response
174 180
      SystemMetadata sysmeta = getSystemMetadata(session, pid);
......
1674 1680
   * @throws ServiceFailure
1675 1681
   * @throws NotFound
1676 1682
   */
1677
  public void checkV1SystemMetaPidExist(Identifier identifier, String serviceFailureCode, String noFoundCode) throws ServiceFailure, NotFound {
1683
  public void checkV1SystemMetaPidExist(Identifier identifier, String serviceFailureCode, String serviceFailureMessage,  
1684
          String noFoundCode, String notFoundMessage) throws ServiceFailure, NotFound {
1678 1685
      boolean exists = false;
1679 1686
      try {
1680 1687
          exists = IdentifierManager.getInstance().systemMetadataPIDExists(identifier);
1681 1688
      } catch (SQLException e) {
1682
          throw new ServiceFailure(serviceFailureCode, "The object specified by "+ identifier.getValue()+
1683
                  " couldn't be identified if it exists at this node since "+e.getMessage());
1689
          throw new ServiceFailure(serviceFailureCode, serviceFailureMessage+" since "+e.getMessage());
1684 1690
      }
1685 1691
      if(!exists) {
1686 1692
        //the v1 method only handles a pid.
1687
          throw new NotFound(noFoundCode, "The object specified by "+identifier.getValue()+" does not exist at this node");
1693
          throw new NotFound(noFoundCode, notFoundMessage);
1688 1694
      }
1689 1695
  }
1690 1696
  
......
1698 1704
   */
1699 1705
  protected Identifier getPIDForSID(Identifier sid, String serviceFailureCode) throws ServiceFailure {
1700 1706
      Identifier id = null;
1707
      String serviceFailureMessage = "The PID "+" couldn't be identified for the sid " + sid.getValue();
1701 1708
      try {
1702 1709
          //determine if the given pid is a sid or not.
1703 1710
          if(IdentifierManager.getInstance().systemMetadataSIDExists(sid)) {
......
1705 1712
                  //set the header pid for the sid if the identifier is a sid.
1706 1713
                  id = IdentifierManager.getInstance().getHeadPID(sid);
1707 1714
              } catch (SQLException sqle) {
1708
                  throw new ServiceFailure(serviceFailureCode, "The current pid associated with the sid "+ sid.getValue()+
1709
                          " couldn't be identified at this node since "+sqle.getMessage());
1715
                  throw new ServiceFailure(serviceFailureCode, serviceFailureMessage+" since "+sqle.getMessage());
1710 1716
              }
1711 1717
              
1712 1718
          }
1713 1719
      } catch (SQLException e) {
1714
          throw new ServiceFailure(serviceFailureCode, "The object specified by "+ sid.getValue()+
1715
                  " couldn't be identified at this node since "+e.getMessage());
1720
          throw new ServiceFailure(serviceFailureCode, serviceFailureMessage + " since "+e.getMessage());
1716 1721
      }
1717 1722
      return id;
1718 1723
  }

Also available in: Unified diff