protected void sendReport ( final WebdavRequest req , final WebdavResponse resp , final Hashtable < String , WebdavStatus > errorList ) throws IOException { resp . setStatus ( WebdavStatus . SC_MULTI_STATUS ) ; final String absoluteUri = req . getRequestURI ( ) ; // String relativePath = getRelativePath(req); final HashMap < String , String > namespaces = new HashMap < String , String > ( ) ; namespaces . put ( "DAV:" , "D" ) ; final XMLWriter generatedXML = new XMLWriter ( namespaces ) ; generatedXML . writeXMLHeader ( ) ; generatedXML . writeElement ( "DAV::multistatus" , XMLWriter . OPENING ) ; final Enumeration < String > pathList = errorList . keys ( ) ; while ( pathList . hasMoreElements ( ) ) { final String errorPath = pathList . nextElement ( ) ; final int errorCode = errorList . get ( errorPath ) . code ( ) ; generatedXML . writeElement ( "DAV::response" , XMLWriter . OPENING ) ; generatedXML . writeElement ( "DAV::href" , XMLWriter . OPENING ) ; String toAppend = null ; if ( absoluteUri . endsWith ( errorPath ) ) { toAppend = absoluteUri ; } else if ( absoluteUri . contains ( errorPath ) ) { final int endIndex = absoluteUri . indexOf ( errorPath ) + errorPath . length ( ) ; toAppend = absoluteUri . substring ( 0 , endIndex ) ; } if ( ! toAppend . startsWith ( "/" ) && ! toAppend . startsWith ( "http:" ) ) { toAppend = "/" + toAppend ; } generatedXML . writeText ( errorPath ) ; generatedXML . writeElement ( "DAV::href" , XMLWriter . CLOSING ) ; generatedXML . writeElement ( "DAV::status" , XMLWriter . OPENING ) ; generatedXML . writeText ( "HTTP/1.1 " + errorCode + " " + WebdavStatus . getStatusText ( errorCode ) ) ; generatedXML . writeElement ( "DAV::status" , XMLWriter . CLOSING ) ; generatedXML . writeElement ( "DAV::response" , XMLWriter . CLOSING ) ; } generatedXML . writeElement ( "DAV::multistatus" , XMLWriter . CLOSING ) ; final Writer writer = resp . getWriter ( ) ; writer . write ( generatedXML . toString ( ) ) ; writer . close ( ) ; }
Send a multistatus element containing a complete error report to the client .