Class AbstractLiveSolrObserver
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.web.indexing.observation.AbstractLiveSolrObserver
-
- All Implemented Interfaces:
Observer
,LogEnabled
,Contextualizable
,Serviceable
- Direct Known Subclasses:
AbstractTagObserver
,SolrContentUnpublishedPart1Observer
,SolrContentUnpublishedPart2Observer
,SolrLiveContentValidatedOrTaggedObserver
,SolrPageMovePart1Observer
,SolrPageMovePart2Observer
,SolrPageRenameObserver
public abstract class AbstractLiveSolrObserver extends AbstractLogEnabled implements Observer, Contextualizable, Serviceable
AbstractObserver
for synchronizing the live solr index.
-
-
Field Summary
Fields Modifier and Type Field Description protected Context
_context
The Avalon context.protected AmetysObjectResolver
_resolver
The ametys object resolver.protected SolrIndexer
_solrIndexer
The Solr indexer.protected SolrPageIndexer
_solrPageIndexer
The Solr page indexer.-
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractLiveSolrObserver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
_deletePageDocumentsForContent(String contentId)
Deletes Solr page documents associated with a content.protected Page
_getPageInLive(String pageId)
Returns the page in the live workspace corresponding to a given id.protected abstract void
_updateIndex(Event event, Map<String,Object> transientVars)
Update the index from the event observed.protected void
_updatePageDocument(String pageId)
Updates a Solr document referencing a page.protected void
_updatePageDocument(String pageId, boolean indexRecursively)
Updates a Solr document referencing a page.protected void
_updatePageDocumentsForContent(String contentId)
Updates Solr page documents associated with a content.void
contextualize(Context context)
int
getPriority(Event event)
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.void
observe(Event event, Map<String,Object> transientVars)
Observes an event.void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_solrIndexer
protected SolrIndexer _solrIndexer
The Solr indexer.
-
_solrPageIndexer
protected SolrPageIndexer _solrPageIndexer
The Solr page indexer.
-
-
Constructor Detail
-
AbstractLiveSolrObserver
public AbstractLiveSolrObserver()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getPriority
public int getPriority(Event event)
Description copied from interface:Observer
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriority
in interfaceObserver
- Parameters:
event
- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
observe
public void observe(Event event, Map<String,Object> transientVars) throws Exception
Description copied from interface:Observer
Observes an event.- Specified by:
observe
in interfaceObserver
- Parameters:
event
- the event.transientVars
- transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.- Throws:
Exception
- if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
-
_updateIndex
protected abstract void _updateIndex(Event event, Map<String,Object> transientVars) throws Exception
Update the index from the event observed.- Parameters:
event
- the event.transientVars
- the transient vars passed from one Observer to another when processing a single Event.- Throws:
Exception
- if an error occurs.
-
_updatePageDocumentsForContent
protected void _updatePageDocumentsForContent(String contentId) throws Exception
Updates Solr page documents associated with a content.- Parameters:
contentId
- the content id.- Throws:
Exception
- if an error occurs.
-
_deletePageDocumentsForContent
protected void _deletePageDocumentsForContent(String contentId) throws Exception
Deletes Solr page documents associated with a content.- Parameters:
contentId
- the content id.- Throws:
Exception
- if an error occurs.
-
_updatePageDocument
protected void _updatePageDocument(String pageId) throws Exception
Updates a Solr document referencing a page.- Parameters:
pageId
- the page id.- Throws:
Exception
- if an error occurs.
-
_updatePageDocument
protected void _updatePageDocument(String pageId, boolean indexRecursively) throws Exception
Updates a Solr document referencing a page.- Parameters:
pageId
- the page id.indexRecursively
- to also process children pages.- Throws:
Exception
- if an error occurs.
-
_getPageInLive
protected Page _getPageInLive(String pageId)
Returns the page in the live workspace corresponding to a given id.- Parameters:
pageId
- the page id.- Returns:
- the page in the live workspace or null if not present.
-
-