Revision 9033
Added by Jing Tao over 9 years ago
MNodeService.java | ||
---|---|---|
273 | 273 |
@Override |
274 | 274 |
public InputStream get(Identifier pid) throws InvalidToken, NotAuthorized, |
275 | 275 |
NotImplemented, ServiceFailure, NotFound, InsufficientResources { |
276 |
boolean exists = false; |
|
277 |
try { |
|
278 |
exists = IdentifierManager.getInstance().systemMetadataPIDExists(pid); |
|
279 |
} catch (SQLException e) { |
|
280 |
throw new ServiceFailure("1030", "The object specified by "+ pid.getValue()+ |
|
281 |
" couldn't be identified if it exists at this node since "+e.getMessage()); |
|
282 |
} |
|
283 |
if(!exists) { |
|
284 |
//the v1 method only handles a pid. |
|
285 |
throw new NotFound("1020", "The object specified by "+pid.getValue()+" does not exist at this node"); |
|
286 |
} |
|
276 |
String serviceFailure = "1030"; |
|
277 |
String notFound = "1020"; |
|
278 |
impl.checkV1SystemMetaPidExist(pid, serviceFailure, notFound); |
|
287 | 279 |
return impl.get(null, pid); |
288 | 280 |
} |
289 | 281 |
|
... | ... | |
292 | 284 |
public InputStream get(Session session, Identifier pid) throws InvalidToken, |
293 | 285 |
NotAuthorized, NotImplemented, ServiceFailure, NotFound, |
294 | 286 |
InsufficientResources { |
295 |
boolean exists = false; |
|
296 |
try { |
|
297 |
exists = IdentifierManager.getInstance().systemMetadataPIDExists(pid); |
|
298 |
} catch (SQLException e) { |
|
299 |
throw new ServiceFailure("1030", "The object specified by "+ pid.getValue()+ |
|
300 |
" couldn't be identified if it exists at this node since "+e.getMessage()); |
|
301 |
} |
|
302 |
if(!exists) { |
|
303 |
//the v1 method only handles a pid. |
|
304 |
throw new NotFound("1020", "The object specified by "+pid.getValue()+" does not exist at this node"); |
|
305 |
} |
|
287 |
String serviceFailure = "1030"; |
|
288 |
String notFound = "1020"; |
|
289 |
impl.checkV1SystemMetaPidExist(pid, serviceFailure, notFound); |
|
306 | 290 |
return impl.get(session, pid); |
307 | 291 |
} |
308 | 292 |
|
Also available in: Unified diff
Refactor the code to check a pid exists in the v1 api.