Author: ludovic
Date: 2008-02-04 01:23:20 +0100 (Mon, 04 Feb 2008)
New Revision: 7286

Added:
   xwiki-products/curriki/trunk/plugins/activitystream/
   xwiki-products/curriki/trunk/plugins/activitystream/pom.xml
   xwiki-products/curriki/trunk/plugins/activitystream/src/
   xwiki-products/curriki/trunk/plugins/activitystream/src/export/
   xwiki-products/curriki/trunk/plugins/activitystream/src/main/
   xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/
   xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/
   xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEvent.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventPriority.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventType.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStream.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStreamException.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityEventImpl.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPlugin.java
   
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPluginApi.java
   xwiki-products/curriki/trunk/plugins/activitystream/src/test/
   xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/
   xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/
   xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/
   
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationManagerImplTest.java.old
   
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationTest.java.old
Log:
CURRIKI-1569 Initial implementation of activity stream

Added: xwiki-products/curriki/trunk/plugins/activitystream/pom.xml
===================================================================
--- xwiki-products/curriki/trunk/plugins/activitystream/pom.xml                 
        (rev 0)
+++ xwiki-products/curriki/trunk/plugins/activitystream/pom.xml 2008-02-04 
00:23:20 UTC (rev 7286)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!--
+ *
+ * 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.
+ *
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.xpn.xwiki.platform.plugins</groupId>
+    <artifactId>xwiki-plugins</artifactId>
+    <version>4-SNAPSHOT</version>
+  </parent>
+  <artifactId>xwiki-plugin-activitystream</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>XWiki Platform - Plugins - Activity Stream</name>
+  <packaging>jar</packaging>
+  <description>XWiki Platform - Plugins - Activity Stream</description>
+  <dependencies>
+    <dependency>
+      <groupId>com.xpn.xwiki.platform</groupId>
+      <artifactId>xwiki-core</artifactId>
+      <version>1.2-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>jmock</groupId>
+      <artifactId>jmock-cglib</artifactId>
+      <version>1.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.xpn.xwiki.platform.plugins</groupId>
+      <artifactId>xwiki-plugin-mailsender</artifactId>
+      <version>1.1-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+</project>      

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEvent.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEvent.java
                            (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEvent.java
    2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,279 @@
+/*
+ * 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.xwiki.plugin.activitystream.api;
+
+import com.xpn.xwiki.XWikiContext;
+
+import java.util.Date;
+
+/**
+ * An Activity Event represents a event done by a user in a certain context.
+ */
+public interface ActivityEvent
+{
+    /**
+     * @return The unique ID of the event
+     */
+    String getEventId();
+
+    /**
+     * @param id Unique ID of the event
+     * @see #getEventId()
+     */
+    void setEventId(String id);
+
+
+    /**
+     * @return The request ID
+     */
+    String getRequestId();
+
+    /**
+     * @param id The request ID of the event
+     * @see #getRequestId()
+     */
+    void setRequestId(String id);
+
+
+    /**
+     * @return The priority of the event
+     */
+    int getPriority();
+
+    /**
+     * @param priority The priority of the event
+     * @see #getPriority()
+     */
+    void setPriority(int priority);
+
+    /**
+     * @return The type of the event
+     */
+    String getType();
+
+    /**
+     * @param type The type of the event
+     * @see #getType()
+     */
+    void setType(String type);
+
+
+    /**
+      * @return The application name
+      */
+     String getApplication();
+
+     /**
+      * @param application The application Name
+      * @see #getApplication()
+      */
+     void setApplication(String application);
+
+
+    /**
+     * @return The stream name
+     */
+    String getStream();
+
+    /**
+     * @param stream The stream Name
+     * @see #getStream()
+     */
+    void setStream(String stream);
+
+
+    /**
+     * @return The stream name
+     */
+    Date getDate();
+
+    /**
+     * @param date The event date
+     * @see #getDate()
+     */
+    void setDate(Date date);
+
+
+    /**
+     * @return The wiki name of the user creating the event
+     */
+    String getUser();
+
+    /**
+     * @param user The wiki name of the user creating the event
+     * @see #getUser()
+     */
+    void setUser(String user);
+
+    /**
+     * @return The wiki name in which the event was created
+     */
+    String getWiki();
+
+    /**
+     * @param wiki The wiki name in which the event was created
+     * @see #getWiki()
+     */
+    void setWiki(String wiki);
+
+    /**
+     * @return The space name in which the event was created
+     */
+    String getSpace();
+
+    /**
+     * @param space The space name in which the event was created
+     * @see #getSpace()
+     */
+    void setSpace(String space);
+
+
+    /**
+     * @return The page of the event
+     */
+    String getPage();
+
+    /**
+     * @param page The page of the event
+     * @see #getPage()
+     */
+    void setPage(String page);
+
+
+    /**
+     * @return The target url
+     */
+    String getUrl();
+
+    /**
+     * @param url The url of the event
+     * @see #getUrl()
+     */
+    void setUrl(String url);
+
+    /**
+     * @return The title of the event
+     */
+    String getTitle();
+
+    /**
+     * @param title The title of the event
+     * @see #getTitle()
+     */
+    void setTitle(String title);
+
+    /**
+     * @return The Body of the event
+     */
+    String getBody();
+
+    /**
+     * @param body The body of the event
+     * @see #getBody()
+     */
+    void setBody(String body);
+
+
+    /**
+     * @return The first param of the event
+     */
+    String getParam1();
+
+    /**
+     * @param param1 The first param of the event
+     * @see #getParam1()
+     */
+    void setParam1(String param1);
+
+
+    /**
+     * @return The second param of the event
+     */
+    String getParam2();
+
+    /**
+     * @param param2 The second param of the event
+     * @see #getParam2()
+     */
+    void setParam2(String param2);
+
+    /**
+     * @return The third param of the event
+     */
+    String getParam3();
+
+    /**
+     * @param param3 The third param of the event
+     * @see #getParam3()
+     */
+    void setParam3(String param3);
+
+    /**
+     * @return The fourth param of the event
+     */
+    String getParam4();
+
+    /**
+     * @param param4 The fourth param of the event
+     * @see #getParam4()
+     */
+    void setParam4(String param4);
+
+    /**
+     * @return The fifth param of the event
+     */
+    String getParam5();
+
+    /**
+     * @param param5 The fifth param of the event
+     * @see #getParam5()
+     */
+    void setParam5(String param5);
+
+
+    /**
+     * Retrieves the event in displayable format
+     * @param context
+     * @return
+     */
+    String getDisplayTitle(XWikiContext context);
+
+    /**
+     * Retrieves the event body in displayable format
+     * @param context
+     * @return
+     */
+    String getDisplayBody(XWikiContext context);
+
+    /**
+     * Retrieves the event date in displayable format
+     * @param context
+     * @return
+     */
+    String getDisplayDate(XWikiContext context);
+
+    /**
+     * Retrieves the event user in displayable format
+     * @param context
+     * @return
+     */
+    String getDisplayUser(XWikiContext context);
+
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventPriority.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventPriority.java
                            (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventPriority.java
    2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,30 @@
+package org.xwiki.plugin.activitystream.api;
+
+/**
+ * The priorities possible for an Activity Event. This allows to filter 
complex events
+ * by only keeping the most high level event or by getting page level event.
+ *
+ */
+public interface ActivityEventPriority {
+
+    /**
+     * The event is a storage level event (low level)
+     */
+    int STORAGE = 10;
+
+    /**
+     * The event is a notification level event (low level)
+     */
+    int NOTIFICATION = 20;
+
+    /**
+     * The event is a action level event (high level)
+     */
+    int ACTION = 30;
+
+    /**
+     * The event is a program level event (higgest level)
+     */
+    int PROGRAM = 40;
+
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventType.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventType.java
                                (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventType.java
        2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,58 @@
+/*
+ * 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.xwiki.plugin.activitystream.api;
+
+/**
+ * The type of request. This list is extensible.
+ * 
+ */
+public interface ActivityEventType {
+
+    String OTHER = "other";
+
+    String CREATE = "create";
+
+    String UPDATE = "update";
+
+    String DELETE = "delete";
+
+    String MOVE = "move";
+
+    String CREATE_COMMENT = "createcomment";
+
+    String CREATE_ATTACHMENT = "createattachment";
+
+    String UPDATE_ATTACHMENT = "updateattachment";
+
+    String DELETE_ATTACHMENT = "deleteattachment";
+
+    String CREATE_USER = "createuser";
+
+    String DELETE_USER = "deleteuser";
+
+    String CREATE_SPACE = "createspace";
+
+    String DELETE_SPACE = "deletespace";
+
+    String CHANGE_RIGHTS = "changerights";
+
+    String NEW_MEMBER = "newmember";
+
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStream.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStream.java
                           (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStream.java
   2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,69 @@
+/*
+ * 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.xwiki.plugin.activitystream.api;
+
+import java.util.List;
+import java.util.Map;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+
+/**
+ * Manages the activity stream
+ */
+public interface ActivityStream
+{
+
+    /**
+     * Creates the classes used by the activity stream when necessary
+     */
+    void initClasses(XWikiContext context) throws XWikiException;
+
+
+    /**
+     * Adding and activity event
+     * The Id does not need to be filled as it will be created
+     * Date and Wiki are optional
+     * @param event
+     * @param context
+     * @throws ActivityStreamException
+     */
+    void addActivityEvent(ActivityEvent event, XWikiContext context) throws 
ActivityStreamException;
+
+    void addActivityEvent(String type, String title, XWikiContext context) 
throws ActivityStreamException;
+
+    void addDocumentActivityEvent(XWikiDocument doc, String type, String 
title, XWikiContext context) throws ActivityStreamException;
+
+    List searchEvents(String hql, boolean filter, int nb, int start, 
XWikiContext context) throws ActivityStreamException;
+
+    List getEvents(boolean filter, int nb, int start, XWikiContext context) 
throws ActivityStreamException;
+
+    List getEventsForSpace(String space, boolean filter, int nb, int start, 
XWikiContext context) throws ActivityStreamException;
+
+    List getEventsForUser(String user, boolean filter, int nb, int start, 
XWikiContext context) throws ActivityStreamException;
+
+    List getEvents(String streamName, boolean filter, int nb, int start, 
XWikiContext context) throws ActivityStreamException;
+
+    List getEventsForSpace(String streamName, String space, boolean filter, 
int nb, int start, XWikiContext context) throws ActivityStreamException;
+
+    List getEventsForUser(String streamName, String user, boolean filter, int 
nb, int start, XWikiContext context) throws ActivityStreamException;
+
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStreamException.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStreamException.java
                          (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStreamException.java
  2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,59 @@
+package org.xwiki.plugin.activitystream.api;
+
+import com.xpn.xwiki.XWikiException;
+
+/**
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ * <p/>
+ * 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 version2.1of
+ * the License,or(at your option)any later version.
+ * <p/>
+ * 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.
+ * <p/>
+ * 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.
+ */
+
+public class ActivityStreamException extends XWikiException {
+    public static final int MODULE_PLUGIN_ActivityStream = 101;
+
+    public static final int ERROR_INVITATION_INVITEE_MISSING = 101001;
+    public static final int ERROR_INVITATION_INVITEE_EMAIL_INVALID = 101002;
+    public static final int ERROR_INVITATION_ALREADY_EXISTS = 101003;
+    public static final int ERROR_INVITATION_ALREADY_MEMBER = 101004;
+    public static final int ERROR_INVITATION_SENDER_EMAIL_INVALID = 101005;
+    public static final int ERROR_INVITATION_TARGET_EMAIL_INVALID = 101006;
+    public static final int ERROR_INVITATION_SENDING_EMAIL_FAILED = 101007;
+    public static final int 
ERROR_INVITATION_MANAGER_REQUIRES_MAILSENDER_PLUGIN = 101008;
+    
+    public static final int ERROR_INVITATION_DATA_INVALID = 101009;
+    public static final int ERROR_INVITATION_CANNOT_FIND_EMAIL_ADDRESS = 
101010;
+
+    public ActivityStreamException(){
+       }
+
+    public ActivityStreamException(int module, int code, String message){
+        super(module, code, message);
+    }
+
+    public ActivityStreamException(int module, int code, String message, 
Exception e){
+        super(module, code, message, e);
+    }
+
+    public ActivityStreamException( XWikiException e ){
+        super();
+        setModule(e.getModule());
+        setCode(e.getCode());
+        setException(e.getException());
+        setArgs(e.getArgs());
+        setMessage(e.getMessage());
+       }
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityEventImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityEventImpl.java
                               (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityEventImpl.java
       2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,220 @@
+/*
+ * 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.xwiki.plugin.activitystream.impl;
+
+
+import com.xpn.xwiki.XWikiContext;
+import org.xwiki.plugin.activitystream.api.ActivityEvent;
+
+import java.util.Date;
+
+/**
+ */
+public class ActivityEventImpl implements ActivityEvent {
+    protected String eventId;
+    protected String requestId;
+    protected int priority = 0;
+    protected Date date;
+    protected String stream;
+    protected String application;
+    protected String type;
+    protected String user;
+    protected String wiki;
+    protected String space;
+    protected String page;
+    protected String url;
+    protected String title;
+    protected String body = "";
+    protected String param1 = "";
+    protected String param2 = "";
+    protected String param3 = "";
+    protected String param4 = "";
+    protected String param5 = "";
+
+
+
+    public String getDisplayTitle(XWikiContext context) {
+        return context.getWiki().parseMessage(title, context);
+    }
+
+    public String getDisplayBody(XWikiContext context) {
+        return context.getWiki().parseMessage(body, context);               
+    }
+
+    public String getDisplayDate(XWikiContext context) {
+        return context.getWiki().formatDate(date, null, context);
+    }
+
+    public String getDisplayUser(XWikiContext context) {
+        return context.getWiki().getLocalUserName(user, context);
+    }
+
+    public String getEventId() {
+        return eventId;
+    }
+
+    public void setEventId(String eventId) {
+        this.eventId = eventId;
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public void setRequestId(String requestId) {
+        this.requestId = requestId;
+    }
+
+    public int getPriority() {
+        return priority;
+    }
+
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    public String getApplication() {
+        return application;
+    }
+
+    public void setStream(String stream) {
+        this.stream = stream;
+    }
+
+    public String getParam1() {
+        return param1;
+    }
+
+    public void setParam1(String param1) {
+        this.param1 = param1;
+    }
+
+    public String getParam2() {
+        return param2;
+    }
+
+    public void setParam2(String param2) {
+        this.param2 = param2;
+    }
+
+    public String getParam3() {
+        return param3;
+    }
+
+    public void setParam3(String param3) {
+        this.param3 = param3;
+    }
+
+    public String getParam4() {
+        return param4;
+    }
+
+    public void setParam4(String param4) {
+        this.param4 = param4;
+    }
+
+    public String getParam5() {
+        return param5;
+    }
+
+    public void setParam5(String param5) {
+        this.param5 = param5;
+    }
+
+    public String getWiki() {
+        return wiki;
+    }
+
+    public void setWiki(String wiki) {
+        this.wiki = wiki;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    public String getSpace() {
+        return space;
+    }
+
+    public void setSpace(String space) {
+        this.space = space;
+    }
+
+    public String getPage() {
+        return page;
+    }
+
+    public void setPage(String page) {
+        this.page = page;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public void setBody(String body) {
+        this.body = body;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public String getStream() {
+        return stream;
+    }
+
+    public void setApplication(String application) {
+        this.application = application;
+    }
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java
                              (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java
      2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,184 @@
+/*
+ * 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.xwiki.plugin.activitystream.impl;
+
+
+import org.xwiki.plugin.activitystream.api.*;
+import org.apache.commons.lang.RandomStringUtils;
+import org.hibernate.Session;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.store.XWikiHibernateStore;
+import com.xpn.xwiki.doc.XWikiDocument;
+
+import java.util.List;
+
+
+public class ActivityStreamImpl implements ActivityStream {
+
+
+    public static final String SPACE_VELOCITY_KEY = "space";
+
+    public static final String INVITATION_VELOCITY_KEY = "invitation";
+
+    public static final String MEMBERSHIP_REQUEST_VELOCITY_KEY = 
"membershiprequest";
+
+    public static final String INVITATION_CLASS_NAME =  
"XWiki.InvitationClass";
+
+    public static final String MEMBERSHIP_REQUEST_CLASS_NAME =  
"XWiki.MembershipRequestClass";
+
+    private boolean mailNotification = true;
+
+
+
+    public void initClasses(XWikiContext context) throws XWikiException {
+    }
+
+
+    protected void prepareEvent(ActivityEvent event, XWikiContext context) {
+        if (event.getUser()==null) {
+            event.setUser(context.getUser());
+        }
+        if (event.getStream()==null) {
+            event.setStream(context.getUser());
+        }
+        if (event.getWiki()==null) {
+            event.setWiki(context.getDatabase());
+        }
+        if (event.getSpace()==null) {
+            event.setSpace(context.getDoc().getSpace());
+        }
+        if (event.getPage()==null) {
+            event.setPage(context.getDoc().getFullName());
+        }
+        if (event.getUrl()==null) {
+            event.setUrl(context.getDoc().getURL("view", context));
+        }
+        if (event.getApplication()==null) {
+            event.setApplication("xwiki");
+        }
+        if (event.getDate()==null) {
+            event.setDate(context.getWiki().getCurrentDate());
+        }
+
+        // get the request id
+        String requestId = (String) context.get("activitystream_requestid");
+        String eventId = event.getEventId();
+
+        if (eventId==null) {
+            eventId = generateEventId(event, context);
+        }
+        if (event.getRequestId()==null) {
+            event.setRequestId(eventId);
+        }
+
+
+    }
+
+    protected String generateEventId(ActivityEvent event, XWikiContext 
context) {
+        return event.getStream() + "-" + event.getApplication() + "-" + 
event.getWiki() + ":" + event.getPage() + "-" + event.getType() + "-" + 
event.getDate().getTime() + "-" + RandomStringUtils.randomAlphanumeric(4);
+    }
+
+    public void addActivityEvent(ActivityEvent event, XWikiContext context) 
throws ActivityStreamException {
+        prepareEvent(event, context);
+
+        // store event using hibernate
+        XWikiHibernateStore hibstore = context.getWiki().getHibernateStore();
+        try {
+            hibstore.beginTransaction(context);
+            Session session = hibstore.getSession(context);
+            session.saveOrUpdate(event);
+            hibstore.endTransaction(context, true);
+        } catch (XWikiException e) {
+            hibstore.endTransaction(context, false);
+        }
+
+    }
+
+    public void addActivityEvent(String type, String title, XWikiContext 
context) throws ActivityStreamException {
+        ActivityEvent event = new ActivityEventImpl();
+        event.setType(type);
+        event.setTitle(title);
+        event.setBody(title);
+        addActivityEvent(event, context);
+    }
+
+    public void addDocumentActivityEvent(XWikiDocument doc, String type, 
String title, XWikiContext context) throws ActivityStreamException {
+        ActivityEvent event = new ActivityEventImpl();
+        event.setPage(doc.getFullName());
+        if (doc.getDatabase()!=null) {
+            event.setWiki(doc.getDatabase());
+        }
+        event.setDate(doc.getDate());
+        event.setPriority(ActivityEventPriority.ACTION);
+        event.setType(type);
+        event.setTitle(title);
+        event.setBody(title);
+        addActivityEvent(event, context);
+    }
+
+    public List searchEvents(String hql, boolean filter, int nb, int start, 
XWikiContext context) throws ActivityStreamException {
+        String searchHql = "select act.* from ActivityEvent as act " + hql;
+
+
+
+        String filterQuery = ", ActivityEvent act2 where 
act.eventId=act2.eventId and act.priority=max(act2.priority)";
+        if (filter) {
+            searchHql += filterQuery;
+        }
+
+        if (!hql.contains("order by")) {
+            searchHql += " order by act.date desc";
+        }
+
+        try {
+            return context.getWiki().search(searchHql, nb, start, context);
+        } catch (XWikiException e) {
+            throw new ActivityStreamException(e);
+        }
+
+    }
+
+    public List getEvents(boolean filter, int nb, int start, XWikiContext 
context) throws ActivityStreamException {
+        return searchEvents("", filter, nb, start, context);
+    }
+
+    public List getEventsForSpace(String space, boolean filter, int nb, int 
start, XWikiContext context) throws ActivityStreamException {
+        return searchEvents("where act.space='" + space + "'", filter, nb, 
start, context);
+    }
+
+    public List getEventsForUser(String user, boolean filter, int nb, int 
start, XWikiContext context) throws ActivityStreamException {
+        return searchEvents("where act.user='" + user + "'", filter, nb, 
start, context);
+    }
+
+    public List getEvents(String stream, boolean filter, int nb, int start, 
XWikiContext context) throws ActivityStreamException {
+        return searchEvents("where act.stream='" + stream + "'", filter, nb, 
start, context);
+    }
+
+    public List getEventsForSpace(String stream, String space, boolean filter, 
int nb, int start, XWikiContext context) throws ActivityStreamException {
+        return searchEvents("where act.space='" + space + "' and act.stream='" 
+ stream + "'", filter, nb, start, context);
+    }
+
+    public List getEventsForUser(String stream, String user, boolean filter, 
int nb, int start, XWikiContext context) throws ActivityStreamException {
+        return searchEvents("where act.user='" + user + "' and act.stream='" + 
stream + "'", filter, nb, start, context);
+    }
+
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPlugin.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPlugin.java
                          (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPlugin.java
  2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,104 @@
+/*
+ * 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.xwiki.plugin.activitystream.plugin;
+
+import org.xwiki.plugin.activitystream.impl.ActivityStreamImpl;
+import org.xwiki.plugin.activitystream.api.ActivityStream;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.api.Api;
+import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
+import com.xpn.xwiki.plugin.XWikiPluginInterface;
+
+/**
+ * Plug-in for for managing invitations and membership requests
+ * 
+ * @see org.xwiki.plugin.invitationmanager.api.InvitationManager
+ */
+public class ActivityStreamPlugin extends XWikiDefaultPlugin
+{
+    /**
+     * We should user inversion of control instead
+     */
+    private ActivityStream invitationManager = new ActivityStreamImpl();
+
+    /**
+     * [EMAIL PROTECTED]
+     * 
+     * @see 
XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
+     */
+    public ActivityStreamPlugin(String name, String className, XWikiContext 
context)
+    {
+        super(name, className, context);
+
+        // move this to ActivityStreamImpl in the near future
+        String mailNotificationCfg =
+            context.getWiki().Param("xwiki.activitystream.mailnotification", 
"1").trim();
+        boolean mailNotification = "1".equals(mailNotificationCfg);
+        // ((ActivityStreamImpl) 
invitationManager).setMailNotification(mailNotification);
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     * 
+     * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getName()
+     */
+    public String getName()
+    {
+        return new String("activitystream");
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     * 
+     * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getPluginApi
+     */
+    public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
+    {
+        return new ActivityStreamPluginApi((ActivityStreamPlugin) plugin, 
context);
+    }
+
+    public ActivityStream getActivityStream()
+    {
+        return invitationManager;
+    }
+
+    public void setActivityStream(ActivityStream invitationManager)
+    {
+        this.invitationManager = invitationManager;
+    }
+
+
+    public void init(XWikiContext context) {
+        super.init(context);
+        try {
+            invitationManager.initClasses(context);
+        } catch (Exception e) {
+        }
+    }
+
+    public void virtualInit(XWikiContext context) {
+        super.virtualInit(context);
+        try {
+            invitationManager.initClasses(context);
+        } catch (Exception e) {
+        }
+    }
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPluginApi.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPluginApi.java
                               (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPluginApi.java
       2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,41 @@
+/*
+ * 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.xwiki.plugin.activitystream.plugin;
+
+import org.xwiki.plugin.activitystream.api.ActivityStream;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.plugin.PluginApi;
+
+/**
+ * API for [EMAIL PROTECTED] ActivityStreamPlugin}
+ */
+public class ActivityStreamPluginApi extends PluginApi
+{
+    public ActivityStreamPluginApi(ActivityStreamPlugin plugin, XWikiContext 
context)
+    {
+        super(plugin, context);
+    }
+
+    protected ActivityStream getActivityStream()
+    {
+        return ((ActivityStreamPlugin) getPlugin()).getActivityStream();
+    }
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationManagerImplTest.java.old
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationManagerImplTest.java.old
                           (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationManagerImplTest.java.old
   2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,76 @@
+/*
+ * 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.xwiki.plugin.invitationmanager.impl;
+
+import org.xwiki.plugin.invitationmanager.api.Invitation;
+import org.xwiki.plugin.invitationmanager.api.MembershipRequest;
+
+import com.xpn.xwiki.XWikiException;
+
+/**
+ * Unit tests for [EMAIL PROTECTED] InvitationManagerImpl} class
+ */
+public class InvitationManagerImplTest extends InvitationManagerTest
+{
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        invitationManager = new InvitationManagerImpl();
+        ((InvitationManagerImpl) invitationManager).setMailNotification(false);
+    }
+
+    protected Invitation createInvitation(String invitee, String space) throws 
XWikiException
+    {
+        return new InvitationImpl(invitee,
+            space,
+            true,
+            (InvitationManagerImpl) invitationManager,
+            context);
+    }
+
+    protected MembershipRequest createMembershipRequest(String requester, 
String space)
+        throws XWikiException
+    {
+        return new MembershipRequestImpl(requester,
+            space,
+            true,
+            (InvitationManagerImpl) invitationManager,
+            context);
+    }
+
+    protected Invitation getInvitation(String invitee, String space) throws 
XWikiException
+    {
+        return new InvitationImpl(invitee,
+            space,
+            false,
+            (InvitationManagerImpl) invitationManager,
+            context);
+    }
+
+    protected MembershipRequest getMembershipRequest(String requester, String 
space)
+        throws XWikiException
+    {
+        return new MembershipRequestImpl(requester,
+            space,
+            false,
+            (InvitationManagerImpl) invitationManager,
+            context);
+    }
+}

Added: 
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationTest.java.old
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationTest.java.old
                              (rev 0)
+++ 
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/InvitationTest.java.old
      2008-02-04 00:23:20 UTC (rev 7286)
@@ -0,0 +1,73 @@
+/*
+ * 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.xwiki.plugin.invitationmanager.impl;
+
+import org.xwiki.plugin.invitationmanager.api.Invitation;
+
+/**
+ * Unit tests for classes implementing [EMAIL PROTECTED] Invitation} interface
+ */
+public abstract class InvitationTest extends JoinRequestTest
+{
+    public Invitation getInvitation()
+    {
+        return (Invitation) joinRequest;
+    }
+
+    /**
+     * test for [EMAIL PROTECTED] Invitation#getInvitee()}
+     */
+    public void testInvitee()
+    {
+        String invitee = "[EMAIL PROTECTED]";
+        getInvitation().setInvitee(invitee);
+        assertEquals(invitee, getInvitation().getInvitee());
+    }
+
+    /**
+     * test for [EMAIL PROTECTED] Invitation#getInviter()}
+     */
+    public void testInviter()
+    {
+        String inviter = "foobar";
+        getInvitation().setInviter(inviter);
+        assertEquals(inviter, getInvitation().getInviter());
+    }
+
+    /**
+     * test for [EMAIL PROTECTED] Invitation#getCode()}
+     */
+    public void testCode()
+    {
+        String code = "qwertyuiopasdfghjkl";
+        getInvitation().setCode(code);
+        assertEquals(code, getInvitation().getCode());
+    }
+
+    /**
+     * test for [EMAIL PROTECTED] Invitation#isOpen()}
+     */
+    public void testOpen()
+    {
+        boolean open = true;
+        getInvitation().setOpen(open);
+        assertEquals(open, getInvitation().isOpen());
+    }
+}

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to