com.endeca.infront.cartridge
Class NavigationCartridgeHandler<ConfigType extends ContentItem,ModelType extends ContentItem>

java.lang.Object
  extended by com.endeca.infront.cartridge.NavigationCartridgeHandler<ConfigType,ModelType>
All Implemented Interfaces:
CartridgeHandler<ConfigType>
Direct Known Subclasses:
BreadcrumbsHandler, DimensionSearchResultsHandler, MediaBannerHandler, NavigationContainerHandler, RecordDetailsHandler, RecordSpotlightHandler, RefinementMenuHandler, ResultsListHandler, SearchAdjustmentsHandler

public abstract class NavigationCartridgeHandler<ConfigType extends ContentItem,ModelType extends ContentItem>
extends Object
implements CartridgeHandler<ConfigType>

Base class for Endeca navigation cartridge handlers. Provides generics for specifying explicit implementations of ContentItem that provide getter or setter methods for accessing keys within the ContentItem (which extends the Map interface).

This class also provides helper methods for executing MDEX queries. The createMdexRequest(FilterState, MdexQuery) and executeMdexRequest(com.endeca.infront.navigation.request.MdexRequest) methods provide the CartridgeHandler a way to tie into the Assembler's query mechanism that consolidates common MDEX queries across multiple CartridgeHandler instances. To make use of this consolidation, createMdexRequest(FilterState, MdexQuery) should be called from preprocess(ConfigType) and executeMdexRequest(com.endeca.infront.navigation.request.MdexRequest) should be called from process(ConfigType). They can also be used together at the same time, but no query consolidation will happen in this case across cartridge handlers.


Constructor Summary
NavigationCartridgeHandler()
           
 
Method Summary
protected  com.endeca.infront.navigation.request.MdexRequest createMdexRequest(FilterState pFilterState, com.endeca.infront.navigation.request.MdexQuery pMdexQuery)
           Convenience method that wraps the MdexRequestBroker.createMdexRequest(FilterState, MdexQuery) method, throwing a CartridgeHandlerException if a NavigationException is caught.
protected  void dispatchNavigationEventInformation(com.endeca.navigation.ENEQueryResults pMdexResponse)
          Tracks all Navigation State related information
protected  com.endeca.navigation.ENEQueryResults executeMdexRequest(com.endeca.infront.navigation.request.MdexRequest mdexRequest)
           Convenience method that wraps the MdexRequest.execute(), throwing a CartridgeHandlerException if a NavigationException is caught.
 ActionPathProvider getActionPathProvider()
          Gets the ActionPathProvider used to determine the site root path and content path when creating Action objects.
 ContentItemInitializer getContentItemInitializer()
          Returns the ContentItemInitializer used to create the full cartridge configuration.
protected  MdexRequestBroker getMdexRequestBroker()
          Used to construct MDEX requests.
 NavigationState getNavigationState()
          Gets the navigation state represented by the current request.
 ConfigType initialize(ContentItem pContentItem)
          Uses the ContentItemInitializer, if one has been set, to create the full configuration for this cartridge.
protected  void populateNavigationPathDefaults(Action action)
          Convenience method to populate the site root path and content path of the given action using the configured ActionPathProvider.
 void preprocess(ConfigType pContentItem)
          The default implementation does nothing.
 ModelType process(ConfigType pContentItem)
          The default implementation does nothing and returns null.
 void setActionPathProvider(ActionPathProvider pActionPathProvider)
          Sets the ActionPathProvider used to determine the site root path and content path when creating Action objects.
 void setContentItemInitializer(ContentItemInitializer initializer)
          Sets the ContentItemInitializer used to create the full cartridge configuration in the initialize(com.endeca.infront.assembler.ContentItem) method.
 void setMdexRequestBroker(MdexRequestBroker pMdexRequestBroker)
          Sets the MdexRequestBroker used to construct requests.
 void setNavigationState(NavigationState pNavigationState)
          Sets the navigation state represented by the current request.
protected abstract  ConfigType wrapConfig(ContentItem item)
          Wraps the input ContentItem as a typed config object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NavigationCartridgeHandler

public NavigationCartridgeHandler()
Method Detail

setContentItemInitializer

public void setContentItemInitializer(ContentItemInitializer initializer)
Sets the ContentItemInitializer used to create the full cartridge configuration in the initialize(com.endeca.infront.assembler.ContentItem) method. If the initializer is null, the initialize(com.endeca.infront.assembler.ContentItem) method will simply wrap the input ContentItem as an instance of the handler's configuration type and return it.

Parameters:
initializer - may be null
See Also:
CartridgeHandler.initialize(ContentItem)

getContentItemInitializer

public ContentItemInitializer getContentItemInitializer()
Returns the ContentItemInitializer used to create the full cartridge configuration.

See Also:
setContentItemInitializer(ContentItemInitializer)

getMdexRequestBroker

protected MdexRequestBroker getMdexRequestBroker()
Used to construct MDEX requests. The MdexRequestBroker must be available within the scope of the request, but should not be modified or used outside the scope of the NavigationCartridgeHandler and NavigationStateBuilder. Use of the MdexRequestBroker in other classes is not supported.

Returns:
The instance of the MdexRequestBroker.

setMdexRequestBroker

public void setMdexRequestBroker(MdexRequestBroker pMdexRequestBroker)
Sets the MdexRequestBroker used to construct requests.


getNavigationState

public NavigationState getNavigationState()
Gets the navigation state represented by the current request.


setNavigationState

public void setNavigationState(NavigationState pNavigationState)
Sets the navigation state represented by the current request.


getActionPathProvider

