Package org.ametys.cms.indexing.explorer
Class AbstractSolrIndexResourceObserver
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.cms.indexing.explorer.AbstractSolrIndexResourceObserver
-
- All Implemented Interfaces:
AsyncObserver
,Observer
,LogEnabled
,Contextualizable
,Serviceable
- Direct Known Subclasses:
ContentAttachmentsSolrObserver
,PageAttachmentsSolrObserver
,SolrIndexProjectResourceObserver
,SolrIndexResourceObserver
public abstract class AbstractSolrIndexResourceObserver extends AbstractLogEnabled implements AsyncObserver, Contextualizable, Serviceable
Abstract observer in charge of indexing resources when created, modified, moved...
-
-
Field Summary
Fields Modifier and Type Field Description protected Context
_context
The component context.protected AmetysObjectResolver
_resolver
The AmetysObject resolver.protected SolrIndexer
_solrIndexer
The Solr indexer.static String
DISABLE_INDEXING_KEY
Request attribute disabling content indexation when set totrue
.-
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractSolrIndexResourceObserver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
_index(Event event, String workspaceName)
Perform the indexation processvoid
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.protected abstract String[]
getWorkspacesToIndex()
Get the list of workspace to indexprotected abstract boolean
isHandledResource(AmetysObject object)
Returns true if it is aResource
orResourceCollection
handled by this observervoid
observe(Event event, Map<String,Object> transientVars)
Observes an event.protected abstract void
onCollectionRenamedOrMoved(ResourceCollection resourceCollection, String workspaceName)
Method called when a resource collection handled by this observer is renamed or moved.protected abstract void
onResourceCreated(Resource resource, String workspaceName)
Method called when a resource handled by this observer is created.protected abstract void
onResourceUpdated(Resource resource, String workspaceName)
Method called when a resource handled by this observer is updated, moved or renamed.void
service(ServiceManager serviceManager)
boolean
supports(Event event)
Checks if the event is supported.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.core.observation.AsyncObserver
parallelizable
-
-
-
-
Field Detail
-
DISABLE_INDEXING_KEY
public static final String DISABLE_INDEXING_KEY
Request attribute disabling content indexation when set totrue
.
-
_solrIndexer
protected SolrIndexer _solrIndexer
The Solr indexer.
-
_resolver
protected AmetysObjectResolver _resolver
The AmetysObject resolver.
-
-
Constructor Detail
-
AbstractSolrIndexResourceObserver
public AbstractSolrIndexResourceObserver()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
supports
public boolean supports(Event event)
Description copied from interface:Observer
Checks if the event is supported. If true, the observe(Event) method will be called.
-
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.
-
getWorkspacesToIndex
protected abstract String[] getWorkspacesToIndex()
Get the list of workspace to index- Returns:
- An array of workspace names
-
_index
protected void _index(Event event, String workspaceName) throws IndexingException
Perform the indexation process- Parameters:
event
- The current eventworkspaceName
- The workspace name for the indexation- Throws:
IndexingException
- if an error occurs during indexation.
-
isHandledResource
protected abstract boolean isHandledResource(AmetysObject object)
Returns true if it is aResource
orResourceCollection
handled by this observer- Parameters:
object
- The resource or collection- Returns:
- true if it is handled by this observer
-
onResourceCreated
protected abstract void onResourceCreated(Resource resource, String workspaceName) throws Exception
Method called when a resource handled by this observer is created. Typically for indexing the created resource.- Parameters:
resource
- The created resourceworkspaceName
- The workspace name- Throws:
Exception
- if an error occurs
-
onResourceUpdated
protected abstract void onResourceUpdated(Resource resource, String workspaceName) throws Exception
Method called when a resource handled by this observer is updated, moved or renamed. Typically for indexing the updated resource.- Parameters:
resource
- The updated resourceworkspaceName
- The workspace name- Throws:
Exception
- if an error occurs
-
onCollectionRenamedOrMoved
protected abstract void onCollectionRenamedOrMoved(ResourceCollection resourceCollection, String workspaceName) throws Exception
Method called when a resource collection handled by this observer is renamed or moved. Typically for indexing the children of the resource collection.- Parameters:
resourceCollection
- The resource collectionworkspaceName
- The workspace name- Throws:
Exception
- if an error occurs
-
-