public Void handleResponse(HttpResponse response) throws IOException { URI contentId = getContentId(localContext); HttpEntity entity = response.getEntity(); try { Header hd = entity.getContentType(); String type = null; if (hd != null) { type = hd.getValue(); } long lm = getLastModified(response); handler.list(contentId, type, lm); } catch (NumberFormatException e) { throw new IOException(e); } return null; } }, localContext);
public void listEachEntry(String href, String base, String accept, DataInfo handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); if ("file".equalsIgnoreCase(uri.getScheme())) { File file = URIUtils.toFile(uri); if (!file.canRead()) { throw XProcException.stepError(12); } if (file.isDirectory()) { for (File f : listAcceptableFiles(file, accept)) { String type; if (f.isDirectory()) { type = null; } else { type = getContentTypeFromName(f.getName()); } handler.list(f.toURI(), type, f.lastModified()); } } else { throw new FileNotFoundException(file.getAbsolutePath() + " is not a directory"); } } else { fallback.listEachEntry(href, base, accept, handler); } }
public void listEachEntry(String href, String base, String accept, DataInfo handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); if ("file".equalsIgnoreCase(uri.getScheme())) { File file = URIUtils.toFile(uri); if (!file.canRead()) { throw XProcException.stepError(12); } if (file.isDirectory()) { for (File f : listAcceptableFiles(file, accept)) { String type; if (f.isDirectory()) { type = null; } else { type = getContentTypeFromName(f.getName()); } handler.list(f.toURI(), type, f.lastModified()); } } else { throw new FileNotFoundException(file.getAbsolutePath() + " is not a directory"); } } else { fallback.listEachEntry(href, base, accept, handler); } }
public void infoEntry(String href, String base, String accept, DataInfo handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); if ("file".equalsIgnoreCase(uri.getScheme())) { File file = URIUtils.toFile(uri); String type; if (file.isFile()) { type = getContentTypeFromName(file.getName()); } else if (file.exists()) { type = null; } else { throw new FileNotFoundException(file.getAbsolutePath()); } handler.list(file.toURI(), type, file.lastModified()); } else { fallback.infoEntry(href, base, accept, handler); } }
public void infoEntry(String href, String base, String accept, DataInfo handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URI uri = baseURI.resolve(href); if ("file".equalsIgnoreCase(uri.getScheme())) { File file = URIUtils.toFile(uri); String type; if (file.isFile()) { type = getContentTypeFromName(file.getName()); } else if (file.exists()) { type = null; } else { throw new FileNotFoundException(file.getAbsolutePath()); } handler.list(file.toURI(), type, file.lastModified()); } else { fallback.infoEntry(href, base, accept, handler); } }
public Void handleResponse(HttpResponse response) throws IOException { URI contentId = getContentId(localContext); HttpEntity entity = response.getEntity(); try { Header hd = entity.getContentType(); String type = null; if (hd != null) { type = hd.getValue(); } long lm = getLastModified(response); handler.list(contentId, type, lm); } catch (NumberFormatException e) { throw new IOException(e); } return null; } }, localContext);
public void infoEntry(String href, String base, String accept, DataInfo handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URL url = baseURI.resolve(href).toURL(); URLConnection connection = url.openConnection(); connection.setRequestProperty("Accept", accept); final InputStream stream = connection.getInputStream(); try { String type = connection.getContentType(); URI id = URI.create(connection.getURL().toExternalForm()); handler.list(id, type, connection.getLastModified()); } finally { stream.close(); } }
public void infoEntry(String href, String base, String accept, DataInfo handler) throws MalformedURLException, FileNotFoundException, IOException { URI baseURI = URI.create(base); URL url = baseURI.resolve(href).toURL(); URLConnection connection = url.openConnection(); connection.setRequestProperty("Accept", accept); final InputStream stream = connection.getInputStream(); try { String type = connection.getContentType(); URI id = URI.create(connection.getURL().toExternalForm()); handler.list(id, type, connection.getLastModified()); } finally { stream.close(); } }