Project

General

Profile

« Previous | Next » 

Revision 7043

serialize exception in header for describe response when there is a BaseException
https://redmine.dataone.org/issues/2440

View differences:

src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java
739 739
     */
740 740
    private void describeObject(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, InvalidRequest
741 741
    {
742
        response.setStatus(200);
742
        
743 743
        response.setContentType("text/xml");
744
        
744

  
745 745
        Identifier id = new Identifier();
746 746
        id.setValue(pid);
747 747

  
748
        DescribeResponse dr = MNodeService.getInstance(request).describe(session, id);
748
        DescribeResponse dr = null;
749
        try {
750
        	dr = MNodeService.getInstance(request).describe(session, id);
751
        } catch (BaseException e) {
752
        	response.setStatus(e.getCode());
753
        	response.addHeader("DataONE-Exception-Name", e.getClass().getName());
754
            response.addHeader("DataONE-Exception-DetailCode", e.getDetail_code());
755
            response.addHeader("DataONE-Exception-Description", e.getDescription());
756
            response.addHeader("DataONE-Exception-PID", id.getValue());
757
            return;
758
		}
759
        
760
        response.setStatus(200);
761
        
749 762
        //response.addHeader("pid", pid);
750 763
        response.addHeader("DataONE-Checksum", dr.getDataONE_Checksum().getAlgorithm() + "," + dr.getDataONE_Checksum().getValue());
751 764
        response.addHeader("Content-Length", dr.getContent_Length() + "");
src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
720 720
     */
721 721
    private void describeObject(String pid) throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented, InvalidRequest
722 722
    {
723
        response.setStatus(200);
724 723
        response.setContentType("text/xml");
725 724
        
726 725
        Identifier id = new Identifier();
727 726
        id.setValue(pid);
728

  
729
        DescribeResponse dr = CNodeService.getInstance(request).describe(session, id);
727
        
728
        DescribeResponse dr = null;
729
        try {
730
            dr = CNodeService.getInstance(request).describe(session, id);
731
        } catch (BaseException e) {
732
        	response.setStatus(e.getCode());
733
        	response.addHeader("DataONE-Exception-Name", e.getClass().getName());
734
            response.addHeader("DataONE-Exception-DetailCode", e.getDetail_code());
735
            response.addHeader("DataONE-Exception-Description", e.getDescription());
736
            response.addHeader("DataONE-Exception-PID", id.getValue());
737
            return;
738
		}
739
        
740
        response.setStatus(200);
730 741
        //response.addHeader("pid", pid);
731 742
        response.addHeader("DataONE-Checksum", dr.getDataONE_Checksum().getAlgorithm() + "," + dr.getDataONE_Checksum().getValue());
732 743
        response.addHeader("Content-Length", dr.getContent_Length() + "");

Also available in: Unified diff