Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix up sitemap namespaces
  • Loading branch information
cbeer committed Mar 31, 2013
1 parent a5db1c7 commit 28016ae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Expand Up @@ -18,9 +18,11 @@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import static java.lang.Integer.parseInt;
import static javax.jcr.query.Query.JCR_SQL2;
import static javax.ws.rs.core.MediaType.TEXT_XML;
import static org.fcrepo.utils.FedoraJcrTypes.*;
import static org.slf4j.LoggerFactory.getLogger;

Expand All @@ -34,6 +36,7 @@ public class FedoraSitemap extends AbstractResource {
ObjectService objectService;

@GET
@Produces(TEXT_XML)
public SitemapIndex getSitemapIndex() throws RepositoryException {
final Session session = repo.login();
try {
Expand All @@ -53,12 +56,13 @@ public SitemapIndex getSitemapIndex() throws RepositoryException {

@GET
@Path("/{page}")
@Produces(TEXT_XML)
public SitemapUrlSet getSitemap(@PathParam("page") final String page) throws RepositoryException {
final Session session = repo.login();
try {
final SitemapUrlSet sitemapUrlSet = new SitemapUrlSet();

RowIterator rows = getSitemapEntries(session, parseInt(page));
RowIterator rows = getSitemapEntries(session, parseInt(page)-1);

while(rows.hasNext()) {
Row r = rows.nextRow();
Expand Down
Expand Up @@ -8,16 +8,16 @@

@XmlRootElement(name = "url", namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
public class SitemapEntry {
@XmlElement
@XmlElement(namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
private final URI loc;

@XmlElement
@XmlElement(namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
private final Calendar lastmod;

@XmlElement
@XmlElement(namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
private final String changefreq = "monthly";

@XmlElement
@XmlElement(namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
private final double priority = 0.8;

public SitemapEntry() {
Expand Down
Expand Up @@ -3,10 +3,12 @@

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;

@XmlRootElement(name = "sitemapindex", namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
@XmlType(namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
public class SitemapIndex {

private List<SitemapEntry> entries = new ArrayList<SitemapEntry>();
Expand All @@ -18,7 +20,7 @@ public void appendSitemapEntry(SitemapEntry e) {
entries.add(e);
}

@XmlElement(name = "sitemap")
@XmlElement(name = "sitemap", namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
public List<SitemapEntry> getSitemapEntries() {
return entries;
}
Expand Down
Expand Up @@ -3,14 +3,15 @@

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;

@XmlRootElement(name = "urlset", namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
public class SitemapUrlSet {


@XmlElement(name = "url")
@XmlElement(name = "url", namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")
private List<SitemapEntry> sitemapEntries = new ArrayList<SitemapEntry>();

public SitemapUrlSet() {
Expand Down

0 comments on commit 28016ae

Please sign in to comment.