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 protected CurrentUserProvider
_currentUserProvider
The current user providerprotected UserHelper
_userHelper
Helper to get usersstatic String
AUTHOR
Constant for event's author JSON key.static String
DATE
Constant for event's date JSON key.static String
NAME
Constant for event's name JSON key.static String
TYPE
Constant for event's type JSON key.-
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
-
NAME
public static final String NAME
Constant for event's name JSON key. The stored value is aString
.- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
Constant for event's type JSON key. The stored value is aString
.- See Also:
- Constant Field Values
-
DATE
public static final String DATE
Constant for event's date JSON key. The stored value is aCalendar
.- See Also:
- Constant Field Values
-
AUTHOR
public static final String AUTHOR
Constant for event's author JSON key. The stored value is aMap
.- See Also:
- Constant Field Values
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_userHelper
protected UserHelper _userHelper
Helper to get users
-
-
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
-
-