private void reportError(Element errorSource, String formattedMsg, Exception nestedException) { SAXParseException e = new SAXParseException2( formattedMsg, forest.locatorTable.getStartLocation(errorSource), nestedException); errorReceiver.error(e); }
protected void doGeneration() { try { model.accept(this); } catch (Exception e) { receiver.error(e); } }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource inputSource = null; if (options.entityResolver != null) { inputSource = options.entityResolver.resolveEntity(null, systemId); } if (inputSource == null) { inputSource = new InputSource(systemId); InputStream is = null; int redirects = 0; boolean redirect; URL url = JAXWSUtils.getFileOrURL(inputSource.getSystemId()); URLConnection conn = url.openConnection(); do { if (conn instanceof HttpsURLConnection) { if (options.disableSSLHostnameVerification) { ((HttpsURLConnection) conn).setHostnameVerifier(new HttpClientVerifier()); } } redirect = false; if (conn instanceof HttpURLConnection) { ((HttpURLConnection) conn).setInstanceFollowRedirects(false); } if (conn instanceof JarURLConnection) { if (conn.getUseCaches()) { doReset = true; conn.setDefaultUseCaches(false); c = conn; } } try { is = conn.getInputStream(); // is = sun.net.www.protocol.http.HttpURLConnection.openConnectionCheckRedirects(conn); } catch (IOException e) { if (conn instanceof HttpURLConnection) { HttpURLConnection httpConn = ((HttpURLConnection) conn); int code = httpConn.getResponseCode(); if (code == 401) { errorReceiver.error( new SAXParseException( WscompileMessages.WSIMPORT_AUTH_INFO_NEEDED( e.getMessage(), systemId, WsimportOptions.defaultAuthfile), null, e)); throw new AbortException(); } // FOR other code we will retry with MEX } throw e; } // handle 302 or 303, JDK does not seem to handle 302 very well. // Need to redesign this a bit as we need to throw better error message for IOException in // this case if (conn instanceof HttpURLConnection) { HttpURLConnection httpConn = ((HttpURLConnection) conn); int code = httpConn.getResponseCode(); if (code == 302 || code == 303) { // retry with the value in Location header List<String> seeOther = httpConn.getHeaderFields().get("Location"); if (seeOther != null && seeOther.size() > 0) { URL newurl = new URL(url, seeOther.get(0)); if (!newurl.equals(url)) { errorReceiver.info( new SAXParseException( WscompileMessages.WSIMPORT_HTTP_REDIRECT(code, seeOther.get(0)), null)); url = newurl; httpConn.disconnect(); if (redirects >= 5) { errorReceiver.error( new SAXParseException( WscompileMessages.WSIMPORT_MAX_REDIRECT_ATTEMPT(), null)); throw new AbortException(); } conn = url.openConnection(); inputSource.setSystemId(url.toExternalForm()); redirects++; redirect = true; } } } } } while (redirect); inputSource.setByteStream(is); } return inputSource; }