public ActionPathProvider getActionPathProvider()
Gets the ActionPathProvider used to determine the site root path and content path when creating Action objects.


setActionPathProvider

public void setActionPathProvider(ActionPathProvider pActionPathProvider)
Sets the ActionPathProvider used to determine the site root path and content path when creating Action objects.


populateNavigationPathDefaults

protected void populateNavigationPathDefaults(Action action)
Convenience method to populate the site root path and content path of the given action using the configured ActionPathProvider.

See Also:
getActionPathProvider()

initialize

public ConfigType initialize(ContentItem pContentItem)
                                          throws CartridgeHandlerException
Uses the ContentItemInitializer, if one has been set, to create the full configuration for this cartridge. If no ContentItemInitializer has been set, simply wraps the input ContentItem using the wrapConfig(com.endeca.infront.assembler.ContentItem) method.

Specified by:
initialize in interface CartridgeHandler<ConfigType extends ContentItem>
Parameters:
pContentItem - cartridge instance configuration, typically from Experience Manager.
Returns:
Full configuration for this cartridge. It is not expected that this configuration will be further modified by the preprocess(ConfigType) or process(ConfigType) methods.
Throws:
CartridgeHandlerException - if an error occurs that is scoped to an individual cartridge instance (for instance, the handler is unable to access its default configuration). This exception will not halt the entire assembly process, which occurs across multiple cartridges; instead, this exception will be packaged in the overall response model. If an unchecked exception is thrown, then the entire assembly process will be halted.
See Also:
setContentItemInitializer(ContentItemInitializer), wrapConfig(ContentItem)

preprocess

public void preprocess(ConfigType pContentItem)
                throws CartridgeHandlerException
The default implementation does nothing.

Specified by:
preprocess in interface CartridgeHandler<ConfigType extends ContentItem>
Parameters:
pContentItem - the cartridge configuration returned by CartridgeHandler.initialize(ContentItem). This cartridge configuration may be modified by this handler. Note that this cartridge configuration is also passed to CartridgeHandler.process(ContentItem).
Throws:
CartridgeHandlerException - if an error occurs that is scoped to an individual cartridge instance. This exception will not halt the entire assembly process, which occurs across multiple cartridges; instead, this exception will be packaged in the overall response model. If an unchecked exception is thrown, then the entire assembly process will be halted.

process

public ModelType process(ConfigType pContentItem)
                                      throws CartridgeHandlerException
The default implementation does nothing and returns null.

Specified by:
process in interface CartridgeHandler<ConfigType extends ContentItem>
Parameters:
pContentItem - the cartridge configuration returned by CartridgeHandler.initialize(ContentItem). Note that this instance may have been modified by the CartridgeHandler.preprocess(ContentItem) method.
Returns:
the output value for this cartridge. If null is returned, then the corresponding node in the output tree will be deleted.
Throws:
CartridgeHandlerException - if an error occurs that is scoped to an individual cartridge instance. This exception will not halt the entire assembly process, which occurs across multiple cartridges; instead, this exception will be packaged in the overall response model. If an unchecked exception is thrown, then the entire assembly process will be halted.

createMdexRequest

protected com.endeca.infront.navigation.request.MdexRequest createMdexRequest(FilterState pFilterState,
                                                                              com.endeca.infront.navigation.request.MdexQuery pMdexQuery)
                                                                       throws CartridgeHandlerException

Convenience method that wraps the MdexRequestBroker.createMdexRequest(FilterState, MdexQuery) method, throwing a CartridgeHandlerException if a NavigationException is caught.

All NavigationCartridgeHandler subclasses included in the Assembler also use this method, which provides an extension mechanism for subclasses of those CartridgeHandler classes to intercept the MdexQuery built by the cartridge handler before it's sent to the MdexRequestBroker

Create an MdexRequest and returns it, enabling a later call to executeMdexRequest(MdexRequest) to execute it. By convention, this method is called by the subclass preprocess(ContentItem) method implementation.

Parameters:
pFilterState - the input filter state
pMdexQuery - the input MDEX feature query
Throws:
CartridgeHandlerException - if the operation fails

executeMdexRequest

protected com.endeca.navigation.ENEQueryResults executeMdexRequest(com.endeca.infront.navigation.request.MdexRequest mdexRequest)
                                                            throws CartridgeHandlerException

Convenience method that wraps the MdexRequest.execute(), throwing a CartridgeHandlerException if a NavigationException is caught.

By convention, this method is called by the subclass process(ContentItem) method implementation, with an MdexRequest previously created by createMdexRequest(FilterState, MdexQuery).

Subclasses are responsible for calling NavigationState.inform with the ENEQueryResults returned by this method. If NavigationState.inform is not called, the SeoUrlFormatter may not fully generate SEO links.

Parameters:
mdexRequest - cannot be null
Returns:
the Presentation API query result object
Throws:
CartridgeHandlerException - if the request fails

wrapConfig

protected abstract ConfigType wrapConfig(ContentItem item)
Wraps the input ContentItem as a typed config object. It is not expected that subclasses will mutate the input ContentItem, beyond passing it into their typed configuration class as a constructor argument.

Parameters:
item - the configuration for this cartridge handler. This will either be the fully initialized configuration object, if a ContentItemInitializer has been set, or it will simply be the instance configuration.
Returns:
an instance of ConfigType which wraps the input ContentItem.
See Also:
initialize(ContentItem), setContentItemInitializer(ContentItemInitializer)

dispatchNavigationEventInformation

protected void dispatchNavigationEventInformation(com.endeca.navigation.ENEQueryResults pMdexResponse)
Tracks all Navigation State related information



Copyright © 2012, Oracle and/or its affiliates. All rights reserved.