public static List<Resource> getResources(URI uri) throws Exception { try (XMLResourceParser parser = new XMLResourceParser(uri)) { return parser.parse(); } }
public static List<Resource> getResources(File file) throws Exception { try (XMLResourceParser parser = new XMLResourceParser(file)) { return parser.parse(); } }
public static List<Resource> getResources(URI uri) throws Exception { try (XMLResourceParser parser = new XMLResourceParser(uri)) { return parser.parse(); } }
public static List<Resource> getResources(File file) throws Exception { try (XMLResourceParser parser = new XMLResourceParser(file)) { return parser.parse(); } }
private void parseReferral() throws Exception { if (--depth < 0) error("Too deep, traversed %s", traversed); else { String depthString = reader.getAttributeValue(null, ATTR_REFERRAL_DEPTH); String urlString = reader.getAttributeValue(null, ATTR_REFERRAL_URL); if (check(urlString != null, "Expected URL in referral")) { // TODO resolve url URI url = this.url.resolve(urlString); traversed.add(url); int depth = 100; if (depthString != null) { depth = Integer.parseInt(depthString); } InputStream in = url.toURL() .openStream(); try (XMLResourceParser referralParser = new XMLResourceParser(in, urlString, depth, traversed, url)) { referralParser.parse(); resources.addAll(referralParser.resources); } } } next(); tagEnd(TAG_REFERRAL); }
private Repository readRepository(File index) throws Exception { if (index.isFile()) { try (XMLResourceParser xp = new XMLResourceParser(index.toURI())) { List<Resource> resources = xp.parse(); if (urlHash.equals(xp.name())) { return new ResourcesRepository(resources); } } } return save(readRepository()); }
private Repository readRepository(File index) throws Exception { if (index.isFile()) { try (XMLResourceParser xp = new XMLResourceParser(index.toURI())) { List<Resource> resources = xp.parse(); if (urlHash.equals(xp.name())) { return new ResourcesRepository(resources); } } } return save(readRepository()); }
private Repository readRepository(File index) throws Exception { if (index.isFile()) { try (XMLResourceParser xp = new XMLResourceParser(index.toURI())) { List<Resource> resources = xp.parse(); if (urlHash.equals(xp.name())) { return new ResourcesRepository(resources); } } } return save(readRepository()); }
private Repository readRepository(File index) throws Exception { if (index.isFile()) { try (XMLResourceParser xp = new XMLResourceParser(index.toURI())) { List<Resource> resources = xp.parse(); if (urlHash.equals(xp.name())) { return new ResourcesRepository(resources); } } } return save(readRepository()); }
private void parseReferral() throws Exception { if (--depth < 0) error("Too deep, traversed %s", traversed); else { String depthString = reader.getAttributeValue(null, ATTR_REFERRAL_DEPTH); String urlString = reader.getAttributeValue(null, ATTR_REFERRAL_URL); if (check(urlString != null, "Expected URL in referral")) { // TODO resolve url URI url = this.url.resolve(urlString); traversed.add(url); int depth = 100; if (depthString != null) { depth = Integer.parseInt(depthString); } InputStream in = url.toURL() .openStream(); try (XMLResourceParser referralParser = new XMLResourceParser(in, urlString, depth, traversed, url)) { referralParser.parse(); resources.addAll(referralParser.resources); } } } next(); tagEnd(TAG_REFERRAL); }
private Promise<List<Resource>> download(URI uri, boolean refresh) { HttpRequest<File> req = client.build() .useCache(refresh ? -1 : staleTime); return req.async(uri) .map(file -> { if (file == null) { logger.debug("{}: No file downloaded for {}", name, uri); return Collections.emptyList(); } try (XMLResourceParser xmlp = new XMLResourceParser(IO.stream(file), name, uri)) { return xmlp.parse(); } }); }
private Promise<List<Resource>> download(URI uri, boolean refresh) { HttpRequest<File> req = client.build() .useCache(refresh ? -1 : staleTime); return req.async(uri) .map(file -> { if (file == null) { logger.debug("{}: No file downloaded for {}", name, uri); return Collections.emptyList(); } try (XMLResourceParser xmlp = new XMLResourceParser(IO.stream(file), name, uri)) { return xmlp.parse(); } }); }
void read() throws Exception { if (isStale()) { refresh(); } else { try (XMLResourceParser parser = new XMLResourceParser(getLocation())) { List<Resource> resources = parser.parse(); addAll(resources); } } }
void read() throws Exception { if (isStale()) { refresh(); } else { try (XMLResourceParser parser = new XMLResourceParser(getLocation())) { List<Resource> resources = parser.parse(); addAll(resources); } } }
void read() throws Exception { if (isStale()) { refresh(); } else { try (XMLResourceParser parser = new XMLResourceParser(getLocation())) { List<Resource> resources = parser.parse(); addAll(resources); } } }
void read() throws Exception { if (isStale()) { refresh(); } else { try (XMLResourceParser parser = new XMLResourceParser(getLocation())) { List<Resource> resources = parser.parse(); addAll(resources); } } }