### Eclipse Workspace Patch 1.0 #P xwiki-core Index: src/main/java/com/xpn/xwiki/XWiki.java =================================================================== --- src/main/java/com/xpn/xwiki/XWiki.java (revision 33144) +++ src/main/java/com/xpn/xwiki/XWiki.java (working copy) @@ -1448,6 +1448,11 @@ if (originalDocument.isNew()) { getNotificationManager().verify(doc, originalDocument, XWikiDocChangeNotificationInterface.EVENT_NEW, context); + //test if it is rollback + if (comment.contains("Rollback")){ + //place it in context so we can retrieve it in AS + context.put("rollbackMessage", comment); + } if (om != null) { om.notify(new DocumentSaveEvent(doc.getPrefixedFullName()), doc, context); } Index: src/main/resources/ApplicationResources.properties =================================================================== --- src/main/resources/ApplicationResources.properties (revision 33172) +++ src/main/resources/ApplicationResources.properties (working copy) @@ -1659,6 +1659,7 @@ xe.activity.action.updateComment=edited a comment xe.activity.action.summary={0,choice,1#one change|1<{0} changes} by {1,choice,1#one user|1<{1} users} xe.activity.action.seechanges=see changes +xe.activity.action.rollbackto=Rolled back to version {0} #timeAgo used by Recent Activity macro (XE 2.6RC1) and Activity macro timeAgo.minutesAgo={0,choice,0#few seconds|1#one minute|1<{0} minutes} ago #P activitystream Index: src/main/java/com/xpn/xwiki/plugin/activitystream/api/ActivityEventType.java =================================================================== --- src/main/java/com/xpn/xwiki/plugin/activitystream/api/ActivityEventType.java (revision 32198) +++ src/main/java/com/xpn/xwiki/plugin/activitystream/api/ActivityEventType.java (working copy) @@ -85,4 +85,9 @@ * Annotation deletion. */ String DELETE_ANNOTATION = "deleteAnnotation"; + + /** + * Rollback action. + * */ + String ROLLBACK = "rollback"; } Index: src/main/java/com/xpn/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java =================================================================== --- src/main/java/com/xpn/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java (revision 33146) +++ src/main/java/com/xpn/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java (working copy) @@ -891,6 +891,14 @@ String msgPrefix = "activitystream.event."; String streamName = getStreamName(currentDoc.getSpace(), context); + //* When doing rollback there are several events triggered, so we must stop them from being triggered unless they are the actual create event */ + if (context.getAction().equals(ActivityEventType.ROLLBACK)){ + //we are on rollback + if (!(event instanceof DocumentSaveEvent)){ + return; + } + } + // If we haven't found a stream to store the event or if both currentDoc and originalDoc are null: exit if (streamName == null) { return; @@ -901,10 +909,17 @@ String eventType; String displayTitle; String additionalIdentifier = null; - + String rollbackMessage = null; + String rollbackVersion = null; + if (event instanceof DocumentSaveEvent) { eventType = ActivityEventType.CREATE; displayTitle = currentDoc.getDisplayTitle(context); + if (context.getAction().equals(ActivityEventType.ROLLBACK)){ + rollbackMessage = (String) context.get("rollbackMessage"); + String[] tokens = rollbackMessage.split(" "); + rollbackVersion = tokens[tokens.length - 1]; + } } else if (event instanceof DocumentUpdateEvent) { eventType = ActivityEventType.UPDATE; displayTitle = originalDoc.getDisplayTitle(context); @@ -954,7 +969,12 @@ if (additionalIdentifier != null) { params.add(additionalIdentifier); } - + + if (rollbackMessage != null){ + params.add(ActivityEventType.ROLLBACK); + params.add(rollbackVersion); + } + try { addDocumentActivityEvent(streamName, currentDoc, eventType, msgPrefix + eventType, params, context); } catch (ActivityStreamException e) {