private Source secureXslt(InputStream is) { // Need to filter out any external entities Source result = null; try { DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(secureEntityResolver); Document document = builder.parse(is); result = new DOMSource(document); } catch (ParserConfigurationException | SAXException | IOException e) { if (debug > 0) { log(e.getMessage(), e); } } finally { if (is != null) { try { is.close(); } catch (IOException e) { // Ignore } } } return result; }
private Source secureXslt(InputStream is) { // Need to filter out any external entities Source result = null; try { DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(secureEntityResolver); Document document = builder.parse(is); result = new DOMSource(document); } catch (ParserConfigurationException | SAXException | IOException e) { if (debug > 0) { log(e.getMessage(), e); } } finally { if (is != null) { try { is.close(); } catch (IOException e) { // Ignore } } } return result; }
log("Serving bytes:" + start + "-" + end);
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) { if (readmeFile!=null) { try { Object obj = directory.lookup(readmeFile); if (obj!=null && obj instanceof Resource) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource)obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch(IOException ioe) { log("DefaultServlet.getReadme: IO exception: " + ioe.getMessage()); } catch (NamingException ne) { log("DefaultServlet.getReadme: Naming exception: " + ne.getMessage()); } } return null; }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException, ServletException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
reader.close(); } catch (Exception e) { log("DefaultServlet.copy: exception closing reader: " + e.getMessage());
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception). * * @param resourceInfo The ResourceInfo object * @param ostream The output stream to write to * @param range Range the client wanted to retrieve * @exception IOException if an input/output error occurs */ protected void copy(CacheEntry cacheEntry, ServletOutputStream ostream, Range range) throws IOException { IOException exception = null; InputStream resourceInputStream = cacheEntry.resource.streamContent(); InputStream istream = new BufferedInputStream(resourceInputStream, input); exception = copyRange(istream, ostream, range.start, range.end); // Clean up the input stream try { istream.close(); } catch (Exception e) { log("DefaultServlet.copy: exception closing input stream: " + e.getMessage()); } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException, ServletException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException, ServletException { if (readmeFile!=null) { try { Object obj = directory.lookup(readmeFile); if (obj!=null && obj instanceof Resource) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource)obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch(Throwable e) { ; /* Should only be IOException or NamingException * can be ignored */ if (debug > 10) log("readme '" + readmeFile + "' not found", e); } } return null; }
/** * Get the readme file as a string. */ protected String getReadme(DirContext directory) throws IOException { if (readmeFile != null) { try { Object obj = directory.lookup(readmeFile); if ((obj != null) && (obj instanceof Resource)) { StringWriter buffer = new StringWriter(); InputStream is = ((Resource) obj).streamContent(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } } catch (NamingException e) { if (debug > 10) log("readme '" + readmeFile + "' not found", e); return null; } } return null; }
reader.close(); } catch (Exception e) { log("DefaultServlet.copy: exception closing reader: " + e.getMessage());
/** * Get the readme file as a string. */ protected String getReadme(WebResource directory) { if (readmeFile != null) { WebResource resource = resources.getResource( directory.getWebappPath() + readmeFile); if (resource.isFile()) { StringWriter buffer = new StringWriter(); InputStream is = resource.getInputStream(); copyRange(new InputStreamReader(is), new PrintWriter(buffer)); return buffer.toString(); } else { if (debug > 10) log("readme '" + readmeFile + "' not found"); return null; } } return null; }