nl.gx.webmanager.services.seo.handler.impl
Class FriendlyURLManagerImpl

java.lang.Object
  extended by nl.gx.webmanager.services.seo.handler.impl.FriendlyURLManagerImpl
All Implemented Interfaces:
FriendlyURLManager

public final class FriendlyURLManagerImpl
extends java.lang.Object
implements FriendlyURLManager

Handles conflict resolving and descendant retrieval.

Author:
Sander Dahlberg

Constructor Summary
FriendlyURLManagerImpl(InternalSEOService seoService, FriendlyURLEntityDAO entityDAO)
          Constructor.
 
Method Summary
 FriendlyURLEntity cloneEntity(FriendlyURLEntity entity)
          Clones the in memory friendly URL entity.
 java.util.List<FriendlyURLEntity> getDescendantEntities(FriendlyURLEntity entity)
          Returns all descendant friendly URL entities for the given page and language.
 java.util.List<FriendlyURLEntity> getDescendantEntities(Page page, Language language)
          Returns all descendant friendly URL entities for the given page and language.
 void resolve(FriendlyURLEntity resolveEntity, java.util.List<FriendlyURLEntity> applyToEntities)
          Resolves potential URL identifier conflicts for the given entity.
 void resolve(java.util.List<FriendlyURLEntity> resolveEntities, java.util.List<FriendlyURLEntity> applyToEntities)
          Resolves potential URL identifier conflicts for the given entities.
 void resolveAgainstAlternatives(FriendlyURLEntity rootEntity, java.util.List<FriendlyURLEntity> resolveEntities)
          Resolves all given entities with the alternative entities having an alternative path within the scope of the given root entity.
 java.util.List<FriendlyURLEntity> selectSameGeneration(java.util.List<FriendlyURLEntity> entities, FriendlyURLEntity entity)
          Returns a subset from the given entities that have the same URL path level as the given entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FriendlyURLManagerImpl

public FriendlyURLManagerImpl(InternalSEOService seoService,
                              FriendlyURLEntityDAO entityDAO)
Constructor.

Parameters:
seoService - SEO service.
entityDAO - Friendly URL entity DAO.
Method Detail

getDescendantEntities

public java.util.List<FriendlyURLEntity> getDescendantEntities(Page page,
                                                               Language language)
                                                        throws FriendlyURLException
Returns all descendant friendly URL entities for the given page and language. Exception are descendants that have an alternative friendly URL, because those friendly URL entities typically do not change due to an operation on some ancestor.

This method is more versatile than FriendlyURLManager.getDescendantEntities(FriendlyURLEntity), as there is no need that a page version for the given page and language should be current, or should even actually exist.

Specified by:
getDescendantEntities in interface FriendlyURLManager
Parameters:
page - Page to retrieve descendant URLs for.
language - Scope the page's versions to those in this language.
Returns:
List of descendant page friendly URL entities.
Throws:
FriendlyURLException - If any access to the persistent layer failed.

getDescendantEntities

public java.util.List<FriendlyURLEntity> getDescendantEntities(FriendlyURLEntity entity)
                                                        throws FriendlyURLException
Returns all descendant friendly URL entities for the given page and language. Exception are descendants that have an alternative friendly URL, because those friendly URL entities typically do not change due to an operation on some ancestor.

This method is faster than FriendlyURLManager.getDescendantEntities(Page, Language), but restricting demands exist for the given entity parameter. The given entity must represent a current page version, and not have an alternative path.

Specified by:
getDescendantEntities in interface FriendlyURLManager
Parameters:
entity - Entity to retrieve descendant URLs for. Entity must return true for FriendlyURLEntity.isLive() and return false for FriendlyURLEntity.isAlternative(), or else an IllegalArgumentException is thrown.
Returns:
List of descendant page friendly URL entities.
Throws:
FriendlyURLException - If any access to the persistent layer failed.

resolve

public void resolve(FriendlyURLEntity resolveEntity,
                    java.util.List<FriendlyURLEntity> applyToEntities)
             throws FriendlyURLException
Resolves potential URL identifier conflicts for the given entity. Delegates to FriendlyURLManager.resolve(List, List).

Specified by:
resolve in interface FriendlyURLManager
Parameters:
resolveEntity - Entity that should be resolved.
applyToEntities - Potential conflict resolving is propagated to these entities.
Throws:
FriendlyURLException - If any access to the persistent layer failed.
See Also:
FriendlyURLManager.resolve(List, List).

resolve

public void resolve(java.util.List<FriendlyURLEntity> resolveEntities,
                    java.util.List<FriendlyURLEntity> applyToEntities)
             throws FriendlyURLException
Resolves potential URL identifier conflicts for the given entities. Conflict resolved URL identifiers are applied to the given list of applyToEntities.

For example, if an entity with URL identifier /a/b is resolved to become /a/b 1, and in the applyToEntities list exists an entity with URL identifier /a/b/c, then this entity gets URL identifier /a/b 1/c.

Specified by:
resolve in interface FriendlyURLManager
Parameters:
resolveEntities - Entities that should be resolved.
applyToEntities - Potential conflict resolving is propagated to these entities.
Throws:
FriendlyURLException - If any access to the persistent layer failed.

resolveAgainstAlternatives

public void resolveAgainstAlternatives(FriendlyURLEntity rootEntity,
                                       java.util.List<FriendlyURLEntity> resolveEntities)
                                throws FriendlyURLException
Resolves all given entities with the alternative entities having an alternative path within the scope of the given root entity.

For example, if root entity has URL identifier /a/b and an entity in the system exists with an URL identifier with alternative path starting with /a/b, like /a/b/c, then the resolveEntities list of entities are conflict resolved against the alternative entity.

Specified by:
resolveAgainstAlternatives in interface FriendlyURLManager
Parameters:
rootEntity - Alternative entities are retrieved with an alternative path starting with the URL identifier of this root entity.
resolveEntities - If there are alternative entities in the domain of the root entity then these entities are conflict resolved, if needed.
Throws:
FriendlyURLException - If any access to the persistent layer failed.

cloneEntity

public FriendlyURLEntity cloneEntity(FriendlyURLEntity entity)
Clones the in memory friendly URL entity.

Specified by:
cloneEntity in interface FriendlyURLManager
Parameters:
entity - Entity to clone.
Returns:
New friendly URL entity object representing the same entity.

selectSameGeneration

public java.util.List<FriendlyURLEntity> selectSameGeneration(java.util.List<FriendlyURLEntity> entities,
                                                              FriendlyURLEntity entity)
Returns a subset from the given entities that have the same URL path level as the given entity. For example, an entity with URL identifier /a/b, is said to be a level two entity.

Note that the URL path tree is not necessarily the same as the page tree.

Specified by:
selectSameGeneration in interface FriendlyURLManager
Parameters:
entities - Input entities of which a subset is returned.
entity - Entity that determines the level the other entities should have to be returned.
Returns:
Entities that exist on the same level as the given entity.


Copyright © 2007-2011 GX Software BV. All Rights Reserved.