use of org.xwiki.eventstream.events.EventStreamDeletedEvent in project xwiki-platform by xwiki.
the class ActivityStreamImpl method deleteActivityEvent.
@Override
public void deleteActivityEvent(ActivityEvent event, XWikiContext context) throws ActivityStreamException {
boolean bTransaction = true;
ActivityEventImpl evImpl = loadActivityEvent(event, true, context);
String oriDatabase = context.getWikiId();
if (useLocalStore()) {
XWikiHibernateStore hibstore;
// delete event from the local database
if (context.getWikiId().equals(event.getWiki())) {
hibstore = context.getWiki().getHibernateStore();
} else {
context.setWikiId(event.getWiki());
hibstore = context.getWiki().getHibernateStore();
}
try {
if (bTransaction) {
hibstore.checkHibernate(context);
bTransaction = hibstore.beginTransaction(context);
}
Session session = hibstore.getSession(context);
session.delete(evImpl);
if (bTransaction) {
hibstore.endTransaction(context, true);
}
} catch (XWikiException e) {
throw new ActivityStreamException();
} finally {
try {
if (bTransaction) {
hibstore.endTransaction(context, false);
}
if (context.getWikiId().equals(oriDatabase)) {
context.setWikiId(oriDatabase);
}
} catch (Exception e) {
// Do nothing.
}
}
}
if (useMainStore()) {
// delete event from the main database
context.setWikiId(context.getMainXWiki());
XWikiHibernateStore hibstore = context.getWiki().getHibernateStore();
try {
if (bTransaction) {
hibstore.checkHibernate(context);
bTransaction = hibstore.beginTransaction(context);
}
Session session = hibstore.getSession(context);
session.delete(evImpl);
if (bTransaction) {
hibstore.endTransaction(context, true);
}
} catch (XWikiException e) {
throw new ActivityStreamException();
} finally {
try {
if (bTransaction) {
hibstore.endTransaction(context, false);
}
context.setWikiId(oriDatabase);
} catch (Exception e) {
// Do nothing
}
}
}
this.sendEventStreamEvent(new EventStreamDeletedEvent(), event);
}
use of org.xwiki.eventstream.events.EventStreamDeletedEvent in project xwiki-platform by xwiki.
the class BridgeEventStream method deleteEvent.
@Override
public void deleteEvent(Event e) {
try {
XWikiContext context = getXWikiContext();
ActivityStreamPlugin plugin = getPlugin(context);
plugin.getActivityStream().deleteActivityEvent(eventConverter.convertEventToActivity(e), context);
this.observationManager.notify(new EventStreamDeletedEvent(), e);
} catch (ActivityStreamException ex) {
// Unlikely; nothing we can do
}
}
Aggregations