use of org.xwiki.eventstream.EventStreamException in project xwiki-platform by xwiki.
the class DefaultModelBridge method findDocument.
private XWikiDocument findDocument(EntityReference entityReference) throws EventStreamException {
XWikiContext context = contextProvider.get();
XWiki xwiki = context.getWiki();
try {
return xwiki.getDocument(entityReference, context);
} catch (XWikiException e) {
throw new EventStreamException(String.format("Unable to retrieve the given document [%s] in the current context.", entityReference), e);
}
}
use of org.xwiki.eventstream.EventStreamException in project xwiki-platform by xwiki.
the class DefaultUntypedRecordableEventDescriptor method setProperties.
/**
* Set the object attributes by extracting their values from the given BaseObject.
*
* @param untypedEventObject the XObject that should contain the desired values
* @throws EventStreamException if the properties could not be extracted
*/
private void setProperties(BaseObject untypedEventObject) throws EventStreamException {
try {
this.eventType = untypedEventObject.getStringValue(UNTYPED_EVENT_EVENT_TYPE);
this.validationExpression = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_VALIDATION_EXPRESSION);
this.target = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_TARGET);
this.objectTypes = untypedEventObject.getListValue(UNTYPED_EVENT_DESCRIPTOR_OBJECT_TYPE);
this.eventDescription = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_DESCRIPTION);
this.eventTriggers = untypedEventObject.getListValue(UNTYPED_EVENT_DESCRIPTOR_EVENT_TRIGGERS);
this.applicationName = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_APPLICATION_NAME);
// If the applicationId property is not defined, fallback on the applicationName
String rawApplicationIdProperty = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_APPLICATION_ID);
this.applicationId = (rawApplicationIdProperty != null && StringUtils.isNotBlank(rawApplicationIdProperty)) ? rawApplicationIdProperty : this.applicationName;
this.applicationIcon = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_APPLICATION_ICON);
this.eventTypeIcon = untypedEventObject.getStringValue(UNTYPED_EVENT_DESCRIPTOR_EVENT_TYPE_ICON);
} catch (Exception e) {
throw new EventStreamException(String.format("Unable to extract the parameters of the [%s] EventClass.", untypedEventObject), e);
}
}
use of org.xwiki.eventstream.EventStreamException in project xwiki-platform by xwiki.
the class DefaultRecordableEventDescriptorManager method getRecordableEventDescriptors.
@Override
public List<RecordableEventDescriptor> getRecordableEventDescriptors(boolean allWikis) throws EventStreamException {
try {
// We use an hashSet to be sure we won't store the same descriptor twice (in case the same application
// is installed on several wikis).
Set<RecordableEventDescriptor> recordableEventDescriptors = new HashSet<>();
// Load the component from the context component manager (root + wiki + user component managers, etc...)
recordableEventDescriptors.addAll(contextComponentManager.getInstanceList(RecordableEventDescriptor.class));
// Maybe add components of the other wikis too
if (allWikis) {
for (String wikiId : wikiDescriptorManager.getAllIds()) {
recordableEventDescriptors.addAll(getDescriptorsFromWiki(wikiId));
}
}
return new ArrayList<>(recordableEventDescriptors);
} catch (WikiManagerException | ComponentLookupException e) {
throw new EventStreamException("Failed to get the list of all Recordable Event Descriptors.", e);
}
}
use of org.xwiki.eventstream.EventStreamException in project xwiki-platform by xwiki.
the class LiveNotificationEmailListener method onEvent.
@Override
public void onEvent(Event event, Object o, Object o1) {
// notifications is enabled.
if (this.notificationConfiguration.isEnabled() && this.notificationConfiguration.areEmailsEnabled()) {
try {
org.xwiki.eventstream.Event eventStreamEvent = (org.xwiki.eventstream.Event) o;
// We can’t directly store a list of RecordableEventDescriptors as some of them can be
// dynamically defined at runtime.
List<RecordableEventDescriptor> descriptorList = this.recordableEventDescriptorManager.getRecordableEventDescriptors(true);
// Try to match one of the given descriptors with the current event.
for (RecordableEventDescriptor descriptor : descriptorList) {
// Find a descriptor that corresponds to the given event
if (descriptor.getEventType().equals(eventStreamEvent.getType())) {
// Add the event to the live notification email queue
this.liveNotificationEmailManager.addEvent(eventStreamEvent);
this.startNotificationThread();
}
}
} catch (EventStreamException e) {
logger.warn("Unable to retrieve a full list of RecordableEventDescriptor.", e);
}
}
}
Aggregations