protected void examineMultiStatusResponse ( IResponse response ) throws DAVException { // If it is not a multistatus we don't look at it. if ( response . getStatusCode ( ) != IResponse . SC_MULTI_STATUS ) return ; // It is declared a multistatus, so if there is no response body // then that is a problem. if ( ! response . hasDocumentBody ( ) ) throw new DAVException ( Policy . bind ( "exception.responseMustHaveDocBody" ) ) ; //$NON-NLS-1$ // Extract the XML document from the response. Element documentElement ; try { documentElement = response . getDocumentBody ( ) . getDocumentElement ( ) ; if ( documentElement == null ) throw new DAVException ( Policy . bind ( "exception.invalidDoc" ) ) ; //$NON-NLS-1$ } catch ( IOException exception ) { throw new SystemException ( exception ) ; } // Enumerate all the responses in the multistat and check that // they are indicating success (i.e. are 200-series response codes). try { MultiStatus multistatus = new MultiStatus ( documentElement ) ; Enumeration responseEnum = multistatus . getResponses ( ) ; while ( responseEnum . hasMoreElements ( ) ) { ResponseBody responseBody = ( ResponseBody ) responseEnum . nextElement ( ) ; Enumeration propstatEnum = responseBody . getPropStats ( ) ; while ( propstatEnum . hasMoreElements ( ) ) { PropStat propstat = ( PropStat ) propstatEnum . nextElement ( ) ; examineStatusCode ( propstat . getStatusCode ( ) , propstat . getResponseDescription ( ) ) ; } // end-while } // end-while } catch ( MalformedElementException e ) { throw new SystemException ( e ) ; } }
If the given response contains a multistatus body the bodies status are checked for errors . If an error is found an exception is thrown .