Package org.dspace.app.sitemap
Class HTMLSitemapGenerator
- java.lang.Object
-
- org.dspace.app.sitemap.AbstractGenerator
-
- 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 Modifier and Type Field Description protected StringindexURLStemStem of URLs sitemaps will eventually appear atprotected StringindexURLTailTail of URLs sitemaps will eventually appear at-
Fields inherited from class org.dspace.app.sitemap.AbstractGenerator
bytesWritten, currentOutput, fileCount, outputDir, urlsWritten
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetFilename(int number)Return the filename a sitemap at the given index should be stored at.StringgetIndexFilename()Get the filename the index should be written to.StringgetLeadingBoilerPlate()Return the boilerplate at the top of a sitemap file.intgetMaxSize()Return the maximum size in bytes that an individual sitemap file should be.intgetMaxURLs()Return the maximum number of URLs that an individual sitemap file should contain.StringgetTrailingBoilerPlate()Return the boilerplate at the end of a sitemap file.StringgetURLText(String url, Date lastMod)Return marked-up text to be included in a sitemap about a given URL.booleanuseCompression()Return whether the written sitemap files and index should be GZIP-compressed.voidwriteIndex(PrintStream output, int sitemapCount)Write the index file.-
Methods inherited from class org.dspace.app.sitemap.AbstractGenerator
addURL, closeCurrentFile, finish, startNewFile
-
-
-
-
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 tourlStem- 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..htmlornull
-
-
Method Detail
-
getFilename
public String getFilename(int number)
Description copied from class:AbstractGeneratorReturn the filename a sitemap at the given index should be stored at.- Specified by:
getFilenamein classAbstractGenerator- 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:AbstractGeneratorReturn the boilerplate at the top of a sitemap file.- Specified by:
getLeadingBoilerPlatein classAbstractGenerator- Returns:
- The boilerplate markup.
-
getMaxSize
public int getMaxSize()
Description copied from class:AbstractGeneratorReturn the maximum size in bytes that an individual sitemap file should be.- Specified by:
getMaxSizein classAbstractGenerator- Returns:
- the size in bytes.
-
getMaxURLs
public int getMaxURLs()
Description copied from class:AbstractGeneratorReturn the maximum number of URLs that an individual sitemap file should contain.- Specified by:
getMaxURLsin classAbstractGenerator- Returns:
- the maximum number of URLs.
-
getTrailingBoilerPlate
public String getTrailingBoilerPlate()
Description copied from class:AbstractGeneratorReturn the boilerplate at the end of a sitemap file.- Specified by:
getTrailingBoilerPlatein classAbstractGenerator- Returns:
- The boilerplate markup.
-
getURLText
public String getURLText(String url, Date lastMod)
Description copied from class:AbstractGeneratorReturn marked-up text to be included in a sitemap about a given URL.- Specified by:
getURLTextin classAbstractGenerator- Parameters:
url- URL to add information aboutlastMod- date URL was last modified, ornullif unknown or not applicable- Returns:
- the mark-up to include
-
useCompression
public boolean useCompression()
Description copied from class:AbstractGeneratorReturn whether the written sitemap files and index should be GZIP-compressed.- Specified by:
useCompressionin classAbstractGenerator- Returns:
trueif GZIP compression should be used,falseotherwise.
-
getIndexFilename
public String getIndexFilename()
Description copied from class:AbstractGeneratorGet the filename the index should be written to.- Specified by:
getIndexFilenamein classAbstractGenerator- Returns:
- the filename of the index.
-
writeIndex
public void writeIndex(PrintStream output, int sitemapCount) throws IOException
Description copied from class:AbstractGeneratorWrite the index file.- Specified by:
writeIndexin classAbstractGenerator- Parameters:
output- stream to write the index tositemapCount- number of sitemaps that were generated- Throws:
IOException- if IO error if an IO error occurs
-
-