Author: mflorea
Date: 2008-02-13 18:00:50 +0100 (Wed, 13 Feb 2008)
New Revision: 7625
Added:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/DocumentationActivityEvent.java
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MemberActivityEvent.java
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MessageActivityEvent.java
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/ResourceActivityEvent.java
Modified:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/impl/CurrikiActivityStream.java
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/CurrikiActivityStreamPluginApi.java
Log:
CURRIKI-1571, CURRIKI-1570, CURRIKI-1573, CURRIKI-1572
Modified:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/impl/CurrikiActivityStream.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/impl/CurrikiActivityStream.java
2008-02-13 17:00:25 UTC (rev 7624)
+++
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/impl/CurrikiActivityStream.java
2008-02-13 17:00:50 UTC (rev 7625)
@@ -3,11 +3,14 @@
import java.util.ArrayList;
import java.util.List;
+import org.xwiki.plugin.activitystream.api.ActivityEvent;
import org.xwiki.plugin.activitystream.api.ActivityEventPriority;
import org.xwiki.plugin.activitystream.api.ActivityEventType;
+import org.xwiki.plugin.activitystream.impl.ActivityEventImpl;
import org.xwiki.plugin.activitystream.impl.ActivityStreamImpl;
import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.notify.XWikiDocChangeNotificationInterface;
import com.xpn.xwiki.notify.XWikiNotificationRule;
@@ -70,34 +73,22 @@
}
List params = new ArrayList();
- String articleTitle = article.getStringValue("title");
- String articleLink =
- "[" + articleTitle + ">" + article.getName().replaceAll("@",
"%40") + "]";
- // should "from" be the creator of the message or the event initiator?
- String from = context.getWiki().getUserName(context.getUser(),
context);
+ params.add(article.getStringValue("title"));
+ params.add(getUserName(context.getUser(), context));
try {
switch (event) {
case XWikiDocChangeNotificationInterface.EVENT_NEW:
- params.add(articleLink);
- params.add(from);
addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.CREATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_mes_add",
- params, context);
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
case XWikiDocChangeNotificationInterface.EVENT_CHANGE:
- params.add(articleLink);
- params.add(from);
addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.UPDATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_mes_edit",
- params, context);
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
case XWikiDocChangeNotificationInterface.EVENT_DELETE:
- params.add(articleTitle);
- params.add(from);
- addDocumentActivityEvent(streamName, olddoc,
ActivityEventType.DELETE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_mes_del",
- params, context);
+ addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.DELETE,
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
}
} catch (Throwable e) {
@@ -114,42 +105,38 @@
return;
}
- // TODO is this truly a documentation
+ String docTitle = newdoc.getTitle();
+ String docType =
+ newdoc.getTags(context).contains("documentation-file") ? "file" :
"wikipage";
+
// update event parameter (workaround)
if (newdoc.isNew()) {
+ docTitle = olddoc.getTitle();
+ docType =
+ olddoc.getTags(context).contains("documentation-file") ?
"file" : "wikipage";
event = XWikiDocChangeNotificationInterface.EVENT_DELETE;
+ } else if (olddoc == null && "1.2".equals(newdoc.getVersion())) {
+ event = XWikiDocChangeNotificationInterface.EVENT_NEW;
}
List params = new ArrayList();
- String docDisplayTitle = newdoc.getDisplayTitle(context);
- String docLink =
- "[" + docDisplayTitle + ">" + newdoc.getSpace() + "."
- + newdoc.getName().replaceAll("@", "%40") + "]";
- // should "user" be the creator of the message or the event initiator?
- String user = context.getWiki().getUserName(context.getUser(),
context);
+ params.add(docTitle);
+ params.add(getUserName(context.getUser(), context));
+ params.add(docType);
try {
switch (event) {
case XWikiDocChangeNotificationInterface.EVENT_NEW:
- params.add(docLink);
- params.add(user);
addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.CREATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_doc_wiki_add",
- params, context);
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
case XWikiDocChangeNotificationInterface.EVENT_CHANGE:
- params.add(docLink);
- params.add(user);
addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.UPDATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_doc_wiki_upd",
- params, context);
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
case XWikiDocChangeNotificationInterface.EVENT_DELETE:
- params.add(docDisplayTitle);
- params.add(user);
- addDocumentActivityEvent(streamName, olddoc,
ActivityEventType.DELETE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_doc_wiki_del",
- params, context);
+ addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.DELETE,
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
}
} catch (Throwable e) {
@@ -182,35 +169,22 @@
}
List params = new ArrayList();
- String docDisplayTitle = newdoc.getDisplayTitle(context);
- String docLink =
- "[" + docDisplayTitle + ">" + newdoc.getSpace() + "."
- + newdoc.getName().replaceAll("@", "%40") + "]";
- // should "from" be the creator of the message or the event initiator?
- String user = context.getWiki().getUserName(context.getUser(),
context);
+ params.add(asset.getStringValue("title"));
+ params.add(getUserName(context.getUser(), context));
try {
switch (event) {
case XWikiDocChangeNotificationInterface.EVENT_NEW:
- params.add(docLink);
- params.add(user);
addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.CREATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_res_add",
- params, context);
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
case XWikiDocChangeNotificationInterface.EVENT_CHANGE:
- params.add(docLink);
- params.add(user);
addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.UPDATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_res_edit",
- params, context);
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
case XWikiDocChangeNotificationInterface.EVENT_DELETE:
- params.add(docDisplayTitle);
- params.add(user);
- addDocumentActivityEvent(streamName, olddoc,
ActivityEventType.DELETE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_res_del",
- params, context);
+ addDocumentActivityEvent(streamName, newdoc,
ActivityEventType.DELETE,
+ ActivityEventPriority.NOTIFICATION, "", params,
context);
break;
}
} catch (Throwable e) {
@@ -244,22 +218,28 @@
try {
String profileName = profile.getName();
- String userName = "XWiki." +
profileName.substring(profileName.indexOf(".") + 1);
- XWikiDocument userDoc = context.getWiki().getDocument(userName,
context);
+ String user = "XWiki." +
profileName.substring(profileName.indexOf(".") + 1);
+ XWikiDocument userDoc = context.getWiki().getDocument(user,
context);
List params = new ArrayList();
- params.add(context.getWiki().getUserName(userName, context));
+ params.add(user);
+ params.add(getUserName(user, context));
+ ActivityEvent activityEvent = new ActivityEventImpl();
+ activityEvent.setStream(streamName);
+ activityEvent.setPriority(ActivityEventPriority.NOTIFICATION);
+ activityEvent.setUrl(userDoc.getExternalURL("view", context));
+ activityEvent.setParams(params);
+ activityEvent.setDate(newdoc.getDate());
+
switch (event) {
case XWikiDocChangeNotificationInterface.EVENT_NEW:
- addDocumentActivityEvent(streamName, userDoc,
ActivityEventType.CREATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_mem_new",
- params, context);
+ activityEvent.setType(ActivityEventType.CREATE);
+ addActivityEvent(activityEvent, newdoc, context);
break;
case XWikiDocChangeNotificationInterface.EVENT_CHANGE:
- addDocumentActivityEvent(streamName, userDoc,
ActivityEventType.UPDATE,
- ActivityEventPriority.NOTIFICATION,
"groups_home_activity_mem_upd",
- params, context);
+ activityEvent.setType(ActivityEventType.UPDATE);
+ addActivityEvent(activityEvent, newdoc, context);
break;
case XWikiDocChangeNotificationInterface.EVENT_DELETE:
// ignore
@@ -296,4 +276,22 @@
return null;
}
}
+
+ private String getUserName(String user, XWikiContext context)
+ {
+ String userName = null;
+ try {
+ XWikiDocument userDoc = context.getWiki().getDocument(user,
context);
+ if (!userDoc.isNew()) {
+ userName =
+ (userDoc.getStringValue("XWiki.XWikiUsers", "first_name")
+ " " + userDoc
+ .getStringValue("XWiki.XWikiUsers",
"last_name")).trim();
+ }
+ } catch (XWikiException e) {
+ }
+ if (userName == null) {
+ userName = user.substring(user.indexOf(".") + 1);
+ }
+ return userName;
+ }
}
Modified:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/CurrikiActivityStreamPluginApi.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/CurrikiActivityStreamPluginApi.java
2008-02-13 17:00:25 UTC (rev 7624)
+++
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/CurrikiActivityStreamPluginApi.java
2008-02-13 17:00:50 UTC (rev 7625)
@@ -1,19 +1,69 @@
package org.curriki.plugin.activitystream.plugin;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
import org.curriki.plugin.activitystream.impl.CurrikiActivityStream;
import org.xwiki.plugin.activitystream.plugin.ActivityStreamPluginApi;
import com.xpn.xwiki.XWikiContext;
-public class CurrikiActivityStreamPluginApi extends ActivityStreamPluginApi {
+public class CurrikiActivityStreamPluginApi extends ActivityStreamPluginApi
+{
public CurrikiActivityStreamPluginApi(CurrikiActivityStreamPlugin plugin,
XWikiContext context)
{
super(plugin, context);
}
- protected CurrikiActivityStream getCurrikiActivityStream() {
- return (CurrikiActivityStream) ((CurrikiActivityStreamPlugin)
getPlugin()).getActivityStream();
+ protected CurrikiActivityStream getCurrikiActivityStream()
+ {
+ return (CurrikiActivityStream) ((CurrikiActivityStreamPlugin)
getPlugin())
+ .getActivityStream();
}
+
+ protected List wrapEvents(List events)
+ {
+ if (events == null || events.size() == 0) {
+ return Collections.EMPTY_LIST;
+ }
+ List result = new ArrayList();
+ Iterator iter = events.iterator();
+ while (iter.hasNext()) {
+ org.xwiki.plugin.activitystream.api.ActivityEvent event =
+ (org.xwiki.plugin.activitystream.api.ActivityEvent)
iter.next();
+ org.xwiki.plugin.activitystream.plugin.ActivityEvent wrappedEvent;
+ if (event.getSpace().startsWith("Messages_Group_")) {
+ wrappedEvent = new MessageActivityEvent(event,
getXWikiContext());
+ } else if (event.getSpace().startsWith("UserProfiles_Group_")) {
+ wrappedEvent = new MemberActivityEvent(event,
getXWikiContext());
+ } else if (event.getSpace().startsWith("Coll_Group_")) {
+ wrappedEvent = new ResourceActivityEvent(event,
getXWikiContext());
+ } else if (event.getSpace().startsWith("Documentation_Group_")) {
+ wrappedEvent = new DocumentationActivityEvent(event,
getXWikiContext());
+ } else {
+ wrappedEvent =
+ new
org.xwiki.plugin.activitystream.plugin.ActivityEvent(event,
+ getXWikiContext());
+ }
+ result.add(wrappedEvent);
+ }
+ return result;
+ }
+
+ protected List unwrapEvents(List events)
+ {
+ List result = super.unwrapEvents(events);
+ for (int i = 0; i < events.size(); i++) {
+ org.xwiki.plugin.activitystream.api.ActivityEvent event =
+ (org.xwiki.plugin.activitystream.api.ActivityEvent)
result.get(i);
+ org.xwiki.plugin.activitystream.plugin.ActivityEvent wrappedEvent =
+ (org.xwiki.plugin.activitystream.plugin.ActivityEvent)
events.get(i);
+ event.setTitle(wrappedEvent.getDisplayTitle());
+ event.setBody(wrappedEvent.getDisplayBody());
+ }
+ return result;
+ }
}
Added:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/DocumentationActivityEvent.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/DocumentationActivityEvent.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/DocumentationActivityEvent.java
2008-02-13 17:00:50 UTC (rev 7625)
@@ -0,0 +1,109 @@
+/*
+ * 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 org.curriki.plugin.activitystream.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xwiki.plugin.activitystream.api.ActivityEventType;
+import org.xwiki.plugin.activitystream.plugin.ActivityEvent;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+
+public class DocumentationActivityEvent extends ActivityEvent
+{
+ private String displayTitle;
+
+ private String displayBody;
+
+ public
DocumentationActivityEvent(org.xwiki.plugin.activitystream.api.ActivityEvent
event,
+ XWikiContext context)
+ {
+ super(event, context);
+
+ String docTitle = event.getParam1();
+ boolean isFile = "file".equals(event.getParam3());
+ String docLink = docTitle;
+ XWikiDocument doc;
+ try {
+ doc = context.getWiki().getDocument(event.getPage(), context);
+ if (!doc.isNew()) {
+ docTitle = doc.getTitle();
+ docLink = "[" + docTitle + ">" + doc.getExternalURL("view",
context) + "]";
+ isFile = doc.getTags(context).contains("documentation-file");
+ }
+ } catch (XWikiException e) {
+ }
+
+ String userName = event.getParam2();
+ String userLink = userName;
+ XWikiDocument userDoc;
+ try {
+ userDoc = context.getWiki().getDocument(event.getUser(), context);
+ if (!userDoc.isNew()) {
+ userName =
+ (userDoc.getStringValue("XWiki.XWikiUsers", "first_name")
+ " " + userDoc
+ .getStringValue("XWiki.XWikiUsers",
"last_name")).trim();
+ userLink = context.getWiki().getUserName(event.getUser(),
context);
+ }
+ } catch (XWikiException e) {
+ }
+
+ String eventTitle = "";
+ if (isFile) {
+ if (ActivityEventType.UPDATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_doc_upd";
+ } else if (ActivityEventType.CREATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_doc_add";
+ } else if (ActivityEventType.DELETE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_doc_del";
+ }
+ } else {
+ if (ActivityEventType.UPDATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_doc_wiki_upd";
+ } else if (ActivityEventType.CREATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_doc_wiki_add";
+ } else if (ActivityEventType.DELETE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_doc_wiki_del";
+ }
+ }
+
+ List params = new ArrayList();
+ params.add(docTitle);
+ params.add(userName);
+ displayTitle = context.getMessageTool().get(eventTitle, params);
+
+ params.set(0, docLink);
+ params.set(1, userLink);
+ displayBody = context.getMessageTool().get(eventTitle, params);
+ }
+
+ public String getDisplayTitle()
+ {
+ return displayTitle;
+ }
+
+ public String getDisplayBody()
+ {
+ return displayBody;
+ }
+}
Added:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MemberActivityEvent.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MemberActivityEvent.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MemberActivityEvent.java
2008-02-13 17:00:50 UTC (rev 7625)
@@ -0,0 +1,82 @@
+/*
+ * 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 org.curriki.plugin.activitystream.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xwiki.plugin.activitystream.api.ActivityEventType;
+import org.xwiki.plugin.activitystream.plugin.ActivityEvent;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+
+public class MemberActivityEvent extends ActivityEvent
+{
+ private String displayTitle;
+
+ private String displayBody;
+
+ public
MemberActivityEvent(org.xwiki.plugin.activitystream.api.ActivityEvent event,
+ XWikiContext context)
+ {
+ super(event, context);
+
+ String user = event.getParam1();
+ String userName = event.getParam2();
+ String userLink = userName;
+ XWikiDocument userDoc;
+ try {
+ userDoc = context.getWiki().getDocument(user, context);
+ if (!userDoc.isNew()) {
+ userName =
+ (userDoc.getStringValue("XWiki.XWikiUsers", "first_name")
+ " " + userDoc
+ .getStringValue("XWiki.XWikiUsers",
"last_name")).trim();
+ userLink = context.getWiki().getUserName(user, context);
+ }
+ } catch (XWikiException e) {
+ }
+
+ String eventTitle = "";
+ if (ActivityEventType.UPDATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_mem_upd";
+ } else if (ActivityEventType.CREATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_mem_new";
+ }
+
+ List params = new ArrayList();
+ params.add(userName);
+ displayTitle = context.getMessageTool().get(eventTitle, params);
+
+ params.set(0, userLink);
+ displayBody = context.getMessageTool().get(eventTitle, params);
+ }
+
+ public String getDisplayTitle()
+ {
+ return displayTitle;
+ }
+
+ public String getDisplayBody()
+ {
+ return displayBody;
+ }
+}
Added:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MessageActivityEvent.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MessageActivityEvent.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/MessageActivityEvent.java
2008-02-13 17:00:50 UTC (rev 7625)
@@ -0,0 +1,101 @@
+/*
+ * 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 org.curriki.plugin.activitystream.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xwiki.plugin.activitystream.api.ActivityEventType;
+import org.xwiki.plugin.activitystream.plugin.ActivityEvent;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.objects.BaseObject;
+
+public class MessageActivityEvent extends ActivityEvent
+{
+ private String displayTitle;
+
+ private String displayBody;
+
+ public
MessageActivityEvent(org.xwiki.plugin.activitystream.api.ActivityEvent event,
+ XWikiContext context)
+ {
+ super(event, context);
+
+ String articleTitle = event.getParam1();
+ String articleLink = articleTitle;
+ XWikiDocument doc;
+ BaseObject article;
+ try {
+ doc = context.getWiki().getDocument(event.getPage(), context);
+ article = doc.getObject("XWiki.ArticleClass");
+ if (article != null) {
+ articleTitle = article.getStringValue("title");
+ articleLink =
+ "[" + articleTitle + ">" +
article.getName().replaceAll("@", "%40") + "]";
+ }
+ } catch (XWikiException e) {
+ }
+
+ String userName = event.getParam2();
+ String userLink = userName;
+ XWikiDocument userDoc;
+ try {
+ userDoc = context.getWiki().getDocument(event.getUser(), context);
+ if (!userDoc.isNew()) {
+ userName =
+ (userDoc.getStringValue("XWiki.XWikiUsers", "first_name")
+ " " + userDoc
+ .getStringValue("XWiki.XWikiUsers",
"last_name")).trim();
+ userLink = context.getWiki().getUserName(event.getUser(),
context);
+ }
+ } catch (XWikiException e) {
+ }
+
+ String eventTitle = "";
+ if (ActivityEventType.UPDATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_mes_edit";
+ } else if (ActivityEventType.CREATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_mes_add";
+ } else if (ActivityEventType.DELETE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_mes_del";
+ }
+
+ List params = new ArrayList();
+ params.add(articleTitle);
+ params.add(userName);
+ displayTitle = context.getMessageTool().get(eventTitle, params);
+
+ params.set(0, articleLink);
+ params.set(1, userLink);
+ displayBody = context.getMessageTool().get(eventTitle, params);
+ }
+
+ public String getDisplayTitle()
+ {
+ return displayTitle;
+ }
+
+ public String getDisplayBody()
+ {
+ return displayBody;
+ }
+}
Added:
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/ResourceActivityEvent.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/ResourceActivityEvent.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/currikiactivitystream/src/main/java/org/curriki/plugin/activitystream/plugin/ResourceActivityEvent.java
2008-02-13 17:00:50 UTC (rev 7625)
@@ -0,0 +1,100 @@
+/*
+ * 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 org.curriki.plugin.activitystream.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xwiki.plugin.activitystream.api.ActivityEventType;
+import org.xwiki.plugin.activitystream.plugin.ActivityEvent;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.objects.BaseObject;
+
+public class ResourceActivityEvent extends ActivityEvent
+{
+ private String displayTitle;
+
+ private String displayBody;
+
+ public
ResourceActivityEvent(org.xwiki.plugin.activitystream.api.ActivityEvent event,
+ XWikiContext context)
+ {
+ super(event, context);
+
+ String assetTitle = event.getParam1();
+ String assetLink = assetTitle;
+ XWikiDocument doc;
+ BaseObject asset;
+ try {
+ doc = context.getWiki().getDocument(event.getPage(), context);
+ asset = doc.getObject("XWiki.AssetClass");
+ if (asset != null) {
+ assetTitle = asset.getStringValue("title");
+ assetLink = "[" + assetTitle + ">" +
asset.getName().replaceAll("@", "%40") + "]";
+ }
+ } catch (XWikiException e) {
+ }
+
+ String userName = event.getParam2();
+ String userLink = userName;
+ XWikiDocument userDoc;
+ try {
+ userDoc = context.getWiki().getDocument(event.getUser(), context);
+ if (!userDoc.isNew()) {
+ userName =
+ (userDoc.getStringValue("XWiki.XWikiUsers", "first_name")
+ " " + userDoc
+ .getStringValue("XWiki.XWikiUsers",
"last_name")).trim();
+ userLink = context.getWiki().getUserName(event.getUser(),
context);
+ }
+ } catch (XWikiException e) {
+ }
+
+ String eventTitle = "";
+ if (ActivityEventType.UPDATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_res_edit";
+ } else if (ActivityEventType.CREATE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_res_add";
+ } else if (ActivityEventType.DELETE.equals(event.getType())) {
+ eventTitle = "groups_home_activity_res_del";
+ }
+
+ List params = new ArrayList();
+ params.add(assetTitle);
+ params.add(userName);
+ displayTitle = context.getMessageTool().get(eventTitle, params);
+
+ params.set(0, assetLink);
+ params.set(1, userLink);
+ displayBody = context.getMessageTool().get(eventTitle, params);
+ }
+
+ public String getDisplayTitle()
+ {
+ return displayTitle;
+ }
+
+ public String getDisplayBody()
+ {
+ return displayBody;
+ }
+}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications