org.dspace.app.sitemap
Class HTMLSitemapGenerator

java.lang.Object
  extended by org.dspace.app.sitemap.AbstractGenerator
      extended by org.dspace.app.sitemap.HTMLSitemapGenerator

public class HTMLSitemapGenerator
extends AbstractGenerator

Class for generating HTML "sitemaps" which contain links to various pages in a DSpace site. This should improve search engine coverage of the DSpace site and limit the server load caused by crawlers.

Author:
Robert Tansley, Stuart Lewis

Field Summary
 
Fields inherited from class org.dspace.app.sitemap.AbstractGenerator
bytesWritten, currentOutput, fileCount, outputDir, urlsWritten
 
Constructor Summary
HTMLSitemapGenerator(File outputDirIn, String urlStem, String urlTail)
          Construct an HTML sitemap generator, writing files to the given directory, and with the sitemaps eventually exposed at starting with the given URL stem and tail.
 
Method Summary
 String getFilename(int number)
          Return the filename a sitemap at the given index should be stored at.
 String getIndexFilename()
          Get the filename the index should be written to.
 String getLeadingBoilerPlate()
          Return the boilerplate at the top of a sitemap file.
 int getMaxSize()
          Return the maximum size in bytes that an individual sitemap file should be.
 int getMaxURLs()
          Return the maximum number of URLs that an individual sitemap file should contain.
 String getTrailingBoilerPlate()
          Return the boilerplate at the end of a sitemap file.
 String getURLText(String url, Date lastMod)
          Return marked-up text to be included in a sitemap about a given URL.
 boolean useCompression()
          Return whether the written sitemap files and index should be GZIP-compressed.
 void writeIndex(PrintStream output, int sitemapCount)
          Write the index file.
 
Methods inherited from class org.dspace.app.sitemap.AbstractGenerator
addURL, closeCurrentFile, finish, startNewFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLSitemapGenerator

public HTMLSitemapGenerator(File outputDirIn,
                            String urlStem,
                            String urlTail)
Construct an HTML sitemap generator, writing files to the given directory, and with the sitemaps eventually exposed at starting with the given URL stem and tail.

Parameters:
outputDirIn - Directory to write sitemap files to
urlStem - start of URL that sitemap files will appear at, e.g. http://dspace.myu.edu/sitemap?sitemap=
urlTail - end of URL that sitemap files will appear at, e.g. .html or null
Method Detail

getFilename

public String getFilename(int number)
Description copied from class: AbstractGenerator
Return the filename a sitemap at the given index should be stored at.

Specified by:
getFilename in class AbstractGenerator
Parameters:
number - index of the sitemap file (zero is first).
Returns:
the filename to write the sitemap to.

getLeadingBoilerPlate

public String getLeadingBoilerPlate()
Description copied from class: AbstractGenerator
Return the boilerplate at the top of a sitemap file.

Specified by:
getLeadingBoilerPlate in class AbstractGenerator
Returns:
The boilerplate markup.

getMaxSize

public int getMaxSize()
Description copied from class: AbstractGenerator
Return the maximum size in bytes that an individual sitemap file should be.

Specified by:
getMaxSize in class AbstractGenerator
Returns:
the size in bytes.

getMaxURLs

public int getMaxURLs()
Description copied from class: AbstractGenerator
Return the maximum number of URLs that an individual sitemap file should contain.

Specified by:
getMaxURLs in class AbstractGenerator
Returns:
the maximum number of URLs.

getTrailingBoilerPlate

public String getTrailingBoilerPlate()
Description copied from class: AbstractGenerator
Return the boilerplate at the end of a sitemap file.

Specified by:
getTrailingBoilerPlate in class AbstractGenerator
Returns:
The boilerplate markup.

getURLText

public String getURLText(String url,
                         Date lastMod)
Description copied from class: AbstractGenerator
Return marked-up text to be included in a sitemap about a given URL.

Specified by:
getURLText in class AbstractGenerator
Parameters:
url - URL to add information about
lastMod - date URL was last modified, or null if unknown or not applicable
Returns:
the mark-up to include

useCompression

public boolean useCompression()
Description copied from class: AbstractGenerator
Return whether the written sitemap files and index should be GZIP-compressed.

Specified by:
useCompression in class AbstractGenerator
Returns:
true if GZIP compression should be used, false otherwise.

getIndexFilename

public String getIndexFilename()
Description copied from class: AbstractGenerator
Get the filename the index should be written to.

Specified by:
getIndexFilename in class AbstractGenerator
Returns:
the filename of the index.

writeIndex

public void writeIndex(PrintStream output,
                       int sitemapCount)
                throws IOException
Description copied from class: AbstractGenerator
Write the index file.

Specified by:
writeIndex in class AbstractGenerator
Parameters:
output - stream to write the index to
sitemapCount - number of sitemaps that were generated
Throws:
IOException - if an IO error occurs


Copyright © 2010 DuraSpace. All Rights Reserved.