SvnDavController implements HttpRequestHandler, ServletConfig, ServletContextAware { public static void handleError(DAVException error, HttpServletResponse servletResponse) throws IOException { SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, error); DAVResponse response = error.getResponse(); if (response == null) { DAVException stackErr = error; while (stackErr != null && stackErr.getTagName() == null) { stackErr = stackErr.getPreviousException(); } if (stackErr != null && stackErr.getTagName() != null) { servletResponse.setContentType(XML_CONTENT_TYPE); servletResponse.setStatus(stackErr.getResponseCode()); StringBuffer errorMessageBuffer = new StringBuffer(); SVNXMLUtil.addXMLHeader(errorMessageBuffer); errorMessageBuffer.append('\n'); errorMessageBuffer.append("<D:error xmlns:D=\"DAV:\""); if (stackErr.getMessage() != null) { errorMessageBuffer.append(" xmlns:m=\"http: } if (stackErr.getNameSpace() != null) { errorMessageBuffer.append(" xmlns:C=\""); errorMessageBuffer.append(stackErr.getNameSpace()); errorMessageBuffer.append("\">\n<C:"); errorMessageBuffer.append(stackErr.getTagName()); errorMessageBuffer.append("/>"); } else { errorMessageBuffer.append(">\n<D:"); errorMessageBuffer.append(stackErr.getTagName()); errorMessageBuffer.append("/>"); } if (stackErr.getMessage() != null) { errorMessageBuffer.append("<m:human-readable errcode=\""); errorMessageBuffer.append(stackErr.getErrorID()); errorMessageBuffer.append("\">\n"); errorMessageBuffer.append(SVNEncodingUtil.xmlEncodeCDATA(stackErr.getMessage())); errorMessageBuffer.append('\n'); errorMessageBuffer.append("</m:human-readable>\n"); } errorMessageBuffer.append("</D:error>\n"); servletResponse.getWriter().print(errorMessageBuffer.toString()); SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, errorMessageBuffer.toString()); return; } servletResponse.setStatus(error.getResponseCode()); return; } DAVXMLUtil.sendMultiStatus(response, servletResponse, error.getResponseCode(), null); }  @PostConstruct void init(); void setDAVConfig(DAVConfig davConfig); ServletConfig getServletConfig(); @Override void handleRequest(HttpServletRequest request, HttpServletResponse response); static void handleError(DAVException error, HttpServletResponse servletResponse); @Override String getServletName(); @Override ServletContext getServletContext(); @Override String getInitParameter(String name); @Override Enumeration getInitParameterNames(); @Override void setServletContext(ServletContext servletContext); static final Logger LOGGER; static final String XML_CONTENT_TYPE; }
@Test public void testHandleError() throws IOException { DAVException davE = new DAVException("Test Error", 404, 0); HttpServletResponse resp = new MockHttpServletResponse(); SvnDavController.handleError(davE, resp); }