Interface HstLinkCreator
-
- All Known Subinterfaces:
CompositeHstLinkCreator
public interface HstLinkCreator
HstLinkCreator interface for creatingHstLink
's
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clears possibly available cachesHstLink
create(String uuid, javax.jcr.Session session, HstRequestContext requestContext)
Rewrite a jcr uuid to a HstLink wrt its current ResolvedSiteMapItem.HstLink
create(String path, Mount mount)
Creates an HstLink for thepath
andmount
.HstLink
create(String path, Mount mount, boolean containerResource)
Creates an HstLink for thepath
andmount
.HstLink
create(javax.jcr.Node node, Mount mount)
HstLink
create(javax.jcr.Node node, Mount mount, boolean crossMount)
HstLink
create(javax.jcr.Node node, Mount mount, HstSiteMapItem preferredItem, boolean fallback)
HstLink
create(javax.jcr.Node node, HstRequestContext requestContext)
Rewrite a jcr Node to a HstLink wrt its current ResolvedSiteMapItemHstLink
create(javax.jcr.Node node, HstRequestContext requestContext, String mountAlias)
HstLink
create(javax.jcr.Node node, HstRequestContext requestContext, String mountAlias, String type)
HstLink
create(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem, boolean fallback)
Rewrite a jcr Node to a HstLink wrt its current HstRequestContext and preferredItem.HstLink
create(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem, boolean fallback, boolean navigationStateful)
This method creates the sameHstLink
ascreate(Node, HstRequestContext, HstSiteMapItem, boolean)
whennavigationStateful = false
.HstLink
create(HstSiteMapItem toHstSiteMapItem, Mount mount)
Regardless the current context, create a HstLink to the HstSiteMapItem that you use as argument.HstLink
create(HippoBean bean, HstRequestContext requestContext)
List<HstLink>
createAll(javax.jcr.Node node, Mount mount, String hostGroupName, String type, boolean crossMount)
Rewrite a jcr Node to a List ofHstLink
sList<HstLink>
createAll(javax.jcr.Node node, HstRequestContext requestContext, boolean crossMount)
Rewrite a jcr Node to a List ofHstLink
sList<HstLink>
createAll(javax.jcr.Node node, HstRequestContext requestContext, String hostGroupName, String type, boolean crossMount)
Rewrite a jcr Node to a List ofHstLink
sList<HstLink>
createAllAvailableCanonicals(javax.jcr.Node node, Mount mount, String type, String hostGroupName)
Expert: Creates aList
of all available canonical links fornode
, within the hostgrouphostGroupName
and where where the backingMount
of theHstLink
has at least oneMount.getTypes()
equal totype
List<HstLink>
createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext)
Expert: Creates aList
of all available canonical links fornode
within the hostgroup (VirtualHost.getHostGroupName()
) of theMount
for theHstRequestContext
.List<HstLink>
createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext, String type)
Expert: Creates aList
of all available canonical links fornode
, within the hostgroup (VirtualHost.getHostGroupName()
) of theMount
for theHstRequestContext
and where where the backingMount
of theHstLink
has at least oneMount.getTypes()
equal totype
List<HstLink>
createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext, String type, String hostGroupName)
Expert: Creates aList
of all available canonical links fornode
, within the hostgrouphostGroupName
and where where the backingMount
of theHstLink
has at least oneMount.getTypes()
equal totype
HstLink
createByRefId(String siteMapItemRefId, Mount mount)
Regardless the current context, create a HstLink to theHstSiteMapItem
forMount
mount
that hasHstSiteMapItem.getRefId()
equal tositeMapItemRefId
.HstLink
createCanonical(javax.jcr.Node node, HstRequestContext requestContext)
This creates a canonical HstLink: regardless the current requestContext, one and the same jcr Node is guaranteed to return the same HstLink.HstLink
createCanonical(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem)
HstLink
createPageNotFoundLink(Mount mount)
String
getBinariesPrefix()
List<LocationResolver>
getLocationResolvers()
boolean
isBinaryLocation(String path)
Binaries frequently have a different linkrewriting mechanism.
-
-
-
Method Detail
-
create
HstLink create(String uuid, javax.jcr.Session session, HstRequestContext requestContext)
Rewrite a jcr uuid to a HstLink wrt its current ResolvedSiteMapItem.- Parameters:
uuid
- the uuid of the node that must be used to link tosession
- jcr sessionrequestContext
- the HstRequestContext- Returns:
- an
HstLink
instance ornull
-
create
HstLink create(javax.jcr.Node node, HstRequestContext requestContext)
Rewrite a jcr Node to a HstLink wrt its current ResolvedSiteMapItem- Parameters:
node
-requestContext
- the HstRequestContext- Returns:
- the HstLink for this jcr Node or
null
-
create
HstLink create(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem, boolean fallback)
Rewrite a jcr Node to a HstLink wrt its current HstRequestContext and preferredItem. WhenpreferredItem
is notnull
, the link is tried to be rewritten to one of the descendants (including itself) of the preferredHstSiteMapItem
. WhenpreferredItem
isnull
, a link is created against the entire sitemap item tree. When there cannot be created an HstLink to a descendant HstSiteMapItem or self, then:- when
fallback = true
, a fallback tocreate(Node, HstRequestContext)
is done - when
fallback = false
, dependent on the implementation some error HstLink ornull
can be returned
This method returns an
HstLink
that takes the current URL into account, but does compute the link with respect to the physical (canonical) location of the jcr Node. If you need aHstLink
within the context of the possible virtual jcr Node (for example in case of in context showing documents in faceted navigation), usecreate(Node, HstRequestContext, HstSiteMapItem, boolean, boolean)
withnavigationStateful = true
- Parameters:
node
- the jcr noderequestContext
- the HstRequestContextpreferredItem
- if not null (null means no preferred sitemap item), first a link is trying to be created for this itemfallback
- whether to fallback to link rewriting withoutpreferredItem
in case link rewriting withpreferredItem
resulted in a not found link- Returns:
- the HstLink for this jcr Node or
null
- See Also:
create(Node, HstRequestContext, HstSiteMapItem, boolean, boolean)
- when
-
create
HstLink create(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem, boolean fallback, boolean navigationStateful)
This method creates the same
HstLink
ascreate(Node, HstRequestContext, HstSiteMapItem, boolean)
whennavigationStateful = false
. WhennavigationStateful = true
, the link that is created is with respect to the jcr Nodenode
, even if this node is a virtual location. This is different thencreate(Node, HstRequestContext, HstSiteMapItem, boolean)
: that method always first tries to find the canonical location of the jcr Node before it is creating a link for the node.Expert: Note there is a difference between context relative with respect to the current URL and with respect to the current jcr Node. Default, links in the HST are created always taking into account the current URL (thus context aware linking) unless you call
createCanonical(Node, HstRequestContext)
orcreateCanonical(Node, HstRequestContext, HstSiteMapItem)
. Also, default, it always (unless there is no) takes the canonical location of the jcr Node. Thus, multiple virtual versions of the same physical Node, result in the same HstLink. Only when havingnavigationStateful = true
, also the jcr Node is context relative, and thus multiple virtual versions of the same jcr Node can result in multiple links. This is interesting for example in faceted navigation views, where you want 'in context' documents to be shown.- Parameters:
node
- the jcr noderequestContext
- the HstRequestContextpreferredItem
- if not null (null means no preferred sitemap item), first a link is trying to be created for this itemfallback
- whether to fallback to link rewriting withoutpreferredItem
in case link rewriting withpreferredItem
resulted in a not found linknavigationStateful
- value true or false- Returns:
- the HstLink for this jcr Node or
null
- See Also:
create(Node, HstRequestContext, HstSiteMapItem, boolean)
-
createCanonical
HstLink createCanonical(javax.jcr.Node node, HstRequestContext requestContext)
This creates a canonical HstLink: regardless the current requestContext, one and the same jcr Node is guaranteed to return the same HstLink. This is useful when showing one and the same content via multiple urls, for example in faceted navigation. Search engines can better index your website when defining a canonical location for duplicate contents: See specify-your-canonical for more info on this subject.- Parameters:
node
-requestContext
- the HstRequestContext- Returns:
- the HstLink for this jcr Node or
null
-
createCanonical
HstLink createCanonical(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem)
- Parameters:
node
-requestContext
- the HstRequestContextpreferredItem
- ifnull
, a fallback tocreateCanonical(Node, HstRequestContext)
is done- Returns:
- the HstLink for this jcr Node or
null
- See Also:
When specifying a preferredItem, we try to create a canonical link wrt this preferredItem. If the link cannot be created for this preferredItem, a fallback to without preferredItem is done.
-
createAllAvailableCanonicals
List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext)
Expert: Creates aList
of all available canonical links fornode
within the hostgroup (VirtualHost.getHostGroupName()
) of theMount
for theHstRequestContext
. All available links have aMount
that has at least one of itsMount.getTypes()
equal to theMount.getTypes()
belonging to theMount
of therequestContext
. If theMount
of therequestContext
has no type in common at all, for example because it isMount
from a REST mount used by the template composer, you can usecreateAllAvailableCanonicals(Node, HstRequestContext, String)
and specify thetype
theMount
's for the available canonical links should be of.- Parameters:
node
-requestContext
- the HstRequestContext- Returns:
- the
List
of all available canonical links where at least one of theMount.getTypes()
are equal toMount.getTypes()
belonging to theMount
of therequestContext
- See Also:
createCanonical(Node, HstRequestContext)
-
createAllAvailableCanonicals
List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext, String type)
Expert: Creates aList
of all available canonical links fornode
, within the hostgroup (VirtualHost.getHostGroupName()
) of theMount
for theHstRequestContext
and where where the backingMount
of theHstLink
has at least oneMount.getTypes()
equal totype
- Parameters:
node
-requestContext
- the HstRequestContexttype
- thetype
that theMount
's belonging to the available canonical links should be of- Returns:
- the
List
of all available canonical links where at least one of theMount.getTypes()
are equal totype
- See Also:
createCanonical(Node, HstRequestContext)
-
createAllAvailableCanonicals
List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext, String type, String hostGroupName)
Expert: Creates aList
of all available canonical links fornode
, within the hostgrouphostGroupName
and where where the backingMount
of theHstLink
has at least oneMount.getTypes()
equal totype
- Parameters:
node
-requestContext
- the HstRequestContexttype
- thetype
that theMount
's belonging to the available canonical links should be ofhostGroupName
- The hostGroupName that theHstLink
s theirMount
s should belong to- Returns:
- the
List
of all available canonical links where at least one of theMount.getTypes()
are equal totype
- See Also:
createCanonical(Node, HstRequestContext)
-
createAllAvailableCanonicals
List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, Mount mount, String type, String hostGroupName)
Expert: Creates aList
of all available canonical links fornode
, within the hostgrouphostGroupName
and where where the backingMount
of theHstLink
has at least oneMount.getTypes()
equal totype
- Parameters:
node
-mount
- theMount
type
- thetype
that theMount
's belonging to the available canonical links should be ofhostGroupName
- The hostGroupName that theHstLink
s theirMount
s should belong to- Returns:
- the
List
of all available canonical links where at least one of theMount.getTypes()
are equal totype
- See Also:
createCanonical(Node, HstRequestContext)
-
create
HstLink create(javax.jcr.Node node, Mount mount)
Expert: Rewrite a jcr
node
to aHstLink
with respect to themount
. Note that this HstLink creation does only take into account themount
and not the current context. Themount
can be a different one then the one of the current request context. If themount
cannot be used to create a HstLink for the jcrnode
, because thenode
belongs to a different (sub)site, a page not found link is returned.note: if a link is returned, this is always the canonical link, also see
createCanonical(Node, HstRequestContext)
- Parameters:
node
- the jcr node for that should be translated into a HstLinkmount
- the (sub)site for which the hstLink should be created for- Returns:
- the
HstLink
for the jcrnode
and themount
ornull
when no link for the node can be made in themount
-
create
HstLink create(javax.jcr.Node node, Mount mount, boolean crossMount)
- Parameters:
node
- the jcr node for that should be translated into a HstLinkmount
- the (sub)site for which the hstLink should be tried to be created for, and if it does not succeed for this mount, depending on the value ofcrossMount
try other mountscrossMount
- iftrue
also mounts not belonging to the parametermount
are tried if themount
cannot return a link for thenode
.- Returns:
- the
HstLink
for the jcrnode
ornull
when no link for the node can be found - See Also:
create(Node, Mount) only now also fallback to other mounts are supported if is
-
create
HstLink create(javax.jcr.Node node, Mount mount, HstSiteMapItem preferredItem, boolean fallback)
Expert: Rewrite a jcr
node
to aHstLink
with respect to themount
andpreferredItem
. WhenpreferredItem
is notnull
, the link is tried to be rewritten to one of the descendants (including itself) of the preferredHstSiteMapItem
. When this does not result in a match, then, depending on whetherfallback = true
,a fallback to an attempt to link rewrite for the entire sitemap is done Note that this HstLink creation does only take into account themount
and not the current context. Themount
can be a different one then the one of the current request context. If themount
cannot be used to create a HstLink for the jcrnode
, because thenode
belongs to a different (sub)site, a page not found link is returned.- Parameters:
node
- the jcr node for that should be translated into a HstLinkmount
- the (sub)site for which the hstLink should be created forpreferredItem
- if not null (null means no preferred sitemap item), first a link is trying to be created for this itemfallback
- whether to fallback to link rewriting withoutpreferredItem
in case link rewriting withpreferredItem
resulted in a not found link- Returns:
- the
HstLink
for the jcrnode
and themount
ornull
when no link for the node can be made in themount
-
create
HstLink create(javax.jcr.Node node, HstRequestContext requestContext, String mountAlias)
Expert: Rewrite a jcr
node
to aHstLink
for themountAlias
. First, theMount
belonging to themountAlias
is searched for. When theMount
belonging to the alias cannot rewrite thenode
, there is no fallback to whether otherMount
's can rewrite thenode
to aHstLink
. Note that the foundMount
must- have
Mount.getAlias()
equal tomountAlias
- have at least one of its
Mount.getTypes()
the same as theMount
belonging to the currentrequestContext
. - have the same
VirtualHost.getHostGroupName()
as theMount
belonging to the currentrequestContext
.
Mount
complying to the above rules,null
is returned. If aMount
does comply, we returncreate(Node, Mount)
- Parameters:
node
- the jcr noderequestContext
- the current request contextmountAlias
- the alias of theMount
for which the link should be created for- Returns:
- the
HstLink
for the jcrnode
and themountAlias
ornull
when there cannot be found anMount
for the alias - See Also:
create(Node, Mount)
- have
-
create
HstLink create(javax.jcr.Node node, HstRequestContext requestContext, String mountAlias, String type)
Expert: Rewrite a jcr
node
to aHstLink
for themountAlias
and fortype
. When theMount
belonging to the alias cannot rewrite thenode
, there is no fallback to whether otherMount
's can rewrite thenode
to aHstLink
Note that the foundMount
must- have
Mount.getAlias()
equal tomountAlias
- contain
type
in itsMount.getTypes()
- have the same
VirtualHost.getHostGroupName()
as theMount
belonging to the currentrequestContext
.
Mount
complying to the above rules,null
is returned. If aMount
does comply, we returncreate(Node, Mount)
.The difference with
create(Node, HstRequestContext, String)
is that this method does not look for aMount
with a commontype
as for theMount
from the current request. It does look for aMount
which at least hastype
as itsMount.getTypes()
- Parameters:
node
- the jcr noderequestContext
- the current request contextmountAlias
- the alias of theMount
for which the link should be created fortype
- the type that should be contained in theMount.getTypes()
where theMount
is the mount belonging to the returnedHstLink
- Returns:
- the
HstLink
for the jcrnode
and themountAlias
ornull
when no link for the node can be made in the
belonging to the alias or when there belongs noMount
Mount
to the alias - See Also:
create(Node, Mount)
- have
-
create
HstLink create(HippoBean bean, HstRequestContext requestContext)
- Parameters:
bean
-requestContext
- the HstRequestContext- Returns:
- a HstLink for
bean
and thehstRequestContext
ornull
when no link for the node can be made
-
create
HstLink create(HstSiteMapItem toHstSiteMapItem, Mount mount)
Regardless the current context, create a HstLink to the HstSiteMapItem that you use as argument. This is only possible if the sitemap item does not contain any ancestor including itself with a wildcard, because the link is ambiguous in that case. If a wildcard is encountered, this method can returnnull
, though this is up to the implementation- Parameters:
toHstSiteMapItem
- theHstSiteMapItem
to link to- Returns:
- an
HstLink
instance ornull
-
createByRefId
HstLink createByRefId(String siteMapItemRefId, Mount mount)
Regardless the current context, create a HstLink to theHstSiteMapItem
forMount
mount
that hasHstSiteMapItem.getRefId()
equal tositeMapItemRefId
. If there cannot be found aHstSiteMapItem
forsiteMapItemRefId
in theMount
mount
, thennull
is returned. If theHstSiteMapItem
is found forsiteMapItemRefId
, then it can be only used when it does not contain any ancestor including itself with a wildcard, because the link is ambiguous in that case. If a wildcard is encountered, this method can returnnull
, though this is up to the implementation- Parameters:
siteMapItemRefId
- theHstSiteMapItem.getRefId()
of theHstSiteMapItem
to link tomount
- theMount
thesiteMapItemRefId
should be in- Returns:
- an
HstLink
instance ornull
-
create
HstLink create(String path, Mount mount)
Creates an HstLink for thepath
andmount
. If themount
is a sub mount, eg /fr, then the resulting link includes /fr after the context path.- Parameters:
path
- the path to the sitemap item, where the sitemap item or one of its ancestors may contain wildcardsmount
- theMount
the path should be in- Returns:
- an
HstLink
instance ornull
-
create
HstLink create(String path, Mount mount, boolean containerResource)
Creates an HstLink for thepath
andmount
. IfcontainerResource
isfalse
, the resulting URL WILL include theMount.getMountPath()
after the webapp relative part (context path). WhencontainerResource
isfalse
, the resulting URL WILL include theMount.getMountPath()
after the webapp relative part (context path).- Parameters:
path
- the path to the sitemap itemmount
- theMount
for which the link should be createdcontainerResource
-true
if the link to be created must be a webapp relative link and not relative toMount.getMountPath()
- Returns:
- an
HstLink
instance ornull
-
createAll
List<HstLink> createAll(javax.jcr.Node node, HstRequestContext requestContext, boolean crossMount)
Rewrite a jcr Node to a List ofHstLink
s- Parameters:
node
-requestContext
- the HstRequestContextcrossMount
- iftrue
also mounts not belonging to the current request context (HstRequestContext.getResolvedMount()
) are tried.- Returns:
- the List of
HstLink
s for this jcr Node or empty list when non found. The returned List is sorted by first theHstLink
s with the shortest path (in number of slashes) and if there are links with equal number of slashes, return lexically sorted on path
-
createAll
List<HstLink> createAll(javax.jcr.Node node, HstRequestContext requestContext, String hostGroupName, String type, boolean crossMount)
Rewrite a jcr Node to a List ofHstLink
s- Parameters:
node
-requestContext
- the HstRequestContexthostGroupName
- The hostGroupName that theHstLink
s theirMount
s should belong totype
- the type that should be contained in theMount.getTypes()
where theMount
is the mount belonging to the returnedHstLink
. Iftype
isnull
, the type of theHstRequestContext.getResolvedMount()
is used.crossMount
- iftrue
also mounts not belonging to the current request context (HstRequestContext.getResolvedMount()
) are tried.- Returns:
- the List of
HstLink
s for this jcr Node or empty list when non found. The returned List is sorted by first theHstLink
s with the shortest path (in number of slashes) and if there are links with equal number of slashes, return lexically sorted on path
-
createAll
List<HstLink> createAll(javax.jcr.Node node, Mount mount, String hostGroupName, String type, boolean crossMount)
Rewrite a jcr Node to a List ofHstLink
s- Parameters:
node
-mount
- theMount
hostGroupName
- The hostGroupName that theHstLink
s theirMount
s should belong totype
- the type that should be contained in theMount.getTypes()
where theMount
is the mount belonging to the returnedHstLink
. Iftype
isnull
, the type of theMount
is used.crossMount
- iftrue
also mounts not belonging to the current site are tried.- Returns:
- the List of
HstLink
s for this jcr Node or empty list when non found. The returned List is sorted by first theHstLink
s with the shortest path (in number of slashes) and if there are links with equal number of slashes, return lexically sorted on path
-
createPageNotFoundLink
HstLink createPageNotFoundLink(Mount mount)
- Returns:
- a link that can be used for page not found links for
mount
-
isBinaryLocation
boolean isBinaryLocation(String path)
Binaries frequently have a different linkrewriting mechanism. If this method returnstrue
the location is a binary location.- Parameters:
path
-- Returns:
true
when the path points to a binary location
-
getBinariesPrefix
String getBinariesPrefix()
- Returns:
- The prefix that is used for binary locations. The returned binaries prefix is relative to
/
and does not include the/
itself. If no binaries prefix is configured,""
will be returned
-
getLocationResolvers
List<LocationResolver> getLocationResolvers()
- Returns:
- the list of location resolvers, primarily used for resolving custom binary locations
-
clear
void clear()
Clears possibly available caches
-
-