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:

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() + "");

Also available in: Unified diff