Package com.day.cq.rewriter.linkchecker
Class LinkCheckerSettings
- java.lang.Object
-
- com.day.cq.rewriter.linkchecker.LinkCheckerSettings
-
public class LinkCheckerSettings extends java.lang.Object
Settings that control the behaviour of theLinkChecker
. The settings are used as a "linkchecker context" that holds the base-ref and context uri, and to control the actual rewrite behavior. If "request" is not attached, they are used merely temporary before the actual linkchecker is initialized.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REQUEST_ATTRIBUTE_NAME
the name of the request attribute
-
Constructor Summary
Constructors Constructor Description LinkCheckerSettings()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LinkCheckerSettings
fromRequest(SlingHttpServletRequest request)
Returns the current link checker settings for the current request.java.lang.String
getBaseRef()
Get the current base ref.java.net.URI
getBaseURI()
Returns the base URI of the request associated with the given settings.java.lang.String
getContextPath()
Returns the context pathjava.net.URI
getContextURI()
Returns the context URI of the web application associated with the given settings.LinkRewriteConfig
getExpiredConfig()
Returns the config for expired linksLinkRewriteConfig
getInvalidConfig()
Returns the config for invalid linksjava.lang.String
getParentRequestURI()
Return a uri to the parent of the current uri.LinkRewriteConfig
getPredatedConfig()
Returns the config for predated linksSlingHttpServletRequest
getRequest()
java.lang.String
getRequestURI()
Get the current request uri.ResourceResolver
getResourceResolver()
Returns the resource resolvervoid
init(SlingHttpServletRequest request)
Attach the settings to the request.boolean
isIgnoreExternals()
Iftrue
, external links are not checkedboolean
isIgnoreInternals()
Iftrue
internal links are not checkedvoid
setBaseRef(java.lang.String baseRef)
Set the current base ref.void
setExpiredConfig(LinkRewriteConfig config)
Sets the config for expired linksboolean
setIgnoreExternals(boolean ignoreExternals)
Controls if external links should be checked by the linkchecker.boolean
setIgnoreInternals(boolean ignoreInternals)
Controls if internal links should be checked by the linkchecker.void
setInvalidConfig(LinkRewriteConfig config)
Sets the config for invalid linksvoid
setPredatedConfig(LinkRewriteConfig config)
Sets the config for predated links
-
-
-
Method Detail
-
fromRequest
public static LinkCheckerSettings fromRequest(SlingHttpServletRequest request)
Returns the current link checker settings for the current request.- Parameters:
request
- the request- Returns:
- the settings or
null
-
init
public void init(SlingHttpServletRequest request)
Attach the settings to the request.- Parameters:
request
- The current request
-
getRequest
public SlingHttpServletRequest getRequest()
-
getResourceResolver
public ResourceResolver getResourceResolver()
Returns the resource resolver- Returns:
- the resource resolver
-
getContextPath
public java.lang.String getContextPath()
Returns the context path- Returns:
- the context path
-
getContextURI
public java.net.URI getContextURI()
Returns the context URI of the web application associated with the given settings.- Returns:
- context URI, or
null
if the URI malformed - Since:
- 5.3
-
getInvalidConfig
public LinkRewriteConfig getInvalidConfig()
Returns the config for invalid links- Returns:
- the config for invalid links
-
setInvalidConfig
public void setInvalidConfig(LinkRewriteConfig config)
Sets the config for invalid links- Parameters:
config
- the config
-
getExpiredConfig
public LinkRewriteConfig getExpiredConfig()
Returns the config for expired links- Returns:
- the config for expired links
-
setExpiredConfig
public void setExpiredConfig(LinkRewriteConfig config)
Sets the config for expired links- Parameters:
config
- the config
-
getPredatedConfig
public LinkRewriteConfig getPredatedConfig()
Returns the config for predated links- Returns:
- the config
-
setPredatedConfig
public void setPredatedConfig(LinkRewriteConfig config)
Sets the config for predated links- Parameters:
config
- the config
-
getRequestURI
public java.lang.String getRequestURI()
Get the current request uri.- Returns:
- the request uri
-
getParentRequestURI
public java.lang.String getParentRequestURI()
Return a uri to the parent of the current uri.- Returns:
- the parent uri or an empty string
-
getBaseRef
public java.lang.String getBaseRef()
Get the current base ref.- Returns:
- the base href
-
getBaseURI
public java.net.URI getBaseURI()
Returns the base URI of the request associated with the given settings.- Returns:
- base URI, or
null
if the URI malformed - Since:
- 5.3
-
setBaseRef
public void setBaseRef(java.lang.String baseRef)
Set the current base ref.- Parameters:
baseRef
- the base href
-
isIgnoreInternals
public boolean isIgnoreInternals()
Iftrue
internal links are not checked- Returns:
true
if internal links are not checked
-
setIgnoreInternals
public boolean setIgnoreInternals(boolean ignoreInternals)
Controls if internal links should be checked by the linkchecker. If set totrue
all internal links are treated as 'valid'. Please note that the settings are directly used by the linkchecker transformer and are respected on a "startElement" event. When altered on-the-fly in a JSP don't forget to flush the writer before changing the value.- Parameters:
ignoreInternals
- iftrue
internal links are not checked- Returns:
- previous value
-
isIgnoreExternals
public boolean isIgnoreExternals()
Iftrue
, external links are not checked- Returns:
true
if external links are not checked
-
setIgnoreExternals
public boolean setIgnoreExternals(boolean ignoreExternals)
Controls if external links should be checked by the linkchecker. If set totrue
all external links are treated as 'valid' and they are also not recorded in the external-link storage. Please note that the settings are directly used by the linkchecker transformer and are respected on a "startElement" event. When altered on-the-fly in a JSP don't forget to flush the writer before changing the value.- Parameters:
ignoreExternals
- iftrue
external links are not checked- Returns:
- previous value
-
-