protected List<URI> findXmlFileReferences(final String directoryContents, final URL url) throws URISyntaxException { final List<URI> results = new ArrayList<URI>(); final String[] filenames = directoryContents.split("\\n"); for (final String filename : filenames) { if (filename.endsWith(XML_EXTENSION)) { results.add(appendToURI(url, filename)); } } return results; }
protected List<URI> findXmlUrlReferences(final String directoryContents, final URL url) throws URISyntaxException { final List<URI> results = new ArrayList<URI>(); final List<String> urlFragments = extractHrefs(directoryContents); for (final String u : urlFragments) { if (u.endsWith(XML_EXTENSION)) { //points to xml if (u.startsWith("/")) { //absolute path need to add the protocol results.add(new URI(url.getProtocol() + ":" + u)); } else if (u.startsWith("http:")) { // full url results.add(new URI(u)); } else { // relative url stick the name on the end results.add(appendToURI(url, u)); } } } return results; }
@Test(groups = "fast") public void testAppendToURI() throws IOException, URISyntaxException { final URL u1 = new URL("http://www.ning.com/foo"); Assert.assertEquals(loader.appendToURI(u1, "bar").toString(), "http://www.ning.com/foo/bar"); final URL u2 = new URL("http://www.ning.com/foo/"); Assert.assertEquals(loader.appendToURI(u2, "bar").toString(), "http://www.ning.com/foo/bar"); }
protected List<URI> findXmlFileReferences(final String directoryContents, final URL url) throws URISyntaxException { final List<URI> results = new ArrayList<URI>(); final String[] filenames = directoryContents.split("\\n"); for (final String filename : filenames) { if (filename.endsWith(XML_EXTENSION)) { results.add(appendToURI(url, filename)); } } return results; }
protected List<URI> findXmlUrlReferences(final String directoryContents, final URL url) throws URISyntaxException { final List<URI> results = new ArrayList<URI>(); final List<String> urlFragments = extractHrefs(directoryContents); for (final String u : urlFragments) { if (u.endsWith(XML_EXTENSION)) { //points to xml if (u.startsWith("/")) { //absolute path need to add the protocol results.add(new URI(url.getProtocol() + ":" + u)); } else if (u.startsWith("http:")) { // full url results.add(new URI(u)); } else { // relative url stick the name on the end results.add(appendToURI(url, u)); } } } return results; }
@Test(groups = "fast") public void testAppendToURI() throws IOException, URISyntaxException { final URL u1 = new URL("http://www.ning.com/foo"); Assert.assertEquals(loader.appendToURI(u1, "bar").toString(), "http://www.ning.com/foo/bar"); final URL u2 = new URL("http://www.ning.com/foo/"); Assert.assertEquals(loader.appendToURI(u2, "bar").toString(), "http://www.ning.com/foo/bar"); }