org.hippoecm.hst.core.linking
Class DefaultHstLinkCreator

java.lang.Object
  extended by org.hippoecm.hst.core.linking.DefaultHstLinkCreator
All Implemented Interfaces:
HstLinkCreator

public class DefaultHstLinkCreator
extends Object
implements HstLinkCreator


Constructor Summary
DefaultHstLinkCreator()
           
 
Method Summary
 void clear()
          Clears possibly available caches
 HstLink create(HippoBean bean, HstRequestContext hstRequestContext)
           
 HstLink create(HstSiteMapItem toHstSiteMapItem)
          Deprecated. use create(HstSiteMapItem, Mount) instead
 HstLink create(HstSiteMapItem toHstSiteMapItem, Mount mount)
          Regardless the current context, create a HstLink to the HstSiteMapItem that you use as argument.
 HstLink create(javax.jcr.Node node, HstRequestContext hstRequestContext)
          Rewrite a jcr Node to a HstLink wrt its current ResolvedSiteMapItem
 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 same HstLink as HstLinkCreator.create(Node, HstRequestContext, HstSiteMapItem, boolean) when navigationStateful = false.
 HstLink create(javax.jcr.Node node, HstRequestContext requestContext, String mountAlias)
          Expert: Rewrite a jcr node to a HstLink for the mountAlias.
 HstLink create(javax.jcr.Node node, HstRequestContext requestContext, String mountAlias, String type)
          Expert: Rewrite a jcr node to a HstLink for the mountAlias and for type.
 HstLink create(javax.jcr.Node node, Mount mount)
          Expert: Rewrite a jcr node to a HstLink with respect to the mount.
 HstLink create(String path, Mount mount)
          Regardless the current context, create a HstLink for the path and mount
 HstLink create(String path, Mount mount, boolean containerResource)
          Regardless the current context, create a HstLink to the path that you use as argument.
 HstLink create(String uuid, javax.jcr.Session session, HstRequestContext requestContext)
          If the uuid points to a node that is of type hippo:document and it is below a hippo:handle, we will rewrite the link wrt hippo:handle, because a handle is the umbrella of a document.
 List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext)
          Expert: Creates a List of all available canonical links for node within the hostgroup ( VirtualHost.getHostGroupName() ) of the Mount for the HstRequestContext.
 List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext, String type)
          Expert: Creates a List of all available canonical links for node, within the hostgroup ( VirtualHost.getHostGroupName() ) of the Mount for the HstRequestContext and where where the backing Mount of the HstLink has at least one Mount.getTypes() equal to type
 List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node, HstRequestContext requestContext, String type, String hostGroupName)
          Expert: Creates a List of all available canonical links for node, within the hostgroup hostGroupName and where where the backing Mount of the HstLink has at least one Mount.getTypes() equal to type
 HstLink createByRefId(String siteMapItemRefId, Mount mount)
          Regardless the current context, create a HstLink to the HstSiteMapItem for Mount mount that has HstSiteMapItem.getRefId() equal to siteMapItemRefId.
 HstLink createCanonical(javax.jcr.Node node, HstRequestContext requestContext)
          This creates a canonical HstLink: regardless the current requestContext, one and the same jcr Node is garantueed to return the same HstLink.
 HstLink createCanonical(javax.jcr.Node node, HstRequestContext requestContext, HstSiteMapItem preferredItem)
           
 String getBinariesPrefix()
           
 List<LocationResolver> getLocationResolvers()
           
 boolean isBinaryLocation(String path)
          Binaries frequently have a different linkrewriting mechanism.
 void setBinariesPrefix(String binariesPrefix)
           
 void setBinaryLocations(String[] binaryLocations)
           
 void setlinkProcessor(HstLinkProcessor linkProcessor)
           
 void setLocationResolvers(List<LocationResolver> locationResolvers)
           
 void setPageNotFoundPath(String pageNotFoundPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHstLinkCreator

public DefaultHstLinkCreator()
Method Detail

setBinariesPrefix

public void setBinariesPrefix(String binariesPrefix)

setBinaryLocations

public void setBinaryLocations(String[] binaryLocations)

setlinkProcessor

public void setlinkProcessor(HstLinkProcessor linkProcessor)

setLocationResolvers

public void setLocationResolvers(List<LocationResolver> locationResolvers)

getLocationResolvers

public List<LocationResolver> getLocationResolvers()
Specified by:
getLocationResolvers in interface HstLinkCreator
Returns:
the list of location resolvers, primarily used for resolving custom binary locations

setPageNotFoundPath

public void setPageNotFoundPath(String pageNotFoundPath)

clear

public void clear()
Description copied from interface: HstLinkCreator
Clears possibly available caches

Specified by:
clear in interface HstLinkCreator

create

public HstLink create(String uuid,
                      javax.jcr.Session session,
                      HstRequestContext requestContext)
If the uuid points to a node that is of type hippo:document and it is below a hippo:handle, we will rewrite the link wrt hippo:handle, because a handle is the umbrella of a document. If the uuid cannot be found, we return null Rewrite a jcr uuid to a HstLink wrt its current ResolvedSiteMapItem.

Specified by:
create in interface HstLinkCreator
Parameters:
uuid - the uuid of the node that must be used to link to
session - jcr session
Returns:
an HstLink instance or null

create

public HstLink create(HippoBean bean,
                      HstRequestContext hstRequestContext)
Specified by:
create in interface HstLinkCreator
Returns:
a HstLink for bean and the hstRequestContext or null when no link for the node can be made

create

public HstLink create(javax.jcr.Node node,
                      HstRequestContext hstRequestContext)
Description copied from interface: HstLinkCreator
Rewrite a jcr Node to a HstLink wrt its current ResolvedSiteMapItem

Specified by:
create in interface HstLinkCreator
Returns:
the HstLink for this jcr Node or null

create

public HstLink create(javax.jcr.Node node,
                      HstRequestContext requestContext,
                      HstSiteMapItem preferredItem,
                      boolean fallback)
Description copied from interface: HstLinkCreator
Rewrite a jcr Node to a HstLink wrt its current HstRequestContext and preferredItem. When preferredItem is not null, the link is tried to be rewritten to one of the descendants (including itself) of the preferred HstSiteMapItem. When preferredItem is null, a link is created against the entire sitemap item tree. When there cannot be created an HstLink to a descendant HstSiteMapItem or self, then:
  1. when fallback = true, a fallback to HstLinkCreator.create(Node, HstRequestContext) is done
  2. when fallback = false, dependent on the implementation some error HstLink or null 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 a HstLink within the context of the possible virtual jcr Node (for example in case of in context showing documents in faceted navigation), use HstLinkCreator.create(Node, HstRequestContext, HstSiteMapItem, boolean, boolean) with navigationStateful = true

Specified by:
create in interface HstLinkCreator
Parameters:
node - the jcr node
requestContext - the current requestContext
preferredItem - if not null (null means no preferred sitemap item), first a link is trying to be created for this item
fallback - value true or false
Returns:
the HstLink for this jcr Node or null
See Also:
HstLinkCreator.create(Node, HstRequestContext, HstSiteMapItem, boolean, boolean)

create

public HstLink create(javax.jcr.Node node,
                      HstRequestContext requestContext,
                      HstSiteMapItem preferredItem,
                      boolean fallback,
                      boolean navigationStateful)
Description copied from interface: HstLinkCreator

This method creates the same HstLink as HstLinkCreator.create(Node, HstRequestContext, HstSiteMapItem, boolean) when navigationStateful = false. When navigationStateful = true, the link that is created is with respect to the jcr Node node, even if this node is a virtual location. This is different then HstLinkCreator.create(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 HstLinkCreator.createCanonical(Node, HstRequestContext) or HstLinkCreator.createCanonical(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 having navigationStateful = 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.

Specified by:
create in interface HstLinkCreator
Parameters:
node - the jcr node
preferredItem - if not null (null means no preferred sitemap item), first a link is trying to be created for this item
fallback - value true or false
navigationStateful - value true or false
Returns:
the HstLink for this jcr Node or null
See Also:
HstLinkCreator.create(Node, HstRequestContext, HstSiteMapItem, boolean)

createCanonical

public HstLink createCanonical(javax.jcr.Node node,
                               HstRequestContext requestContext)
Description copied from interface: HstLinkCreator
This creates a canonical HstLink: regardless the current requestContext, one and the same jcr Node is garantueed 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.

Specified by:
createCanonical in interface HstLinkCreator
Returns:
the HstLink for this jcr Node or null

createCanonical

public HstLink createCanonical(javax.jcr.Node node,
                               HstRequestContext requestContext,
                               HstSiteMapItem preferredItem)
Specified by:
createCanonical in interface HstLinkCreator
preferredItem - if null, a fallback to HstLinkCreator.createCanonical(Node, HstRequestContext) is done
Returns:
the HstLink for this jcr Node or null
See Also:
#createCanonical(Node, HstRequestContext)}. 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 {@link #createCanonical(Node, HstRequestContext)} without preferredItem is done.

createAllAvailableCanonicals

public List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node,
                                                  HstRequestContext requestContext)
Description copied from interface: HstLinkCreator
Expert: Creates a List of all available canonical links for node within the hostgroup ( VirtualHost.getHostGroupName() ) of the Mount for the HstRequestContext. All available links have a Mount that has at least one of its Mount.getTypes() equal to the Mount.getTypes() belonging to the Mount of the requestContext. If the Mount of the requestContext has no type in common at all, for example because it is Mount from a REST mount used by the template composer, you can use HstLinkCreator.createAllAvailableCanonicals(Node, HstRequestContext, String) and specify the type the Mount's for the available canonical links should be of.

Specified by:
createAllAvailableCanonicals in interface HstLinkCreator
Returns:
the List of all available canonical links where at least one of the Mount.getTypes() are equal to Mount.getTypes() belonging to the Mount of the requestContext
See Also:
HstLinkCreator.createCanonical(Node, HstRequestContext)

createAllAvailableCanonicals

public List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node,
                                                  HstRequestContext requestContext,
                                                  String type)
Description copied from interface: HstLinkCreator
Expert: Creates a List of all available canonical links for node, within the hostgroup ( VirtualHost.getHostGroupName() ) of the Mount for the HstRequestContext and where where the backing Mount of the HstLink has at least one Mount.getTypes() equal to type

Specified by:
createAllAvailableCanonicals in interface HstLinkCreator
type - the type that the Mount's belonging to the available canonical links should be of
Returns:
the List of all available canonical links where at least one of the Mount.getTypes() are equal to type
See Also:
HstLinkCreator.createCanonical(Node, HstRequestContext)

createAllAvailableCanonicals

public List<HstLink> createAllAvailableCanonicals(javax.jcr.Node node,
                                                  HstRequestContext requestContext,
                                                  String type,
                                                  String hostGroupName)
Description copied from interface: HstLinkCreator
Expert: Creates a List of all available canonical links for node, within the hostgroup hostGroupName and where where the backing Mount of the HstLink has at least one Mount.getTypes() equal to type

Specified by:
createAllAvailableCanonicals in interface HstLinkCreator
type - the type that the Mount's belonging to the available canonical links should be of
hostGroupName - The hostGroupName that the HstLinks their Mounts should belong to
Returns:
the List of all available canonical links where at least one of the Mount.getTypes() are equal to type
See Also:
HstLinkCreator.createCanonical(Node, HstRequestContext)

create

public HstLink create(javax.jcr.Node node,
                      Mount mount)
Description copied from interface: HstLinkCreator

Expert: Rewrite a jcr node to a HstLink with respect to the mount. Note that this HstLink creation does only take into account the mount and not the current context. The mount can be a different one then the one of the current request context. If the mount cannot be used to create a HstLink for the jcr node, because the node 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 HstLinkCreator.createCanonical(Node, HstRequestContext)

Specified by:
create in interface HstLinkCreator
Parameters:
node - the jcr node for that should be translated into a HstLink
mount - the (sub)site for which the hstLink should be created for
Returns:
the HstLink for the jcr node and the mount or null when no link for the node can be made in the mount

create

public HstLink create(javax.jcr.Node node,
                      HstRequestContext requestContext,
                      String mountAlias)
Description copied from interface: HstLinkCreator

Expert: Rewrite a jcr node to a HstLink for the mountAlias. First, the Mount belonging to the mountAlias is searched for. When the Mount belonging to the alias cannot rewrite the node, there is no fallback to whether other Mount's can rewrite the node to a HstLink. Note that the found Mount must

  1. have Mount.getAlias() equal to mountAlias
  2. have at least one of its Mount.getTypes() the same as the Mount belonging to the current requestContext.
  3. have the same VirtualHost.getHostGroupName() as the Mount belonging to the current requestContext.
If there is no Mount complying to the above rules, null is returned. If a Mount does comply, we return HstLinkCreator.create(Node, Mount)

Specified by:
create in interface HstLinkCreator
Parameters:
node - the jcr node
requestContext - the current request context
mountAlias - the alias of the Mount for which the link should be created for
Returns:
the HstLink for the jcr node and the mountAlias or null when there cannot be found an Mount for the alias
See Also:
#create(Node, Mount)}

create

public HstLink create(javax.jcr.Node node,
                      HstRequestContext requestContext,
                      String mountAlias,
                      String type)
Description copied from interface: HstLinkCreator

Expert: Rewrite a jcr node to a HstLink for the mountAlias and for type. When the Mount belonging to the alias cannot rewrite the node, there is no fallback to whether other Mount's can rewrite the node to a HstLink Note that the found Mount must

  1. have Mount.getAlias() equal to mountAlias
  2. contain type in its Mount.getTypes()
  3. have the same VirtualHost.getHostGroupName() as the Mount belonging to the current requestContext.
If there is no Mount complying to the above rules, null is returned. If a Mount does comply, we return HstLinkCreator.create(Node, Mount).

The difference with #create(Node, HstRequestContext, String)) is that this method does not look for a Mount with a common type as for the Mount from the current request. It does look for a Mount which at least has type as its Mount.getTypes()

Specified by:
create in interface HstLinkCreator
Parameters:
node - the jcr node
requestContext - the current request context
mountAlias - the alias of the Mount for which the link should be created for
type - the type tha should be contained in the Mount.getTypes() where the Mount is the mount belonging to the returned HstLink
Returns:
the HstLink for the jcr node and the mountAlias or null when no link for the node can be made in the Mount belonging to the alias or when there belongs no Mount to the alias
See Also:
#create(Node, Mount)}

create

public HstLink create(String path,
                      Mount mount)
Description copied from interface: HstLinkCreator
Regardless the current context, create a HstLink for the path and mount

Specified by:
create in interface HstLinkCreator
Parameters:
path - the path to the sitemap item
mount - the Mount the path should be in
Returns:
an HstLink instance or null

create

public HstLink create(String path,
                      Mount mount,
                      boolean containerResource)
Description copied from interface: HstLinkCreator
Regardless the current context, create a HstLink to the path that you use as argument.

Specified by:
create in interface HstLinkCreator
Parameters:
path - the path to the sitemap item
mount - the Mount for which the link should be created
containerResource - whether it is a static link, for example for css/js
Returns:
an HstLink instance or null

create

@Deprecated
public HstLink create(HstSiteMapItem toHstSiteMapItem)
Deprecated. use create(HstSiteMapItem, Mount) instead

Specified by:
create in interface HstLinkCreator

create

public HstLink create(HstSiteMapItem toHstSiteMapItem,
                      Mount mount)
Description copied from interface: HstLinkCreator
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 return null, though this is up to the implementation

Specified by:
create in interface HstLinkCreator
Parameters:
toHstSiteMapItem - the HstSiteMapItem to link to
Returns:
an HstLink instance or null

createByRefId

public HstLink createByRefId(String siteMapItemRefId,
                             Mount mount)
Description copied from interface: HstLinkCreator
Regardless the current context, create a HstLink to the HstSiteMapItem for Mount mount that has HstSiteMapItem.getRefId() equal to siteMapItemRefId. If there cannot be found a HstSiteMapItem for siteMapItemRefId in the Mount mount, then null is returned. If the HstSiteMapItem is found for siteMapItemRefId, 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 return null, though this is up to the implementation

Specified by:
createByRefId in interface HstLinkCreator
Parameters:
siteMapItemRefId - the HstSiteMapItem.getRefId() of the HstSiteMapItem to link to
mount - the Mount the siteMapItemRefId should be in
Returns:
an HstLink instance or null

getBinariesPrefix

public String getBinariesPrefix()
Specified by:
getBinariesPrefix in interface HstLinkCreator
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

isBinaryLocation

public boolean isBinaryLocation(String path)
Description copied from interface: HstLinkCreator
Binaries frequently have a different linkrewriting mechanism. If this method returns true the location is a binary location.

Specified by:
isBinaryLocation in interface HstLinkCreator
Returns:
true when the path points to a binary location


Copyright © 2008-2012 Hippo. All Rights Reserved.