use of com.redfin.sitemapgenerator.WebSitemapUrl in project eol-globi-data by jhpoelen.
the class SiteMapUtils method generateSiteMapFor.
public static List<File> generateSiteMapFor(String queryParamName, Set<String> queryParamValues, File baseDir, String siteMapLocation) throws IOException {
final String hostname = "www.globalbioticinteractions.org";
final String baseUrl = "http://" + hostname;
WebSitemapGenerator wsg = WebSitemapGenerator.builder(baseUrl, baseDir).gzip(true).build();
for (String accordingTo : queryParamValues) {
URI uri;
try {
uri = new URI("http", hostname, "/", queryParamName + accordingTo, null);
} catch (URISyntaxException e) {
throw new IOException("unexpected malformed uri", e);
}
WebSitemapUrl url = new WebSitemapUrl.Options(StringEscapeUtils.escapeXml10(uri.toString())).lastMod(new Date()).priority(1.0).changeFreq(ChangeFreq.WEEKLY).build();
wsg.addUrl(url);
}
final List<File> maps = wsg.write();
File outFile = new File(baseDir, "sitemap_index.xml");
SitemapIndexGenerator sig = (new SitemapIndexGenerator.Options(siteMapLocation, outFile)).build();
if (maps.size() > 1) {
sig.addUrls(siteMapLocation + "sitemap", ".xml.gz", maps.size()).write();
} else {
sig.addUrl(siteMapLocation + "sitemap.xml.gz");
}
sig.write();
return maps;
}
Aggregations