Project

General

Profile

« Previous | Next » 

Revision 7766

Added by Matt Jones over 11 years ago

Updated documentation, and added modification date to the sitemap index file entries.

View differences:

src/edu/ucsb/nceas/metacat/Sitemap.java
33 33
import java.sql.PreparedStatement;
34 34
import java.sql.ResultSet;
35 35
import java.sql.SQLException;
36
import java.text.SimpleDateFormat;
37
import java.util.Date;
36 38
import java.util.TimerTask;
37 39

  
38 40
import org.apache.log4j.Logger;
......
83 85
    /**
84 86
     * Generate all of the sitemap files needed to list the URLs from this
85 87
     * instance of Metacat, using the open sitemap format described here:
86
     * 
88
     *   http://www.sitemaps.org/protocol.html
87 89
     * URLs are written to a single file, unless the maximum number of URLs
88
     * allowed inthe sitemap file is exceeded, in which subsequent numbered
89
     * files are created.
90
     * allowed in the sitemap file is exceeded, in which subsequent numbered
91
     * files are created. An index of the sitemaps is also created.
90 92
     * 
93
     * The sitemap index can be registered with search index providers such as
94
     * Google, but beware that it needs to be accessible in a location above the
95
     * mount point for the service URLs.  By default the files are placed in 
96
     * {context}/sitemaps, but you will need to expose them at {context}/ for
97
     * them to be trusted by Google.  See the Sitemaps.org documentation for
98
     * details.
99
     * 
91 100
     * @param directory
92 101
     *            an existing File directory in which to write the sitemaps
93 102
     * @param urlRoot
......
324 333
            sitemapIndex.write("<sitemap><loc>");
325 334
            sitemapIndex.write(url.toString());
326 335
            sitemapIndex.write("</loc>");
336
            Date now = new Date();
337
            SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
338
            sitemapIndex.write("<lastmod>"+ fmt.format(now) +"</lastmod>");
327 339
            sitemapIndex.write("</sitemap>");
328 340
            sitemapIndex.write("\n");
329 341
            sitemapIndex.flush();

Also available in: Unified diff