public class StaticSitemapGenerator extends GenericService implements SitemapGenerator
staticPages
This is an example of what will be generated:
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://www.example.com/</loc> <changefreq>monthly</changefreq> <priority>0.8</priority> </url> </urlset>
The available tags are described below:
For additional information see Sitemap protocol
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
CHANGE_FREQUENCY_VALUES |
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
COLON
Valid value for change frequency.
|
static java.lang.String |
SITEMAP_FOOTER |
SERVICE_INFO_KEY
MAX_SITEMAPS, MAX_SIZE, MAX_URLS, NUCLEUS_SERVLET_PATH
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
StaticSitemapGenerator() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addURLToSitemap(SitemapGeneratorService pSitemapGeneratorService,
java.lang.StringBuilder pSitemap,
java.lang.String pUrlXml,
int pUrlCount,
int pSitemapCount)
Adds sitemap URL xml to sitemap.
|
java.lang.String |
cutServletPathFromSitemapURL(java.lang.String sitemapURL)
Cut servlet path from the generated sitemap URL.
|
void |
findAllMatchedFiles(java.io.File pDir,
java.lang.String pRegExp,
java.util.List<java.lang.String> pMatchedFiles)
Recursively goes through all files in specified directory including subdirectories and
finds all files which names match a given regular expression.
|
void |
generateSitemap(SitemapGeneratorService pSitemapGeneratorService)
This method will generate sitemap from list of pages in
staticPages |
protected void |
generateSitemapUrls(SitemapGeneratorService pSitemapGeneratorService,
java.util.List<java.lang.String> pages,
java.lang.String pSiteId)
Generates sitemap URLs for given list of static pages and given site.
|
java.lang.String |
getChangeFrequency()
Returns how frequently the page is likely to change.
|
java.lang.String |
getChangeFrequencyForPage(java.lang.String pEntry)
Returns change frequency for specified page.
|
java.lang.String |
getLocationForPage(java.lang.String pPageURL)
Gets fully specified sitemap URL for a given relative page.
|
java.lang.String |
getLocationForPage(java.lang.String pPageURL,
java.lang.String pSiteId,
SitemapGeneratorService pSitemapGeneratorService)
Gets fully specified sitemap URL for a given page and site.
|
java.util.List<java.lang.String> |
getMatchedFiles(java.io.File pDir,
java.lang.String pRegExp)
Gets all files in directory including subdirectories which names match
given regular expression.
|
java.lang.String |
getPageURL(java.lang.String pEntry)
Returns relative page URL.
|
java.lang.String |
getParametersForPage(java.lang.String pEntry)
Returns parameters string for page in format: :
|
java.lang.Float |
getPriority()
Returns the priority of URL relative to other URLs on site.
|
java.lang.Float |
getPriorityForPage(java.lang.String pEntry)
Returns priority for specified page.
|
java.lang.String |
getRegularExprForPattern(java.lang.String pPagePattern)
Converts page pattern used in component configuration to java regular
expression.
|
java.util.List<java.lang.String> |
getResolvedStaticPages()
Takes configured list of static pages, which can be either actual pages or page patterns
with wildcards, and replaces pages that are using
wildcards with corresponding matching pages.
|
java.lang.String |
getSitemapFilePrefix()
Returns Sitemap file prefix.
|
java.util.List<java.lang.String> |
getStaticPages()
Returns list of static pages which generator will use to build sitemap
|
java.lang.String |
getUrlPrefix()
Returns URL prefix to the application with protocol, host, port
|
java.lang.String |
getWarDir()
Returns path where applications's war is located.
|
WebApp |
getWebApp()
Returns representation of web application in
WebApp . |
boolean |
isChangeFrequencyValid(java.lang.String pChangeFrequency)
Checks that change frequency is from list of valid values.
|
boolean |
isNeedServletPathOnSitemapURL() |
boolean |
isPriorityValid(java.lang.Float pPriority)
Checks that priority is from 0.0 to 1.0 range.
|
java.util.List<java.lang.String> |
resolvePagePattern(java.lang.String pPagePattern)
Returns list of pages that match a given pattern.
|
void |
setChangeFrequency(java.lang.String pChangeFrequency)
Sets how frequently the page is likely to change.
|
void |
setNeedServletPathOnSitemapURL(boolean pNeedServletPathOnSitemapURL)
Sets NeedServletPathOnSitemapURL value.
|
void |
setPriority(java.lang.Float pPriority)
Sets the priority of URL relative to other URLs on site.
|
void |
setSitemapFilePrefix(java.lang.String pSitemapFilePrefix)
Sets Sitemap file prefix.
|
void |
setStaticPages(java.util.List<java.lang.String> pStaticPages)
Sets new list of static pages which generator will use to build sitemap
|
void |
setUrlPrefix(java.lang.String pUrlPrefix)
Sets new URL prefix to the application with protocol, host, port
|
void |
setWarDir(java.lang.String pWarDir)
Sets new path where to war directory.
|
void |
setWebApp(WebApp pWebApp)
Sets new WebApp component.
|
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
public static final java.lang.String COLON
public static final java.lang.String SITEMAP_FOOTER
public static final java.lang.String[] CHANGE_FREQUENCY_VALUES
public java.lang.String getChangeFrequency()
public void setChangeFrequency(java.lang.String pChangeFrequency)
pChangeFrequency
- how frequently the page is likely to change.public java.lang.Float getPriority()
public void setPriority(java.lang.Float pPriority)
pPriority
- the priority of URL relative to other URLs on site.public java.lang.String getSitemapFilePrefix()
public void setSitemapFilePrefix(java.lang.String pSitemapFilePrefix)
SitemapFilePrefix
- the Sitemap file prefixpublic java.lang.String getWarDir()
public void setWarDir(java.lang.String pWarDir)
WarDir
- directory where application's war is located.public java.util.List<java.lang.String> getStaticPages()
public void setStaticPages(java.util.List<java.lang.String> pStaticPages)
StaticPages
- the List of static pagespublic java.lang.String getUrlPrefix()
public void setUrlPrefix(java.lang.String pUrlPrefix)
UrlPrefix
- new URL prefix to the application with protocol, host, portpublic WebApp getWebApp()
WebApp
.public void setWebApp(WebApp pWebApp)
WebApp
- new WebApp componentpublic boolean isNeedServletPathOnSitemapURL()
public void setNeedServletPathOnSitemapURL(boolean pNeedServletPathOnSitemapURL)
pNeedServletPathOnSitemapURL
- the boolean value to setpublic java.util.List<java.lang.String> getResolvedStaticPages()
public java.util.List<java.lang.String> resolvePagePattern(java.lang.String pPagePattern)
pPagePattern
doesn't contains wildCards
returns pPagePattern
without changes, if it contains
wildcards like * and ? then it resolves this pattern to actual list of pages.
During resolving pattern with wildcards to actual list of pages it
looks for matched files in the file system directory where applications's
war is located.
E.g., if pPagePattern
equals "company/*.jsp" the returned list of
pages will contain all pages under pPagePattern
equals "company/** /*.jsp" the returned list of
pages will contain all pages under pPagePattern
equals "company/news??.jsp" this will match such pages
like "company/news01.jsp", "company/news02.jsp", etc.pPagePattern
- page name patternpublic java.lang.String getRegularExprForPattern(java.lang.String pPagePattern)
pPagePattern
- page patternpublic void findAllMatchedFiles(java.io.File pDir, java.lang.String pRegExp, java.util.List<java.lang.String> pMatchedFiles)
matchedFiles
listpDir
- directory to be searched for matching filespRegExp
- regular expressionpMatchedFiles
- list to that matched files should be addedpublic java.util.List<java.lang.String> getMatchedFiles(java.io.File pDir, java.lang.String pRegExp)
pDir
- directory to be searched for matching filespRegExp
- regular expressionpublic java.lang.String getChangeFrequencyForPage(java.lang.String pEntry)
pEntry
- relative URL parameter in format public boolean isChangeFrequencyValid(java.lang.String pChangeFrequency)
pChangeFrequency
- change frequencypublic java.lang.Float getPriorityForPage(java.lang.String pEntry)
pEntry
- page's relative URL with parameters in format public boolean isPriorityValid(java.lang.Float pPriority)
pPriority
- prioritypublic java.lang.String getPageURL(java.lang.String pEntry)
pEntry
- relative URL parameter in format public java.lang.String getLocationForPage(java.lang.String pPageURL)
pPageURL
- page's relative URLpublic java.lang.String getLocationForPage(java.lang.String pPageURL, java.lang.String pSiteId, SitemapGeneratorService pSitemapGeneratorService)
urlPrefix
.
If site ID is specified then final URL is determined by SiteURLManager using
site configuration.pPageURL
- page's relative URLpSiteId
- site ID *public java.lang.String getParametersForPage(java.lang.String pEntry)
pEntry
- relative URL parameter in format public void generateSitemap(SitemapGeneratorService pSitemapGeneratorService)
staticPages
generateSitemap
in interface SitemapGenerator
protected void generateSitemapUrls(SitemapGeneratorService pSitemapGeneratorService, java.util.List<java.lang.String> pages, java.lang.String pSiteId)
pSitemapGeneratorService
- Sitemap Generator service.pages
- list of static pages.pSiteId
- site ID.protected boolean addURLToSitemap(SitemapGeneratorService pSitemapGeneratorService, java.lang.StringBuilder pSitemap, java.lang.String pUrlXml, int pUrlCount, int pSitemapCount)
pSitemapGeneratorService
- Sitemap Generator ServicepSitemap
- String builder containing generated sitemappUrlXml
- URL XML to be added to sitemappUrlCount
- current count of URLs in sitemappublic java.lang.String cutServletPathFromSitemapURL(java.lang.String sitemapURL)
sitemapURL
- String generated sitemap URL