Package org.dspace.app.sitemap
Class HTMLSitemapGenerator
java.lang.Object
org.dspace.app.sitemap.AbstractGenerator
org.dspace.app.sitemap.HTMLSitemapGenerator
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
FieldsModifier and TypeFieldDescriptionprotected StringStem of URLs sitemaps will eventually appear atprotected StringTail of URLs sitemaps will eventually appear atFields inherited from class org.dspace.app.sitemap.AbstractGenerator
bytesWritten, currentOutput, fileCount, outputDir, urlsWritten -
Constructor Summary
ConstructorsConstructorDescriptionHTMLSitemapGenerator(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
Modifier and TypeMethodDescriptiongetFilename(int number) Return the filename a sitemap at the given index should be stored at.Get the filename the index should be written to.Return the boilerplate at the top of a sitemap file.intReturn the maximum size in bytes that an individual sitemap file should be.intReturn the maximum number of URLs that an individual sitemap file should contain.Return the boilerplate at the end of a sitemap file.getURLText(String url, Instant lastMod) Return marked-up text to be included in a sitemap about a given URL.booleanReturn 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
-
Field Details
-
indexURLStem
Stem of URLs sitemaps will eventually appear at -
indexURLTail
Tail of URLs sitemaps will eventually appear at
-
-
Constructor Details
-
HTMLSitemapGenerator
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 Details
-
getFilename
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
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
Description copied from class:AbstractGeneratorReturn the boilerplate at the end of a sitemap file.- Specified by:
getTrailingBoilerPlatein classAbstractGenerator- Returns:
- The boilerplate markup.
-
getURLText
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
Description copied from class:AbstractGeneratorGet the filename the index should be written to.- Specified by:
getIndexFilenamein classAbstractGenerator- Returns:
- the filename of the index.
-
writeIndex
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
-