194 |
194 |
// verify that guid == SystemMetadata.getIdentifier()
|
195 |
195 |
logMetacat.debug("Comparing guid|sysmeta_guid: " + guid.getValue() + "|" + sysmeta.getIdentifier().getValue());
|
196 |
196 |
if (!guid.getValue().equals(sysmeta.getIdentifier().getValue())) {
|
197 |
|
throw new InvalidSystemMetadata(1180,
|
|
197 |
throw new InvalidSystemMetadata("1180",
|
198 |
198 |
"GUID in method call does not match GUID in system metadata.");
|
199 |
199 |
}
|
200 |
200 |
|
... | ... | |
202 |
202 |
// Check that the identifier does not already exist
|
203 |
203 |
IdentifierManager im = IdentifierManager.getInstance();
|
204 |
204 |
if (im.identifierExists(guid.getValue())) {
|
205 |
|
throw new IdentifierNotUnique(1120,
|
|
205 |
throw new IdentifierNotUnique("1120",
|
206 |
206 |
"GUID is already in use by an existing object.");
|
207 |
207 |
}
|
208 |
208 |
|
... | ... | |
217 |
217 |
String msg = "Could not create string from XML stream: " +
|
218 |
218 |
" " + e.getMessage();
|
219 |
219 |
logMetacat.debug(msg);
|
220 |
|
throw new ServiceFailure(1190, msg);
|
|
220 |
throw new ServiceFailure("1190", msg);
|
221 |
221 |
}
|
222 |
222 |
|
223 |
223 |
} else {
|
... | ... | |
275 |
275 |
}
|
276 |
276 |
catch(Exception e)
|
277 |
277 |
{
|
278 |
|
throw new ServiceFailure(1030, "Error updating document in CrudService: " + e.getMessage());
|
|
278 |
throw new ServiceFailure("1030", "Error updating document in CrudService: " + e.getMessage());
|
279 |
279 |
}
|
280 |
280 |
}
|
281 |
281 |
|
282 |
282 |
public Identifier delete(AuthToken token, Identifier guid)
|
283 |
283 |
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
284 |
284 |
NotImplemented {
|
285 |
|
throw new NotImplemented(1000, "This method not yet implemented.");
|
|
285 |
throw new NotImplemented("1000", "This method not yet implemented.");
|
286 |
286 |
}
|
287 |
287 |
|
288 |
288 |
public DescribeResponse describe(AuthToken token, Identifier guid)
|
289 |
289 |
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
290 |
290 |
NotImplemented {
|
291 |
|
throw new NotImplemented(1000, "This method not yet implemented.");
|
|
291 |
throw new NotImplemented("1000", "This method not yet implemented.");
|
292 |
292 |
}
|
293 |
293 |
|
294 |
294 |
public InputStream get(AuthToken token, Identifier guid)
|
... | ... | |
316 |
316 |
sessionData.getUserName(),
|
317 |
317 |
sessionData.getGroupNames(), true, params);
|
318 |
318 |
} catch (PropertyNotFoundException e) {
|
319 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
319 |
throw new ServiceFailure("1030", e.getMessage());
|
320 |
320 |
} catch (ClassNotFoundException e) {
|
321 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
321 |
throw new ServiceFailure("1030", e.getMessage());
|
322 |
322 |
} catch (IOException e) {
|
323 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
323 |
throw new ServiceFailure("1030", e.getMessage());
|
324 |
324 |
} catch (SQLException e) {
|
325 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
325 |
throw new ServiceFailure("1030", e.getMessage());
|
326 |
326 |
} catch (McdbException e) {
|
327 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
327 |
throw new ServiceFailure("1030", e.getMessage());
|
328 |
328 |
} catch (ParseLSIDException e) {
|
329 |
|
throw new NotFound(1020, e.getMessage());
|
|
329 |
throw new NotFound("1020", e.getMessage());
|
330 |
330 |
} catch (InsufficientKarmaException e) {
|
331 |
|
throw new NotAuthorized(1000, "Not authorized for get().");
|
|
331 |
throw new NotAuthorized("1000", "Not authorized for get().");
|
332 |
332 |
}
|
333 |
333 |
|
334 |
334 |
return "Completed";
|
... | ... | |
337 |
337 |
return objectStream;
|
338 |
338 |
|
339 |
339 |
} catch (McdbDocNotFoundException e) {
|
340 |
|
throw new NotFound(1020, e.getMessage());
|
|
340 |
throw new NotFound("1020", e.getMessage());
|
341 |
341 |
}
|
342 |
342 |
}
|
343 |
343 |
|
344 |
344 |
public Checksum getChecksum(AuthToken token, Identifier guid)
|
345 |
345 |
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
346 |
346 |
InvalidRequest, NotImplemented {
|
347 |
|
throw new NotImplemented(1000, "This method not yet implemented.");
|
|
347 |
throw new NotImplemented("1000", "This method not yet implemented.");
|
348 |
348 |
}
|
349 |
349 |
|
350 |
350 |
public Checksum getChecksum(AuthToken token, Identifier guid,
|
351 |
351 |
String checksumAlgorithm) throws InvalidToken, ServiceFailure,
|
352 |
352 |
NotAuthorized, NotFound, InvalidRequest, NotImplemented {
|
353 |
|
throw new NotImplemented(1000, "This method not yet implemented.");
|
|
353 |
throw new NotImplemented("1000", "This method not yet implemented.");
|
354 |
354 |
}
|
355 |
355 |
|
356 |
356 |
public LogRecordSet getLogRecords(AuthToken token, Date fromDate, Date toDate)
|
357 |
357 |
throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest,
|
358 |
358 |
NotImplemented {
|
359 |
|
throw new NotImplemented(1000, "This method not yet implemented.");
|
|
359 |
throw new NotImplemented("1000", "This method not yet implemented.");
|
360 |
360 |
}
|
361 |
361 |
|
362 |
362 |
public SystemMetadata getSystemMetadata(AuthToken token, Identifier guid)
|
... | ... | |
387 |
387 |
sessionData.getUserName(),
|
388 |
388 |
sessionData.getGroupNames(), true, params);
|
389 |
389 |
} catch (PropertyNotFoundException e) {
|
390 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
390 |
throw new ServiceFailure("1030", e.getMessage());
|
391 |
391 |
} catch (ClassNotFoundException e) {
|
392 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
392 |
throw new ServiceFailure("1030", e.getMessage());
|
393 |
393 |
} catch (IOException e) {
|
394 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
394 |
throw new ServiceFailure("1030", e.getMessage());
|
395 |
395 |
} catch (SQLException e) {
|
396 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
396 |
throw new ServiceFailure("1030", e.getMessage());
|
397 |
397 |
} catch (McdbException e) {
|
398 |
|
throw new ServiceFailure(1030, e.getMessage());
|
|
398 |
throw new ServiceFailure("1030", e.getMessage());
|
399 |
399 |
} catch (ParseLSIDException e) {
|
400 |
|
throw new NotFound(1020, e.getMessage());
|
|
400 |
throw new NotFound("1020", e.getMessage());
|
401 |
401 |
} catch (InsufficientKarmaException e) {
|
402 |
|
throw new NotAuthorized(1000, "Not authorized for get().");
|
|
402 |
throw new NotAuthorized("1000", "Not authorized for get().");
|
403 |
403 |
}
|
404 |
404 |
|
405 |
405 |
return "Completed";
|
... | ... | |
412 |
412 |
|
413 |
413 |
} catch (McdbDocNotFoundException e) {
|
414 |
414 |
//e.printStackTrace();
|
415 |
|
throw new NotFound(1000, e.getMessage());
|
|
415 |
throw new NotFound("1000", e.getMessage());
|
416 |
416 |
}
|
417 |
417 |
}
|
418 |
418 |
|
... | ... | |
505 |
505 |
//newFile.delete();
|
506 |
506 |
logMetacat.debug("SQLE: " + e.getMessage());
|
507 |
507 |
e.printStackTrace(System.out);
|
508 |
|
throw new ServiceFailure(1190, "Registration failed: " + e.getMessage());
|
|
508 |
throw new ServiceFailure("1190", "Registration failed: " + e.getMessage());
|
509 |
509 |
} catch (AccessionNumberException e) {
|
510 |
510 |
//newFile.delete();
|
511 |
511 |
logMetacat.debug("ANE: " + e.getMessage());
|
512 |
512 |
e.printStackTrace(System.out);
|
513 |
|
throw new ServiceFailure(1190, "Registration failed: " + e.getMessage());
|
|
513 |
throw new ServiceFailure("1190", "Registration failed: " + e.getMessage());
|
514 |
514 |
} catch (Exception e) {
|
515 |
515 |
//newFile.delete();
|
516 |
516 |
logMetacat.debug("Exception: " + e.getMessage());
|
517 |
517 |
e.printStackTrace(System.out);
|
518 |
|
throw new ServiceFailure(1190, "Registration failed: " + e.getMessage());
|
|
518 |
throw new ServiceFailure("1190", "Registration failed: " + e.getMessage());
|
519 |
519 |
}
|
520 |
520 |
|
521 |
521 |
logMetacat.debug("Logging the creation event.");
|
... | ... | |
528 |
528 |
localId, "insert", false, null);
|
529 |
529 |
|
530 |
530 |
} catch (PropertyNotFoundException e) {
|
531 |
|
throw new ServiceFailure(1190, "Could not lock file for writing:" + e.getMessage());
|
|
531 |
throw new ServiceFailure("1190", "Could not lock file for writing:" + e.getMessage());
|
532 |
532 |
}
|
533 |
533 |
|
534 |
534 |
}
|
535 |
535 |
} catch (Exception e) {
|
536 |
536 |
// Could not get a lock on the document, so we can not update the file now
|
537 |
|
throw new ServiceFailure(1190, "Failed to lock file: " + e.getMessage());
|
|
537 |
throw new ServiceFailure("1190", "Failed to lock file: " + e.getMessage());
|
538 |
538 |
}
|
539 |
539 |
}
|
540 |
540 |
|
... | ... | |
553 |
553 |
os.close();
|
554 |
554 |
} else {
|
555 |
555 |
logMetacat.debug("File creation failed, or file already exists.");
|
556 |
|
throw new ServiceFailure(1190, "File already exists: " + fileName);
|
|
556 |
throw new ServiceFailure("1190", "File already exists: " + fileName);
|
557 |
557 |
}
|
558 |
558 |
} catch (FileNotFoundException e) {
|
559 |
559 |
logMetacat.debug("FNF: " + e.getMessage());
|
560 |
|
throw new ServiceFailure(1190, "File not found: " + fileName + " "
|
|
560 |
throw new ServiceFailure("1190", "File not found: " + fileName + " "
|
561 |
561 |
+ e.getMessage());
|
562 |
562 |
} catch (IOException e) {
|
563 |
563 |
logMetacat.debug("IOE: " + e.getMessage());
|
564 |
|
throw new ServiceFailure(1190, "File was not written: " + fileName
|
|
564 |
throw new ServiceFailure("1190", "File was not written: " + fileName
|
565 |
565 |
+ " " + e.getMessage());
|
566 |
566 |
}
|
567 |
567 |
|
... | ... | |
605 |
605 |
}
|
606 |
606 |
catch(Exception e)
|
607 |
607 |
{
|
608 |
|
throw new ServiceFailure(1030, "Error updating system metadata: " + e.getMessage());
|
|
608 |
throw new ServiceFailure("1030", "Error updating system metadata: " + e.getMessage());
|
609 |
609 |
}
|
610 |
610 |
}
|
611 |
611 |
|
... | ... | |
689 |
689 |
}
|
690 |
690 |
catch(McdbDocNotFoundException e)
|
691 |
691 |
{
|
692 |
|
throw new ServiceFailure(1030, "CrudService.insertOrUpdateDocument(): " +
|
|
692 |
throw new ServiceFailure("1030", "CrudService.insertOrUpdateDocument(): " +
|
693 |
693 |
"guid " + guid.getValue() + " should have been in the identifier table, but it wasn't: " + e.getMessage());
|
694 |
694 |
}
|
695 |
695 |
}
|
... | ... | |
733 |
733 |
sysmetaOut = new ByteArrayOutputStream();
|
734 |
734 |
mctx.marshalDocument(sysmeta, "UTF-8", null, sysmetaOut);
|
735 |
735 |
} catch (JiBXException e) {
|
736 |
|
throw new ServiceFailure(1190, "Failed to serialize and insert SystemMetadata: " + e.getMessage());
|
|
736 |
throw new ServiceFailure("1190", "Failed to serialize and insert SystemMetadata: " + e.getMessage());
|
737 |
737 |
}
|
738 |
738 |
|
739 |
739 |
return sysmetaOut;
|
... | ... | |
747 |
747 |
SystemMetadata sysmeta = (SystemMetadata) uctx.unmarshalDocument(xml, null);
|
748 |
748 |
return sysmeta;
|
749 |
749 |
} catch (JiBXException e) {
|
750 |
|
throw new ServiceFailure(1190, "Failed to serialize and insert SystemMetadata: " + e.getMessage());
|
|
750 |
throw new ServiceFailure("1190", "Failed to serialize and insert SystemMetadata: " + e.getMessage());
|
751 |
751 |
}
|
752 |
752 |
}
|
753 |
753 |
}
|
changed the detailCode for DataOne exceptions to a string