61 |
61 |
import edu.ucsb.nceas.metacat.IdentifierManager;
|
62 |
62 |
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
|
63 |
63 |
import edu.ucsb.nceas.metacat.MetacatHandler;
|
|
64 |
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
|
64 |
65 |
import edu.ucsb.nceas.metacat.dataone.CrudService;
|
65 |
66 |
import edu.ucsb.nceas.metacat.service.SessionService;
|
66 |
67 |
import edu.ucsb.nceas.metacat.util.RequestUtil;
|
... | ... | |
631 |
632 |
{ //get a specific document
|
632 |
633 |
Identifier id = new Identifier();
|
633 |
634 |
id.setValue(guid);
|
634 |
|
InputStream data = cs.get(token, id);
|
635 |
|
IOUtils.copyLarge(data, response.getOutputStream());
|
|
635 |
try
|
|
636 |
{
|
|
637 |
InputStream data = cs.get(token, id);
|
|
638 |
IOUtils.copyLarge(data, response.getOutputStream());
|
|
639 |
}
|
|
640 |
catch(InvalidToken it)
|
|
641 |
{
|
|
642 |
serializeException(it, out);
|
|
643 |
}
|
|
644 |
catch(ServiceFailure sf)
|
|
645 |
{
|
|
646 |
serializeException(sf, out);
|
|
647 |
}
|
|
648 |
catch(NotAuthorized na)
|
|
649 |
{
|
|
650 |
serializeException(na, out);
|
|
651 |
}
|
|
652 |
catch(NotFound nf)
|
|
653 |
{
|
|
654 |
serializeException(nf, out);
|
|
655 |
}
|
|
656 |
catch(NotImplemented ni)
|
|
657 |
{
|
|
658 |
serializeException(ni, out);
|
|
659 |
}
|
|
660 |
catch(Exception e)
|
|
661 |
{
|
|
662 |
System.out.println("Error with Crud.get(). " +
|
|
663 |
"If this is an 'Exception producing data' error, " +
|
|
664 |
"go to CrudService.get() for better debugging. " +
|
|
665 |
"Here's the error: " + e.getMessage());
|
|
666 |
e.printStackTrace();
|
|
667 |
ServiceFailure sf = new ServiceFailure("1030",
|
|
668 |
"IO Error in ResourceHandler.getObject: " + e.getMessage());
|
|
669 |
serializeException(sf, out);
|
|
670 |
}
|
636 |
671 |
}
|
637 |
672 |
else
|
638 |
673 |
{ //call listObjects with specified params
|
added some new error handling to work around this issue https://trac.dataone.org/ticket/706