public abstract class NavigationCartridgeHandler<ConfigType extends ContentItem,ModelType extends ContentItem> extends Object implements CartridgeHandler<ConfigType>
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 and Description |
---|
NavigationCartridgeHandler() |
Modifier and Type | Method and Description |
---|---|
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. |
protected com.endeca.navigation.ENEQueryResults |
executeMdexRequest(com.endeca.infront.navigation.request.MdexRequest mdexRequest,
boolean trackNavigationEvent)
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. |
public void setContentItemInitializer(ContentItemInitializer initializer)
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.initializer
- may be nullCartridgeHandler.initialize(ContentItem)
public ContentItemInitializer getContentItemInitializer()
ContentItemInitializer
used to create the full cartridge
configuration.protected MdexRequestBroker getMdexRequestBroker()
NavigationCartridgeHandler
and NavigationStateBuilder
. Use
of the MdexRequestBroker in other classes is not supported.public void setMdexRequestBroker(MdexRequestBroker pMdexRequestBroker)
public NavigationState getNavigationState()
public void setNavigationState(NavigationState pNavigationState)
public ActionPathProvider getActionPathProvider()
Action
objects.public void setActionPathProvider(ActionPathProvider pActionPathProvider)
Action
objects.protected void populateNavigationPathDefaults(Action action)
ActionPathProvider
.getActionPathProvider()
public ConfigType initialize(ContentItem pContentItem) throws CartridgeHandlerException
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.initialize
in interface CartridgeHandler<ConfigType extends ContentItem>
pContentItem
- cartridge instance configuration, typically
from Experience Manager.preprocess(ConfigType)
or process(ConfigType)
methods.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.setContentItemInitializer(ContentItemInitializer)
,
wrapConfig(ContentItem)
public void preprocess(ConfigType pContentItem) throws CartridgeHandlerException
preprocess
in interface CartridgeHandler<ConfigType extends ContentItem>
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)
.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.public ModelType process(ConfigType pContentItem) throws CartridgeHandlerException
process
in interface CartridgeHandler<ConfigType extends ContentItem>
pContentItem
- the cartridge configuration returned by
CartridgeHandler.initialize(ContentItem)
. Note that this instance may have been modified by
the CartridgeHandler.preprocess(ContentItem)
method.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.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.
pFilterState
- the input filter statepMdexQuery
- the input MDEX feature queryCartridgeHandlerException
- if the operation failsprotected 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)
.
mdexRequest
- cannot be nullCartridgeHandlerException
- if the request failsprotected com.endeca.navigation.ENEQueryResults executeMdexRequest(com.endeca.infront.navigation.request.MdexRequest mdexRequest, boolean trackNavigationEvent) 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)
.
mdexRequest
- cannot be nulltrackNavigationEvent
- only track the results of this request with the assmelber logging
framework if this is trueCartridgeHandlerException
- if the request failsprotected abstract ConfigType wrapConfig(ContentItem item)
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.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.ConfigType
which wraps the input ContentItem
.initialize(ContentItem)
,
setContentItemInitializer(ContentItemInitializer)
protected void dispatchNavigationEventInformation(com.endeca.navigation.ENEQueryResults pMdexResponse)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.