### Eclipse Workspace Patch 1.0
#P xwiki-core-observation-api
Index: src/main/java/org/xwiki/observation/event/AbstractCancelableEvent.java
===================================================================
--- src/main/java/org/xwiki/observation/event/AbstractCancelableEvent.java (revision 32659)
+++ src/main/java/org/xwiki/observation/event/AbstractCancelableEvent.java (working copy)
@@ -56,7 +56,7 @@
*/
protected AbstractCancelableEvent(String name)
{
- super(name);
+ super(name, null);
}
/**
Index: src/main/java/org/xwiki/observation/event/AbstractFilterableEvent.java
===================================================================
--- src/main/java/org/xwiki/observation/event/AbstractFilterableEvent.java (revision 32659)
+++ src/main/java/org/xwiki/observation/event/AbstractFilterableEvent.java (working copy)
@@ -45,6 +45,11 @@
private EventFilter eventFilter;
/**
+ * An identifier to retrieve information about the event.
+ * */
+ private String identifier;
+
+ /**
* Constructor initializing the event filter with an
* {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will
* match any other event of the same type.
@@ -58,11 +63,13 @@
* Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter},
* meaning that this event will match only events of the same type affecting the same passed name.
*
- * @param name a generic name that uniquely identifies an event type
+ * @param name a generic name that identifies an event type
+ * @param identifier - a generic name which identidies the event in its class of events
*/
- public AbstractFilterableEvent(String name)
+ public AbstractFilterableEvent(String name, String identifier)
{
this.eventFilter = new FixedNameEventFilter(name);
+ this.identifier = identifier;
}
/**
@@ -76,6 +83,16 @@
}
/**
+ * Return the identifier used to log this event.
+ *
+ *@return the identifier for this event
+ */
+ public String getIdentifier()
+ {
+ return this.identifier;
+ }
+
+ /**
* {@inheritDoc}
* @see FilterableEvent#getEventFilter()
*/
Index: pom.xml
===================================================================
--- pom.xml (revision 32659)
+++ pom.xml (working copy)
@@ -27,7 +27,7 @@
org.xwiki.platform
xwiki-core-observation
- 2.7-SNAPSHOT
+ 2.6-rc-2
org.xwiki.platform
xwiki-core-observation-api
Index: src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
===================================================================
--- src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java (revision 32659)
+++ src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java (working copy)
@@ -49,7 +49,7 @@
*/
public AbstractDocumentEvent(String documentName)
{
- super(documentName);
+ super(documentName, null);
}
/**
#P xwiki-core-annotations-core
Index: src/main/java/org/xwiki/annotation/event/AnnotationDeletedEvent.java
===================================================================
--- src/main/java/org/xwiki/annotation/event/AnnotationDeletedEvent.java (revision 32668)
+++ src/main/java/org/xwiki/annotation/event/AnnotationDeletedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package org.xwiki.annotation.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class AnnotationDeletedEvent extends AbstractAnnotationEvent
+public class AnnotationDeletedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
Index: src/main/java/org/xwiki/annotation/event/AnnotationAddedEvent.java
===================================================================
--- src/main/java/org/xwiki/annotation/event/AnnotationAddedEvent.java (revision 32668)
+++ src/main/java/org/xwiki/annotation/event/AnnotationAddedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package org.xwiki.annotation.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class AnnotationAddedEvent extends AbstractAnnotationEvent
+public class AnnotationAddedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
Index: src/main/java/org/xwiki/annotation/event/AnnotationUpdatedEvent.java
===================================================================
--- src/main/java/org/xwiki/annotation/event/AnnotationUpdatedEvent.java (revision 32668)
+++ src/main/java/org/xwiki/annotation/event/AnnotationUpdatedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package org.xwiki.annotation.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class AnnotationUpdatedEvent extends AbstractAnnotationEvent
+public class AnnotationUpdatedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
#P xwiki-core
Index: src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- src/main/java/com/xpn/xwiki/XWiki.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/XWiki.java (working copy)
@@ -85,6 +85,9 @@
import org.exoplatform.container.RootContainer;
import org.hibernate.HibernateException;
import org.securityfilter.filter.URLPatternMatcher;
+import org.xwiki.annotation.event.AnnotationAddedEvent;
+import org.xwiki.annotation.event.AnnotationDeletedEvent;
+import org.xwiki.annotation.event.AnnotationUpdatedEvent;
import org.xwiki.cache.Cache;
import org.xwiki.cache.CacheException;
import org.xwiki.cache.CacheFactory;
@@ -111,6 +114,8 @@
import com.xpn.xwiki.internal.event.CommentAddedEvent;
import com.xpn.xwiki.internal.event.CommentDeletedEvent;
import com.xpn.xwiki.internal.event.CommentUpdatedEvent;
+import com.xpn.xwiki.internal.event.SystemEvent;
+
import org.xwiki.observation.event.DocumentDeleteEvent;
import org.xwiki.observation.event.DocumentSaveEvent;
import org.xwiki.observation.event.DocumentUpdateEvent;
@@ -3021,6 +3026,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated Tag Class"), doc, context);
}
return bclass;
}
@@ -3058,6 +3067,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated XWikiSheet Class"), doc, context);
}
return bclass;
}
@@ -3069,7 +3082,7 @@
*
* @param context the XWiki Context
* @return the XWikiUsers Base Class object containing the properties
- * @throws XWikiException if an error happens during the save to the datavase
+ * @throws XWikiException if an error happens during the save to the database
*/
public BaseClass getUserClass(XWikiContext context) throws XWikiException
{
@@ -3110,6 +3123,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated XWikiUsers Class"), doc, context);
}
return bclass;
@@ -3295,6 +3312,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated Preferences page"), doc, context);
}
return bclass;
}
@@ -3316,6 +3337,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated XWikiGroups Class"), doc, context);
}
// Create the group template document and attach a XWiki.XWikiGroupClass object
@@ -3394,6 +3419,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated" + title), doc, context);
}
return bclass;
}
@@ -3429,6 +3458,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated Comments Class"), doc, context);
}
return bclass;
}
@@ -3458,6 +3491,10 @@
if (needsUpdate) {
saveDocument(doc, context);
+
+ ObservationManager om = Utils.getComponent(ObservationManager.class);
+ String reference = this.defaultEntityReferenceSerializer.serialize(doc.getDocumentReference());
+ om.notify(new SystemEvent(reference, "Updated Skin Class"), doc, context);
}
return bclass;
}
@@ -7552,6 +7589,14 @@
} else {
om.notify(new CommentUpdatedEvent(reference, diff.getNumber() + ""), source, data);
}
+ }else if (StringUtils.equals(diff.getClassName(), "AnnotationCode.AnnotationClass")) {
+ if (StringUtils.equals(diff.getAction(), "object-removed")) {
+ om.notify(new AnnotationDeletedEvent(reference, diff.getNumber() + ""), source, data);
+ } else if (StringUtils.equals(diff.getAction(), "object-added")) {
+ om.notify(new AnnotationAddedEvent(reference, diff.getNumber() + ""), source, data);
+ } else {
+ om.notify(new AnnotationUpdatedEvent(reference, diff.getNumber() + ""), source, data);
+ }
}
break;
}
Index: src/main/java/com/xpn/xwiki/internal/event/AttachmentDeletedEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/AttachmentDeletedEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/AttachmentDeletedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class AttachmentDeletedEvent extends AbstractAttachmentEvent
+public class AttachmentDeletedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
@@ -52,11 +53,11 @@
* document name.
*
* @param documentName the name of the document to match
- * @param name the name of the deleted attachment
+ * @param identifier the name of the deleted attachment
*/
- public AttachmentDeletedEvent(String documentName, String name)
+ public AttachmentDeletedEvent(String documentName, String identifier)
{
- super(documentName, name);
+ super(documentName, identifier);
}
/**
Index: src/main/java/com/xpn/xwiki/internal/event/SystemEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/SystemEvent.java (revision 0)
+++ src/main/java/com/xpn/xwiki/internal/event/SystemEvent.java (revision 0)
@@ -0,0 +1,52 @@
+package com.xpn.xwiki.internal.event;
+
+import org.xwiki.observation.event.AbstractFilterableEvent;
+import org.xwiki.observation.event.filter.EventFilter;
+
+/**
+ * An event triggered when a system event occurs.
+ *
+ * @version $Id: $
+ * @since
+ */
+public class SystemEvent extends AbstractFilterableEvent
+{
+ /**
+ * The version identifier for this Serializable class. Increment only if the serialized form of the class
+ * changes.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor initializing the event filter with an
+ * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
+ * other attachment delete event.
+ */
+ public SystemEvent()
+ {
+ super();
+ }
+
+ /**
+ * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter},
+ * meaning that this event will match only attachment delete events affecting the document matching the passed
+ * document name.
+ *
+ * @param documentName the name of the document to match
+ * @param identifier the name of the deleted attachment
+ */
+ public SystemEvent(String documentName, String identifier)
+ {
+ super(documentName, identifier);
+ }
+
+ /**
+ * Constructor using a custom {@link EventFilter}.
+ *
+ * @param eventFilter the filter to use for matching events
+ */
+ public SystemEvent(EventFilter eventFilter)
+ {
+ super(eventFilter);
+ }
+}
Index: pom.xml
===================================================================
--- pom.xml (revision 32887)
+++ pom.xml (working copy)
@@ -771,6 +771,11 @@
org.xwiki.platform
+ xwiki-core-annotations-core
+ ${project.version}
+
+
+ org.xwiki.platform
xwiki-core-cache-jbosscache
${project.version}
Index: src/main/java/com/xpn/xwiki/internal/event/CommentDeletedEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/CommentDeletedEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/CommentDeletedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class CommentDeletedEvent extends AbstractCommentEvent
+public class CommentDeletedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
Index: src/main/java/com/xpn/xwiki/internal/event/CommentUpdatedEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/CommentUpdatedEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/CommentUpdatedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class CommentUpdatedEvent extends AbstractCommentEvent
+public class CommentUpdatedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
Index: src/main/java/com/xpn/xwiki/internal/event/AttachmentUpdatedEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/AttachmentUpdatedEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/AttachmentUpdatedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class AttachmentUpdatedEvent extends AbstractAttachmentEvent
+public class AttachmentUpdatedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
@@ -52,11 +53,11 @@
* document name.
*
* @param documentName the name of the document to match
- * @param name the name of the updated attachment
+ * @param identifier the name of the updated attachment
*/
- public AttachmentUpdatedEvent(String documentName, String name)
+ public AttachmentUpdatedEvent(String documentName, String identifier)
{
- super(documentName, name);
+ super(documentName, identifier);
}
/**
Index: src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java (working copy)
@@ -1,88 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-package com.xpn.xwiki.internal.event;
-
-import org.xwiki.observation.event.AbstractDocumentEvent;
-import org.xwiki.observation.event.filter.EventFilter;
-
-/**
- * Base class for all comment {@link org.xwiki.observation.event.Event events}.
- *
- * @version $Id$
- * @since 2.6RC2
- */
-public abstract class AbstractCommentEvent extends AbstractDocumentEvent
-{
- /**
- * The version identifier for this Serializable class. Increment only if the serialized form of the class
- * changes.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * The comment that is used in events.
- */
- private String identifier;
-
- /**
- * Constructor initializing the event filter with an
- * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
- * other comment event (add, update, delete).
- */
- public AbstractCommentEvent()
- {
- super();
- }
-
- /**
- * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter},
- * meaning that this event will match only comment events affecting the document matching the passed document name.
- *
- * @param documentName the name of the updated document to match
- * @param identifier the identifier of the comment added/updated/deleted
- */
- public AbstractCommentEvent(String documentName, String identifier)
- {
- super(documentName);
- this.identifier = identifier;
- }
-
- /**
- * Constructor using a custom {@link EventFilter}.
- *
- * @param eventFilter the filter to use for matching events
- */
- public AbstractCommentEvent(EventFilter eventFilter)
- {
- super(eventFilter);
- }
-
- /**
- * Retrieves the content of the comment added/updated/deleted in the event.
- *
- * @return comment identifier
- */
- public String getIdentifier()
- {
- return identifier;
- }
-
-}
Index: src/main/java/com/xpn/xwiki/internal/event/CommentAddedEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/CommentAddedEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/CommentAddedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class CommentAddedEvent extends AbstractCommentEvent
+public class CommentAddedEvent extends AbstractFilterableEvent
{
/**
* The version identifier for this Serializable class. Increment only if the serialized form of the class
@@ -36,7 +37,7 @@
*/
private static final long serialVersionUID = 1L;
- /**
+ /**AbstractCommentEvent
* Constructor initializing the event filter with an
* {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
* other comment add event.
Index: src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java (working copy)
@@ -1,88 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- */
-package com.xpn.xwiki.internal.event;
-
-import org.xwiki.observation.event.AbstractDocumentEvent;
-import org.xwiki.observation.event.filter.EventFilter;
-
-/**
- * Base class for all attachment {@link org.xwiki.observation.event.Event events}.
- *
- * @version $Id$
- * @since 2.6RC2
- */
-public class AbstractAttachmentEvent extends AbstractDocumentEvent
-{
- /**
- * The version identifier for this Serializable class. Increment only if the serialized form of the class
- * changes.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * The name of the attachment that is used in events.
- */
- private String name;
-
- /**
- * Constructor initializing the event filter with an
- * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
- * other attachment event (add, update, delete).
- */
- public AbstractAttachmentEvent()
- {
- super();
- }
-
- /**
- * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter},
- * meaning that this event will match only attachment events affecting the document matching the passed document
- * name.
- *
- * @param documentName the name of the updated document to match
- * @param name the name of the attachment added/updated/deleted
- */
- public AbstractAttachmentEvent(String documentName, String name)
- {
- super(documentName);
- this.name = name;
- }
-
- /**
- * Constructor using a custom {@link EventFilter}.
- *
- * @param eventFilter the filter to use for matching events
- */
- public AbstractAttachmentEvent(EventFilter eventFilter)
- {
- super(eventFilter);
- }
-
- /**
- * Retrieves the name of the attachment added/updated/deleted in the event.
- *
- * @return name name of the attachment
- */
- public String getName()
- {
- return name;
- }
-}
Index: src/main/java/com/xpn/xwiki/internal/event/AttachmentAddedEvent.java
===================================================================
--- src/main/java/com/xpn/xwiki/internal/event/AttachmentAddedEvent.java (revision 32887)
+++ src/main/java/com/xpn/xwiki/internal/event/AttachmentAddedEvent.java (working copy)
@@ -20,6 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
+import org.xwiki.observation.event.AbstractFilterableEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
@@ -28,7 +29,7 @@
* @version $Id$
* @since 2.6RC2
*/
-public class AttachmentAddedEvent extends AbstractAttachmentEvent
+public class AttachmentAddedEvent extends AbstractFilterableEvent
{
/**
@@ -53,11 +54,11 @@
* name.
*
* @param documentName the name of the document to match
- * @param name the name of the added attachment
+ * @param identifier the name of the added attachment
*/
- public AttachmentAddedEvent(String documentName, String name)
+ public AttachmentAddedEvent(String documentName, String identifier)
{
- super(documentName, name);
+ super(documentName, identifier);
}
/**
#P activitystream
Index: src/main/java/com/xpn/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java (revision 32666)
+++ src/main/java/com/xpn/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java (working copy)
@@ -30,13 +30,11 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;
-import org.xwiki.annotation.event.AnnotationAddedEvent;
-import org.xwiki.annotation.event.AnnotationDeletedEvent;
-import org.xwiki.annotation.event.AnnotationUpdatedEvent;
import org.xwiki.observation.EventListener;
import org.xwiki.observation.ObservationManager;
+import org.xwiki.observation.event.AbstractFilterableEvent;
+import org.xwiki.observation.event.AllEvent;
import org.xwiki.observation.event.DocumentDeleteEvent;
-import org.xwiki.observation.event.DocumentSaveEvent;
import org.xwiki.observation.event.DocumentUpdateEvent;
import org.xwiki.observation.event.Event;
import org.xwiki.observation.remote.RemoteObservationManagerContext;
@@ -97,18 +95,7 @@
private static final List LISTENER_EVENTS = new ArrayList()
{
{
- add(new DocumentSaveEvent());
- add(new DocumentUpdateEvent());
- add(new DocumentDeleteEvent());
- add(new CommentAddedEvent());
- add(new CommentDeletedEvent());
- add(new CommentUpdatedEvent());
- add(new AttachmentAddedEvent());
- add(new AttachmentDeletedEvent());
- add(new AttachmentUpdatedEvent());
- add(new AnnotationAddedEvent());
- add(new AnnotationDeletedEvent());
- add(new AnnotationUpdatedEvent());
+ add(AllEvent.ALLEVENT);
}
};
@@ -409,6 +396,7 @@
event.setBody(title);
event.setVersion(doc.getVersion());
event.setParams(params);
+ event.setUser(doc.getAuthor());
addActivityEvent(event, doc, context);
}
@@ -881,6 +869,9 @@
*/
public void onEvent(Event event, Object source, Object data)
{
+ if (!(event instanceof AbstractFilterableEvent && source instanceof XWikiDocument)) {
+ return;
+ }
XWikiDocument currentDoc = (XWikiDocument) source;
XWikiDocument originalDoc = currentDoc.getOriginalDocument();
XWikiContext context = (XWikiContext) data;
@@ -895,56 +886,18 @@
// Take events into account only once in a cluster
if (!Utils.getComponent(RemoteObservationManagerContext.class).isRemoteState()) {
- String eventType;
- String displayTitle;
- String additionalIdentifier = null;
+ AbstractFilterableEvent filterableEvent = (AbstractFilterableEvent) event;
- if (event instanceof DocumentSaveEvent) {
- eventType = ActivityEventType.CREATE;
- displayTitle = currentDoc.getDisplayTitle(context);
- } else if (event instanceof DocumentUpdateEvent) {
- eventType = ActivityEventType.UPDATE;
+ String eventType = filterableEvent.getClass().getSimpleName();
+ String displayTitle;
+ //test for event type in order to retrieve correctly the display title
+ if (event instanceof DocumentUpdateEvent || event instanceof DocumentDeleteEvent) {
displayTitle = originalDoc.getDisplayTitle(context);
- } else if (event instanceof DocumentDeleteEvent) {
- eventType = ActivityEventType.DELETE;
- displayTitle = originalDoc.getDisplayTitle(context);
- } else if (event instanceof CommentAddedEvent) {
- eventType = ActivityEventType.ADD_COMMENT;
+ }else{
displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((CommentAddedEvent) event).getIdentifier();
- } else if (event instanceof CommentDeletedEvent) {
- eventType = ActivityEventType.DELETE_COMMENT;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((CommentDeletedEvent) event).getIdentifier();
- } else if (event instanceof CommentUpdatedEvent) {
- eventType = ActivityEventType.UPDATE_COMMENT;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((CommentUpdatedEvent) event).getIdentifier();
- } else if (event instanceof AttachmentAddedEvent) {
- eventType = ActivityEventType.ADD_ATTACHMENT;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((AttachmentAddedEvent) event).getName();
- } else if (event instanceof AttachmentDeletedEvent) {
- eventType = ActivityEventType.DELETE_ATTACHMENT;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((AttachmentDeletedEvent) event).getName();
- } else if (event instanceof AttachmentUpdatedEvent) {
- eventType = ActivityEventType.UPDATE_ATTACHMENT;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((AttachmentUpdatedEvent) event).getName();
- } else if (event instanceof AnnotationAddedEvent) {
- eventType = ActivityEventType.ADD_ANNOTATION;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((AnnotationAddedEvent) event).getIdentifier();
- } else if (event instanceof AnnotationDeletedEvent) {
- eventType = ActivityEventType.DELETE_ANNOTATION;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((AnnotationDeletedEvent) event).getIdentifier();
- } else { // update annotation
- eventType = ActivityEventType.UPDATE_ANNOTATION;
- displayTitle = currentDoc.getDisplayTitle(context);
- additionalIdentifier = ((AnnotationUpdatedEvent) event).getIdentifier();
}
+
+ String additionalIdentifier = filterableEvent.getIdentifier();
List params = new ArrayList();
params.add(displayTitle);
@@ -959,6 +912,7 @@
+ currentDoc.getFullName() + "]");
}
}
+
}
/**