Class DefaultEventType
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.repository.events.DefaultEventType
-
- All Implemented Interfaces:
EventType
,LogEnabled
,PluginAware
,Configurable
,Serviceable
- Direct Known Subclasses:
WorkspacesEventType
public class DefaultEventType extends AbstractLogEnabled implements Configurable, EventType, Serviceable, PluginAware
Default implementation forEventType
storing event in JCR
-
-
Field Summary
Fields Modifier and Type Field Description private static int
__MAX_MERGE_EVENT_RANGE
The default time range to merge compatible events : 5 minutesprotected CurrentUserProvider
_currentUserProvider
The current user providerprivate String
_pluginName
private Map<String,I18nizableText>
_supportedEventTypes
protected UserHelper
_userHelper
Helper to get users-
Fields inherited from interface org.ametys.plugins.repository.events.EventType
EVENT_AUTHOR, EVENT_DATE, EVENT_TYPE
-
-
Constructor Summary
Constructors Constructor Description DefaultEventType()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected UserIdentity
_getAuthor(Node eventNode)
Gets the identity of the author of the given eventvoid
configure(Configuration configuration)
Map<String,Object>
event2JSON(Node eventNode)
Format an event node to JSONMap<String,I18nizableText>
getSupportedTypes()
Get the ids of the supported event typesboolean
isMergeable(Map<String,Object> event1, Map<String,Object> event2)
Determines if two events can be mergedMap<String,Object>
mergeEvents(List<Map<String,Object>> events)
Merge events into one event.void
service(ServiceManager serviceManager)
void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.protected void
storeAdditionalEventData(Node eventNode, Map<String,Object> parameters)
Store additional data on eventNode
storeEvent(String eventId, Map<String,Object> parameters, EventHolder eventHolder)
Store an event with the given event id under the given event holder node-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__MAX_MERGE_EVENT_RANGE
private static final int __MAX_MERGE_EVENT_RANGE
The default time range to merge compatible events : 5 minutes- See Also:
- Constant Field Values
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_userHelper
protected UserHelper _userHelper
Helper to get users
-
_supportedEventTypes
private Map<String,I18nizableText> _supportedEventTypes
-
_pluginName
private String _pluginName
-
-
Constructor Detail
-
DefaultEventType
public DefaultEventType()
-
-
Method Detail
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getSupportedTypes
public Map<String,I18nizableText> getSupportedTypes()
Description copied from interface:EventType
Get the ids of the supported event types- Specified by:
getSupportedTypes
in interfaceEventType
- Returns:
- the ids of the supported event types
-
storeEvent
public Node storeEvent(String eventId, Map<String,Object> parameters, EventHolder eventHolder) throws RepositoryException
Description copied from interface:EventType
Store an event with the given event id under the given event holder node- Specified by:
storeEvent
in interfaceEventType
- Parameters:
eventId
- the id of the event to storeparameters
- the event parameterseventHolder
- the event holder- Returns:
- the stored node
- Throws:
RepositoryException
- if an error occurs while manipulating the repository
-
storeAdditionalEventData
protected void storeAdditionalEventData(Node eventNode, Map<String,Object> parameters) throws RepositoryException
Store additional data on event- Parameters:
eventNode
- The event nodeparameters
- The event's parameters- Throws:
RepositoryException
- if an error occurred
-
event2JSON
public Map<String,Object> event2JSON(Node eventNode) throws RepositoryException
Description copied from interface:EventType
Format an event node to JSON- Specified by:
event2JSON
in interfaceEventType
- Parameters:
eventNode
- the node of an event- Returns:
- the JSON for the node
- Throws:
RepositoryException
- if an error occurs while manipulating the repository
-
_getAuthor
protected UserIdentity _getAuthor(Node eventNode) throws RepositoryException
Gets the identity of the author of the given event- Parameters:
eventNode
- The node of the event- Returns:
- the identity of the author of the given event
- Throws:
RepositoryException
- if an error occurs while manipulating the repository
-
isMergeable
public boolean isMergeable(Map<String,Object> event1, Map<String,Object> event2)
Description copied from interface:EventType
Determines if two events can be merged- Specified by:
isMergeable
in interfaceEventType
- Parameters:
event1
- The first eventevent2
- The second event- Returns:
- true if the events can be merged
-
mergeEvents
public Map<String,Object> mergeEvents(List<Map<String,Object>> events)
Description copied from interface:EventType
Merge events into one event. Be careful : be sure that the events can be merged calling isMergeable method before- Specified by:
mergeEvents
in interfaceEventType
- Parameters:
events
- The events to merge- Returns:
- Merged event
-
-