Class EventServiceImpl
- java.lang.Object
-
- org.apache.unomi.services.impl.events.EventServiceImpl
-
- All Implemented Interfaces:
EventService
public class EventServiceImpl extends Object implements EventService
-
-
Field Summary
-
Fields inherited from interface org.apache.unomi.api.services.EventService
ERROR, NO_CHANGE, PROFILE_UPDATED, SESSION_UPDATED
-
-
Constructor Summary
Constructors Constructor Description EventServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringauthenticateThirdPartyServer(String key, String ip)Get the third party server name, if the request is originated from a known peervoidbind(org.osgi.framework.ServiceReference<EventListenerService> serviceReference)EventgetEvent(String id)Retrieves theEventby its identifier.List<EventProperty>getEventProperties()Retrieves the list of available event properties.Set<String>getEventTypeIds()Retrieves the set of known event type identifiers.booleanhasEventAlreadyBeenRaised(Event event)Checks whether the specified event has already been raised with the same itemId.booleanhasEventAlreadyBeenRaised(Event event, boolean session)Checks whether the specified event has already been raised either for the associated session or profile depending on the specifiedsessionparameter.booleanisEventAllowed(Event event, String thirdPartyId)Check if the sender is allowed to sent the speecified event.voidremoveProfileEvents(String profileId)Removes all events of the specified profilePartialList<Event>search(Query query)PartialList<Event>searchEvents(String sessionId, String[] eventTypes, String query, int offset, int size, String sortBy)PartialList<Event>searchEvents(Condition condition, int offset, int size)intsend(Event event)Propagates the specified event in the context server, notifyingEventListenerServiceinstances if needed.voidsetBundleContext(org.osgi.framework.BundleContext bundleContext)voidsetDefinitionsService(DefinitionsService definitionsService)voidsetPersistenceService(PersistenceService persistenceService)voidsetPredefinedEventTypeIds(Set<String> predefinedEventTypeIds)voidsetRestrictedEventTypeIds(Set<String> restrictedEventTypeIds)voidsetThirdPartyConfiguration(Map<String,String> thirdPartyConfiguration)voidunbind(org.osgi.framework.ServiceReference<EventListenerService> serviceReference)
-
-
-
Method Detail
-
setThirdPartyConfiguration
public void setThirdPartyConfiguration(Map<String,String> thirdPartyConfiguration)
-
setPredefinedEventTypeIds
public void setPredefinedEventTypeIds(Set<String> predefinedEventTypeIds)
-
setRestrictedEventTypeIds
public void setRestrictedEventTypeIds(Set<String> restrictedEventTypeIds)
-
setPersistenceService
public void setPersistenceService(PersistenceService persistenceService)
-
setDefinitionsService
public void setDefinitionsService(DefinitionsService definitionsService)
-
setBundleContext
public void setBundleContext(org.osgi.framework.BundleContext bundleContext)
-
isEventAllowed
public boolean isEventAllowed(Event event, String thirdPartyId)
Description copied from interface:EventServiceCheck if the sender is allowed to sent the speecified event. Restricted event must be explicitely allowed for a sender.- Specified by:
isEventAllowedin interfaceEventService- Parameters:
event- event to testthirdPartyId- third party id- Returns:
- true if the event is allowed
-
authenticateThirdPartyServer
public String authenticateThirdPartyServer(String key, String ip)
Description copied from interface:EventServiceGet the third party server name, if the request is originated from a known peer- Specified by:
authenticateThirdPartyServerin interfaceEventService- Parameters:
key- the keyip- the ip- Returns:
- server name
-
send
public int send(Event event)
Description copied from interface:EventServicePropagates the specified event in the context server, notifyingEventListenerServiceinstances if needed. If the event is persistent (Event.isPersistent(), it will be persisted appropriately. Once the event is propagated, anyActionPostExecutorthe event defined will be executed and the user profile updated if needed.- Specified by:
sendin interfaceEventService- Parameters:
event- the Event to be propagated- Returns:
- the result of the event handling as combination of EventService flags, to be checked using bitwise AND (&) operator
-
getEventProperties
public List<EventProperty> getEventProperties()
Description copied from interface:EventServiceRetrieves the list of available event properties.- Specified by:
getEventPropertiesin interfaceEventService- Returns:
- a list of available event properties
-
getEventTypeIds
public Set<String> getEventTypeIds()
Description copied from interface:EventServiceRetrieves the set of known event type identifiers.- Specified by:
getEventTypeIdsin interfaceEventService- Returns:
- the set of known event type identifiers.
-
searchEvents
public PartialList<Event> searchEvents(Condition condition, int offset, int size)
Description copied from interface:EventServiceRetrievesEvents matching the specifiedCondition. Events are ordered according to their time stamp (Event.getTimeStamp()and paged: onlysizeof them are retrieved, starting with theoffset-th one.- Specified by:
searchEventsin interfaceEventService- Parameters:
condition- the Condition we want the Events to match to be retrievedoffset- zero or a positive integer specifying the position of the first event in the total ordered collection of matching eventssize- a positive integer specifying how many matching events should be retrieved or-1if all of them should be retrieved- Returns:
- a
PartialListof matching events
-
searchEvents
public PartialList<Event> searchEvents(String sessionId, String[] eventTypes, String query, int offset, int size, String sortBy)
Description copied from interface:EventServiceRetrievesEvents for theSessionidentified by the provided session identifier, matching any of the provided event types, ordered according to the specifiedsortByString and paged: onlysizeof them are retrieved, starting with theoffset-th one. If aqueryis provided, a full text search is performed on the matching events to further filter them.- Specified by:
searchEventsin interfaceEventService- Parameters:
sessionId- the identifier of the user session we're consideringeventTypes- an array of event type names; the events to retrieve should at least match one of thesequery- a String to perform full text filtering on events matching the other conditionsoffset- zero or a positive integer specifying the position of the first event in the total ordered collection of matching eventssize- a positive integer specifying how many matching events should be retrieved or-1if all of them should be retrievedsortBy- an optional (nullif no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier:ascordesc.- Returns:
- a
PartialListof matching events
-
search
public PartialList<Event> search(Query query)
Description copied from interface:EventService- Specified by:
searchin interfaceEventService- Parameters:
query- aQueryspecifying which Events to retrieve- Returns:
- a
PartialListofEventinstances matching the specified query
-
getEvent
public Event getEvent(String id)
Description copied from interface:EventServiceRetrieves theEventby its identifier.- Specified by:
getEventin interfaceEventService- Parameters:
id- the identifier of theEventto retrieve- Returns:
- the
Eventidentified by the specified identifier ornullif no such profile exists
-
hasEventAlreadyBeenRaised
public boolean hasEventAlreadyBeenRaised(Event event)
Description copied from interface:EventServiceChecks whether the specified event has already been raised with the same itemId.- Specified by:
hasEventAlreadyBeenRaisedin interfaceEventService- Parameters:
event- the event we want to check- Returns:
trueif the event has already been raised,falseotherwise
-
hasEventAlreadyBeenRaised
public boolean hasEventAlreadyBeenRaised(Event event, boolean session)
Description copied from interface:EventServiceChecks whether the specified event has already been raised either for the associated session or profile depending on the specifiedsessionparameter.- Specified by:
hasEventAlreadyBeenRaisedin interfaceEventService- Parameters:
event- the event we want to checksession-trueif we want to check if the specified event has already been raised for the associated session,falseif we want to check whether the event has already been raised for the associated profile- Returns:
trueif the event has already been raised,falseotherwise
-
bind
public void bind(org.osgi.framework.ServiceReference<EventListenerService> serviceReference)
-
unbind
public void unbind(org.osgi.framework.ServiceReference<EventListenerService> serviceReference)
-
removeProfileEvents
public void removeProfileEvents(String profileId)
Description copied from interface:EventServiceRemoves all events of the specified profile- Specified by:
removeProfileEventsin interfaceEventService- Parameters:
profileId- identifier of the profile that we want to remove it's events
-
-