Author: mflorea
Date: 2008-02-07 13:56:56 +0100 (Thu, 07 Feb 2008)
New Revision: 7343
Added:
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventImplTest.java
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventTest.java
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImplTest.java
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamTest.java
Modified:
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/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/ActivityStreamPlugin.java
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPluginApi.java
Log:
clean-up
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEvent.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -19,10 +19,10 @@
*/
package org.xwiki.plugin.activitystream.api;
-import com.xpn.xwiki.XWikiContext;
-
import java.util.Date;
+import com.xpn.xwiki.XWikiContext;
+
/**
* An Activity Event represents a event done by a user in a certain context.
*/
@@ -39,7 +39,6 @@
*/
void setEventId(String id);
-
/**
* @return The request ID
*/
@@ -51,7 +50,6 @@
*/
void setRequestId(String id);
-
/**
* @return The priority of the event
*/
@@ -74,19 +72,17 @@
*/
void setType(String type);
+ /**
+ * @return The application name
+ */
+ String getApplication();
/**
- * @return The application name
- */
- String getApplication();
+ * @param application The application Name
+ * @see #getApplication()
+ */
+ void setApplication(String application);
- /**
- * @param application The application Name
- * @see #getApplication()
- */
- void setApplication(String application);
-
-
/**
* @return The stream name
*/
@@ -98,7 +94,6 @@
*/
void setStream(String stream);
-
/**
* @return The stream name
*/
@@ -110,7 +105,6 @@
*/
void setDate(Date date);
-
/**
* @return The wiki name of the user creating the event
*/
@@ -144,7 +138,6 @@
*/
void setSpace(String space);
-
/**
* @return The page of the event
*/
@@ -156,7 +149,6 @@
*/
void setPage(String page);
-
/**
* @return The target url
*/
@@ -190,7 +182,6 @@
*/
void setBody(String body);
-
/**
* @return The first param of the event
*/
@@ -202,7 +193,6 @@
*/
void setParam1(String param1);
-
/**
* @return The second param of the event
*/
@@ -247,9 +237,9 @@
*/
void setParam5(String param5);
-
/**
* Retrieves the event in displayable format
+ *
* @param context
* @return
*/
@@ -257,6 +247,7 @@
/**
* Retrieves the event body in displayable format
+ *
* @param context
* @return
*/
@@ -264,6 +255,7 @@
/**
* Retrieves the event date in displayable format
+ *
* @param context
* @return
*/
@@ -271,9 +263,9 @@
/**
* Retrieves the event user in displayable format
+ *
* @param context
* @return
*/
String getDisplayUser(XWikiContext context);
-
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventPriority.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -1,12 +1,30 @@
+/*
+ * 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 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.
- *
+ * 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 {
-
+public interface ActivityEventPriority
+{
/**
* The event is a storage level event (low level)
*/
@@ -23,8 +41,7 @@
int ACTION = 30;
/**
- * The event is a program level event (higgest level)
+ * The event is a program level event (highest level)
*/
int PROGRAM = 40;
-
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityEventType.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -21,10 +21,9 @@
/**
* The type of request. This list is extensible.
- *
*/
-public interface ActivityEventType {
-
+public interface ActivityEventType
+{
String OTHER = "other";
String CREATE = "create";
@@ -54,5 +53,4 @@
String CHANGE_RIGHTS = "changerights";
String NEW_MEMBER = "newmember";
-
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStream.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -20,7 +20,6 @@
package org.xwiki.plugin.activitystream.api;
import java.util.List;
-import java.util.Map;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
@@ -31,39 +30,46 @@
*/
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
+ * 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(ActivityEvent event, XWikiContext context)
+ throws ActivityStreamException;
- void addActivityEvent(String type, String title, 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;
+ 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 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 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 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 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 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 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;
-
+ List getEventsForUser(String streamName, String user, boolean filter, int
nb, int start,
+ XWikiContext context) throws ActivityStreamException;
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/api/ActivityStreamException.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -1,8 +1,4 @@
-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/>
@@ -21,39 +17,47 @@
* 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;
-public class ActivityStreamException extends XWikiException {
- public static final int MODULE_PLUGIN_ActivityStream = 101;
+import com.xpn.xwiki.XWikiException;
- 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 class ActivityStreamException extends XWikiException
+{
+ public static final int MODULE_PLUGIN_ACTIVITY_STREAM = 102;
- public ActivityStreamException(){
- }
+ /**
+ * @see XWikiException#XWikiException()
+ */
+ public ActivityStreamException()
+ {
+ }
- public ActivityStreamException(int module, int code, String message){
+ /**
+ * @see XWikiException#XWikiException(int, int, String)
+ */
+ public ActivityStreamException(int module, int code, String message)
+ {
super(module, code, message);
}
- public ActivityStreamException(int module, int code, String message,
Exception e){
+ /**
+ * @see XWikiException#XWikiException(int, int, String, Throwable)
+ */
+ public ActivityStreamException(int module, int code, String message,
Exception e)
+ {
super(module, code, message, e);
}
- public ActivityStreamException( XWikiException e ){
+ /**
+ * @see Exception#Exception(Throwable)
+ */
+ public ActivityStreamException(XWikiException e)
+ {
super();
setModule(e.getModule());
setCode(e.getCode());
setException(e.getException());
setArgs(e.getArgs());
setMessage(e.getMessage());
- }
+ }
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityEventImpl.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -19,202 +19,259 @@
*/
package org.xwiki.plugin.activitystream.impl;
+import java.util.Date;
-import com.xpn.xwiki.XWikiContext;
import org.xwiki.plugin.activitystream.api.ActivityEvent;
-import java.util.Date;
+import com.xpn.xwiki.XWikiContext;
-/**
- */
-public class ActivityEventImpl implements ActivityEvent {
+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) {
+ public String getDisplayTitle(XWikiContext context)
+ {
return context.getWiki().parseMessage(title, context);
}
- public String getDisplayBody(XWikiContext context) {
- return context.getWiki().parseMessage(body, context);
+ public String getDisplayBody(XWikiContext context)
+ {
+ return context.getWiki().parseMessage(body, context);
}
- public String getDisplayDate(XWikiContext context) {
+ public String getDisplayDate(XWikiContext context)
+ {
return context.getWiki().formatDate(date, null, context);
}
- public String getDisplayUser(XWikiContext context) {
+ public String getDisplayUser(XWikiContext context)
+ {
return context.getWiki().getLocalUserName(user, context);
}
- public String getEventId() {
+ public String getEventId()
+ {
return eventId;
}
- public void setEventId(String eventId) {
+ public void setEventId(String eventId)
+ {
this.eventId = eventId;
}
- public String getRequestId() {
+ public String getRequestId()
+ {
return requestId;
}
- public void setRequestId(String requestId) {
+ public void setRequestId(String requestId)
+ {
this.requestId = requestId;
}
- public int getPriority() {
+ public int getPriority()
+ {
return priority;
}
- public void setPriority(int priority) {
+ public void setPriority(int priority)
+ {
this.priority = priority;
}
- public String getApplication() {
+ public String getApplication()
+ {
return application;
}
- public void setStream(String stream) {
+ public void setStream(String stream)
+ {
this.stream = stream;
}
- public String getParam1() {
+ public String getParam1()
+ {
return param1;
}
- public void setParam1(String param1) {
+ public void setParam1(String param1)
+ {
this.param1 = param1;
}
- public String getParam2() {
+ public String getParam2()
+ {
return param2;
}
- public void setParam2(String param2) {
+ public void setParam2(String param2)
+ {
this.param2 = param2;
}
- public String getParam3() {
+ public String getParam3()
+ {
return param3;
}
- public void setParam3(String param3) {
+ public void setParam3(String param3)
+ {
this.param3 = param3;
}
- public String getParam4() {
+ public String getParam4()
+ {
return param4;
}
- public void setParam4(String param4) {
+ public void setParam4(String param4)
+ {
this.param4 = param4;
}
- public String getParam5() {
+ public String getParam5()
+ {
return param5;
}
- public void setParam5(String param5) {
+ public void setParam5(String param5)
+ {
this.param5 = param5;
}
- public String getWiki() {
+ public String getWiki()
+ {
return wiki;
}
- public void setWiki(String wiki) {
+ public void setWiki(String wiki)
+ {
this.wiki = wiki;
}
- public String getType() {
+ public String getType()
+ {
return type;
}
- public void setType(String type) {
+ public void setType(String type)
+ {
this.type = type;
}
- public String getUser() {
+ public String getUser()
+ {
return user;
}
- public void setUser(String user) {
+ public void setUser(String user)
+ {
this.user = user;
}
- public String getSpace() {
+ public String getSpace()
+ {
return space;
}
- public void setSpace(String space) {
+ public void setSpace(String space)
+ {
this.space = space;
}
- public String getPage() {
+ public String getPage()
+ {
return page;
}
- public void setPage(String page) {
+ public void setPage(String page)
+ {
this.page = page;
}
- public String getUrl() {
+ public String getUrl()
+ {
return url;
}
- public void setUrl(String url) {
+ public void setUrl(String url)
+ {
this.url = url;
}
- public String getTitle() {
+ public String getTitle()
+ {
return title;
}
- public void setTitle(String title) {
+ public void setTitle(String title)
+ {
this.title = title;
}
- public String getBody() {
+ public String getBody()
+ {
return body;
}
- public void setBody(String body) {
+ public void setBody(String body)
+ {
this.body = body;
}
- public Date getDate() {
+ public Date getDate()
+ {
return date;
}
- public void setDate(Date date) {
+ public void setDate(Date date)
+ {
this.date = date;
}
- public String getStream() {
+ public String getStream()
+ {
return stream;
}
- public void setApplication(String application) {
+ public void setApplication(String application)
+ {
this.application = application;
}
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImpl.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -19,85 +19,70 @@
*/
package org.xwiki.plugin.activitystream.impl;
+import java.util.List;
-import org.xwiki.plugin.activitystream.api.*;
import org.apache.commons.lang.RandomStringUtils;
import org.hibernate.Session;
+import org.xwiki.plugin.activitystream.api.ActivityEvent;
+import org.xwiki.plugin.activitystream.api.ActivityEventPriority;
+import org.xwiki.plugin.activitystream.api.ActivityStream;
+import org.xwiki.plugin.activitystream.api.ActivityStreamException;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
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 {
+public class ActivityStreamImpl implements ActivityStream
+{
+ public void initClasses(XWikiContext context) throws XWikiException
+ {
}
-
- protected void prepareEvent(ActivityEvent event, XWikiContext context) {
- if (event.getUser()==null) {
+ protected void prepareEvent(ActivityEvent event, XWikiContext context)
+ {
+ if (event.getUser() == null) {
event.setUser(context.getUser());
}
- if (event.getStream()==null) {
+ if (event.getStream() == null) {
event.setStream(context.getUser());
}
- if (event.getWiki()==null) {
+ if (event.getWiki() == null) {
event.setWiki(context.getDatabase());
}
- if (event.getSpace()==null) {
+ if (event.getSpace() == null) {
event.setSpace(context.getDoc().getSpace());
}
- if (event.getPage()==null) {
+ if (event.getPage() == null) {
event.setPage(context.getDoc().getFullName());
}
- if (event.getUrl()==null) {
+ if (event.getUrl() == null) {
event.setUrl(context.getDoc().getURL("view", context));
}
- if (event.getApplication()==null) {
+ if (event.getApplication() == null) {
event.setApplication("xwiki");
}
- if (event.getDate()==null) {
+ 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.getEventId() == null) {
+ event.setEventId(generateEventId(event, context));
}
- if (event.getRequestId()==null) {
- event.setRequestId(eventId);
+ if (event.getRequestId() == null) {
+ event.setRequestId((String)
context.get("activitystream_requestid"));
}
-
-
}
- protected String generateEventId(ActivityEvent event, XWikiContext
context) {
- return event.getStream() + "-" + event.getApplication() + "-" +
event.getWiki() + ":" + event.getPage() + "-" + event.getType() + "-" +
event.getDate().getTime() + "-" + RandomStringUtils.randomAlphanumeric(4);
+ 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 {
+ public void addActivityEvent(ActivityEvent event, XWikiContext context)
+ throws ActivityStreamException
+ {
prepareEvent(event, context);
// store event using hibernate
@@ -110,21 +95,24 @@
} catch (XWikiException e) {
hibstore.endTransaction(context, false);
}
-
}
- public void addActivityEvent(String type, String title, XWikiContext
context) throws ActivityStreamException {
- ActivityEvent event = new ActivityEventImpl();
+ public void addActivityEvent(String type, String title, XWikiContext
context)
+ throws ActivityStreamException
+ {
+ ActivityEvent event = newActivityEvent();
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();
+ public void addDocumentActivityEvent(XWikiDocument doc, String type,
String title,
+ XWikiContext context) throws ActivityStreamException
+ {
+ ActivityEvent event = newActivityEvent();
event.setPage(doc.getFullName());
- if (doc.getDatabase()!=null) {
+ if (doc.getDatabase() != null) {
event.setWiki(doc.getDatabase());
}
event.setDate(doc.getDate());
@@ -135,12 +123,12 @@
addActivityEvent(event, context);
}
- public List searchEvents(String hql, boolean filter, int nb, int start,
XWikiContext context) throws ActivityStreamException {
+ 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)";
+ String filterQuery =
+ ", ActivityEvent act2 where act.eventId=act2.eventId and
act.priority=max(act2.priority)";
if (filter) {
searchHql += filterQuery;
}
@@ -154,31 +142,48 @@
} catch (XWikiException e) {
throw new ActivityStreamException(e);
}
-
}
- public List getEvents(boolean filter, int nb, int start, XWikiContext
context) throws ActivityStreamException {
+ 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 {
+ 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 {
+ 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 {
+ 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 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);
+ 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);
}
+ protected ActivityEvent newActivityEvent()
+ {
+ return new ActivityEventImpl();
+ }
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPlugin.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -19,8 +19,8 @@
*/
package org.xwiki.plugin.activitystream.plugin;
+import org.xwiki.plugin.activitystream.api.ActivityStream;
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;
@@ -28,37 +28,29 @@
import com.xpn.xwiki.plugin.XWikiPluginInterface;
/**
- * Plug-in for for managing invitations and membership requests
+ * Plug-in for for managing streams of activity events
*
- * @see org.xwiki.plugin.invitationmanager.api.InvitationManager
+ * @see ActivityStream
*/
public class ActivityStreamPlugin extends XWikiDefaultPlugin
{
/**
* We should user inversion of control instead
*/
- private ActivityStream invitationManager = new ActivityStreamImpl();
+ private ActivityStream activityStream = 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()
+ * @see XWikiDefaultPlugin#getName()
*/
public String getName()
{
@@ -68,36 +60,53 @@
/**
* [EMAIL PROTECTED]
*
- * @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getPluginApi
+ * @see XWikiDefaultPlugin#getPluginApi
*/
public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
{
return new ActivityStreamPluginApi((ActivityStreamPlugin) plugin,
context);
}
+ /**
+ * @return The [EMAIL PROTECTED] ActivityStream} component used in behind
by this plug-in instance
+ */
public ActivityStream getActivityStream()
{
- return invitationManager;
+ return activityStream;
}
- public void setActivityStream(ActivityStream invitationManager)
+ /**
+ * @param activityStream The [EMAIL PROTECTED] ActivityStream} component
to be used
+ */
+ public void setActivityStream(ActivityStream activityStream)
{
- this.invitationManager = invitationManager;
+ this.activityStream = activityStream;
}
-
- public void init(XWikiContext context) {
+ /**
+ * [EMAIL PROTECTED]
+ *
+ * @see XWikiDefaultPlugin#init(XWikiContext)
+ */
+ public void init(XWikiContext context)
+ {
super.init(context);
try {
- invitationManager.initClasses(context);
+ activityStream.initClasses(context);
} catch (Exception e) {
}
}
- public void virtualInit(XWikiContext context) {
+ /**
+ * [EMAIL PROTECTED]
+ *
+ * @see XWikiDefaultPlugin#virtualInit(XWikiContext)
+ */
+ public void virtualInit(XWikiContext context)
+ {
super.virtualInit(context);
try {
- invitationManager.initClasses(context);
+ activityStream.initClasses(context);
} catch (Exception e) {
}
}
Modified:
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
2008-02-07 12:14:01 UTC (rev 7342)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/main/java/org/xwiki/plugin/activitystream/plugin/ActivityStreamPluginApi.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -23,17 +23,24 @@
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.plugin.PluginApi;
+import com.xpn.xwiki.plugin.XWikiPluginInterface;
/**
* API for [EMAIL PROTECTED] ActivityStreamPlugin}
*/
public class ActivityStreamPluginApi extends PluginApi
{
+ /**
+ * @see PluginApi#PluginApi(XWikiPluginInterface, XWikiContext)
+ */
public ActivityStreamPluginApi(ActivityStreamPlugin plugin, XWikiContext
context)
{
super(plugin, context);
}
+ /**
+ * @return The [EMAIL PROTECTED] ActivityStream} component to use inside
the API
+ */
protected ActivityStream getActivityStream()
{
return ((ActivityStreamPlugin) getPlugin()).getActivityStream();
Added:
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventImplTest.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventImplTest.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventImplTest.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * Unit tests for [EMAIL PROTECTED] ActivityEventImpl} class
+ */
+public class ActivityEventImplTest extends ActivityEventTest
+{
+}
Added:
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventTest.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventTest.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityEventTest.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -0,0 +1,29 @@
+/*
+ * 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.ActivityEvent;
+
+/**
+ * Unit tests for classes implementing [EMAIL PROTECTED] ActivityEvent}
interface.
+ */
+public abstract class ActivityEventTest // extends MockObjectTestCase
+{
+}
Added:
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImplTest.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImplTest.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamImplTest.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * Unit tests for [EMAIL PROTECTED] ActivityStreamImpl#} class.
+ */
+public class ActivityStreamImplTest extends ActivityStreamTest
+{
+}
Added:
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamTest.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamTest.java
(rev 0)
+++
xwiki-products/curriki/trunk/plugins/activitystream/src/test/java/org/xwiki/plugin/activitystream/impl/ActivityStreamTest.java
2008-02-07 12:56:56 UTC (rev 7343)
@@ -0,0 +1,29 @@
+/*
+ * 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.ActivityStream;
+
+/**
+ * Unit tests for classes implementing [EMAIL PROTECTED] ActivityStream}
interface.
+ */
+public abstract class ActivityStreamTest // extends MockObjectTestCase
+{
+}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications