Commit 56a75925 authored by Matija Obreza's avatar Matija Obreza
Browse files

Sitemap: Updated frequencies and priorities

- Included /content/news list page
- Included /partners list page
- Included /c list page
parent 90ca0877
......@@ -178,12 +178,13 @@ public class SitemapXMLController {
};
private final SitemapPage[] sitemapContentPages = new SitemapPage[] {
new SitemapPage("/", Frequency.DAILY, 1.0),
new SitemapPage("/content/about/about", 1.0),
new SitemapPage("/content/legal/terms", 1.0),
new SitemapPage("/content/legal/disclaimer", 0.6),
new SitemapPage("/documentation/apis", 0.7),
new SitemapPage("/documentation/brapi", 0.7)
new SitemapPage("/", Frequency.WEEKLY, 1.0),
new SitemapPage("/content/news", Frequency.WEEKLY, 0.8),
new SitemapPage("/content/about/about", Frequency.YEARLY, 0.7),
new SitemapPage("/content/legal/terms", Frequency.YEARLY, 0.2),
new SitemapPage("/content/legal/disclaimer", Frequency.YEARLY, 0.2),
new SitemapPage("/documentation/apis", Frequency.YEARLY, 0.1),
new SitemapPage("/documentation/brapi", Frequency.YEARLY, 0.1)
};
@RequestMapping(value = "/sitemap.xml", method = RequestMethod.GET, produces = { MediaType.TEXT_XML_VALUE })
......@@ -213,7 +214,7 @@ public class SitemapXMLController {
taxonomyService.getAllGenera().stream().filter(g -> g.matches("^[a-zA-Z]+$")).forEach(genus -> {
try {
writePage(response, sb, "/t/" + genus, Frequency.WEEKLY, 0.4, null);
writePage(response, sb, "/t/" + genus, Frequency.YEARLY, 0.1, null);
sb.flush();
} catch (IOException e) {
LOG.warn(e.getMessage());
......@@ -237,6 +238,8 @@ public class SitemapXMLController {
for (ActivityPost ap : activityPosts) {
String slug = jspHelper.suggestUrlForText(ap.getTitle());
SitemapPage sm = new SitemapPage("/content/news/" + ap.getId() + "/" + slug, ap.getLastModifiedDate());
sm.priority = 0.7;
sm.freq = Frequency.YEARLY;
list.add(sm);
}
......@@ -253,7 +256,7 @@ public class SitemapXMLController {
List<VocabularyTerm> vt = geoService.list3166Alpha3Terms(PageRequest.of(0, Integer.MAX_VALUE, Sort.Direction.ASC, "code3")).getContent();
for (VocabularyTerm term : vt) {
writePage(response, sb, "/iso3166/" + term.getCode().toUpperCase(), Frequency.WEEKLY, null, null);
writePage(response, sb, "/iso3166/" + term.getCode().toUpperCase(), Frequency.YEARLY, 0.4, null);
}
sb.append("</urlset>");
......@@ -274,9 +277,11 @@ public class SitemapXMLController {
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.append("<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
writePage(response, sb, "/partners", Frequency.MONTHLY, 0.7, null);
List<Partner> partners = partnerService.list(new PartnerFilter(), PageRequest.of(0, Integer.MAX_VALUE, Sort.Direction.ASC, "id")).getContent();
for (Partner partner : partners) {
writePage(response, sb, "/partners/" + partner.getUuid(), Frequency.WEEKLY, 1.0, partner.getLastModifiedDate());
writePage(response, sb, "/partners/" + partner.getUuid(), Frequency.YEARLY, 0.6, partner.getLastModifiedDate());
}
sb.append("</urlset>");
......@@ -304,7 +309,7 @@ public class SitemapXMLController {
subsets = Collections.emptyList();
}
for (Subset subset : subsets) {
writePage(response, sb, "/subsets/" + subset.getUuid(), Frequency.MONTHLY, 0.8, subset.getLastModifiedDate());
writePage(response, sb, "/subsets/" + subset.getUuid(), Frequency.YEARLY, 0.5, subset.getLastModifiedDate());
}
sb.append("</urlset>");
......@@ -332,7 +337,7 @@ public class SitemapXMLController {
datasets = Collections.emptyList();
}
for (Dataset dataset : datasets) {
writePage(response, sb, "/datasets/" + dataset.getUuid(), Frequency.MONTHLY, 0.8, dataset.getLastModifiedDate());
writePage(response, sb, "/datasets/" + dataset.getUuid(), Frequency.YEARLY, 0.5, dataset.getLastModifiedDate());
}
sb.append("</urlset>");
......@@ -360,7 +365,7 @@ public class SitemapXMLController {
descriptorLists = Collections.emptyList();
}
for (DescriptorList descriptorList : descriptorLists) {
writePage(response, sb, "/descriptorlists/" + descriptorList.getUuid(), Frequency.MONTHLY, 0.8, descriptorList.getLastModifiedDate());
writePage(response, sb, "/descriptorlists/" + descriptorList.getUuid(), Frequency.YEARLY, 0.5, descriptorList.getLastModifiedDate());
}
sb.append("</urlset>");
......@@ -406,7 +411,7 @@ public class SitemapXMLController {
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.append("<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
writePage(response, sb, "/wiews/" + faoInstitute.getCode(), Frequency.MONTHLY, 1.0, null);
writePage(response, sb, "/wiews/" + faoInstitute.getCode(), Frequency.YEARLY, 0.6, null);
// Create JSON filter
AccessionFilter instituteFilter = new AccessionFilter();
......@@ -416,9 +421,9 @@ public class SitemapXMLController {
accessionProcessor.process(instituteFilter, (accessions) -> {
for (Accession accession: accessions) {
if (accession.getDoi() != null) {
writePage(response, sb, "/" + accession.getDoi(), null, 0.9, accession.getLastModifiedDate());
writePage(response, sb, "/" + accession.getDoi(), Frequency.YEARLY, 0.2, accession.getLastModifiedDate());
} else {
writePage(response, sb, "/a/" + accession.getUuid(), null, 0.8, accession.getLastModifiedDate());
writePage(response, sb, "/a/" + accession.getUuid(), Frequency.YEARLY, 0.2, accession.getLastModifiedDate());
}
}
sb.flush();
......@@ -444,8 +449,10 @@ public class SitemapXMLController {
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.append("<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
writePage(response, sb, "/c", Frequency.MONTHLY, 0.6, null);
for (Crop crop : cropService.listCrops()) {
writePage(response, sb, "/c/" + crop.getShortName(), Frequency.WEEKLY, 1.0, null);
writePage(response, sb, "/c/" + crop.getShortName(), Frequency.MONTHLY, 0.5, null);
}
sb.append("</urlset>");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment