Search in sources :

Example 1 with SitemapUrl

use of org.nextprot.api.web.seo.domain.SitemapUrl in project nextprot-api by calipho-sib.

the class SitemapTest method testSitemapUrlSetCreation.

@Test
public void testSitemapUrlSetCreation() {
    String base = "https://search.nextprot.org";
    SitemapUrlSet urlSet = new SitemapUrlSet();
    urlSet.add(new SitemapUrl(base + "/about"));
    urlSet.add(new SitemapUrl(base + "/copyright"));
    urlSet.add(new SitemapUrl(base + "/news"));
    urlSet.add(new SitemapUrl(base + "/help"));
    urlSet.add(new SitemapUrl(base + "/copyright"));
    urlSet.add(new SitemapUrl(base + "/help/simple-search"));
    // for (SitemapUrl siturl : urlSet.getUrls()) System.out.println(siturl.getLoc());
    Assert.assertEquals(5, urlSet.getUrls().size());
}
Also used : SitemapUrl(org.nextprot.api.web.seo.domain.SitemapUrl) SitemapUrlSet(org.nextprot.api.web.seo.domain.SitemapUrlSet) Test(org.junit.Test)

Example 2 with SitemapUrl

use of org.nextprot.api.web.seo.domain.SitemapUrl in project nextprot-api by calipho-sib.

the class SitemapTest method testSitemapUrlCreation.

@Test
public void testSitemapUrlCreation() {
    String url = "http://aaa.bbb.com/toto";
    SitemapUrl siturl = new SitemapUrl(url);
    String expectedDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    // System.out.println("expectedDate: " + expectedDate);
    Assert.assertEquals(url, siturl.getLoc());
    Assert.assertEquals(expectedDate, siturl.getLastmod());
    Assert.assertEquals("weekly", siturl.getChangefreq());
    Assert.assertEquals("0.5", siturl.getPriority());
}
Also used : SitemapUrl(org.nextprot.api.web.seo.domain.SitemapUrl) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 3 with SitemapUrl

use of org.nextprot.api.web.seo.domain.SitemapUrl in project nextprot-api by calipho-sib.

the class SitemapTest method test1.

@Test
public void test1() {
    try {
        String base = "https://search.nextprot.org";
        SitemapUrlSet urlSet = new SitemapUrlSet();
        urlSet.add(new SitemapUrl(base + "/about"));
        urlSet.add(new SitemapUrl(base + "/copyright"));
        urlSet.add(new SitemapUrl(base + "/news"));
        JAXBContext jaxbContext = JAXBContext.newInstance(SitemapUrlSet.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    // jaxbMarshaller.marshal(urlSet, System.out);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}
Also used : SitemapUrl(org.nextprot.api.web.seo.domain.SitemapUrl) Marshaller(javax.xml.bind.Marshaller) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) SitemapUrlSet(org.nextprot.api.web.seo.domain.SitemapUrlSet) Test(org.junit.Test)

Example 4 with SitemapUrl

use of org.nextprot.api.web.seo.domain.SitemapUrl in project nextprot-api by calipho-sib.

the class SitemapServiceImpl method getSitemapUrlSet.

@Override
public SitemapUrlSet getSitemapUrlSet() {
    // TODO set this elsewhere !
    String base = "https://www.nextprot.org";
    SitemapUrlSet urlSet = new SitemapUrlSet();
    // news urls
    for (NextProtNews n : githubService.getNews()) {
        urlSet.add(new SitemapUrl(base + "/news/" + n.getUrl()));
    }
    // other application urls (help, about, home, portals, ...)
    for (SeoTagsAndUrl tag : seoTagService.getGitHubSeoTags()) {
        // blocked by robots.txt, thus removed from sitemap
        if ("/user/proteins/lists".equals(tag.getUrl()))
            continue;
        // blocked by robots.txt, thus removed from sitemap
        if ("/user/queries".equals(tag.getUrl()))
            continue;
        urlSet.add(new SitemapUrl(base + tag.getUrl()));
    }
    // entry function urls
    Set<String> acs = masterIdentifierService.findUniqueNames();
    for (String ac : acs) {
        urlSet.add(new SitemapUrl(base + "/entry/" + ac));
    }
    return urlSet;
}
Also used : SitemapUrl(org.nextprot.api.web.seo.domain.SitemapUrl) SeoTagsAndUrl(org.nextprot.api.web.seo.domain.SeoTagsAndUrl) NextProtNews(org.nextprot.api.web.domain.NextProtNews) SitemapUrlSet(org.nextprot.api.web.seo.domain.SitemapUrlSet)

Aggregations

SitemapUrl (org.nextprot.api.web.seo.domain.SitemapUrl)4 Test (org.junit.Test)3 SitemapUrlSet (org.nextprot.api.web.seo.domain.SitemapUrlSet)3 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 NextProtNews (org.nextprot.api.web.domain.NextProtNews)1 SeoTagsAndUrl (org.nextprot.api.web.seo.domain.SeoTagsAndUrl)1