mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
MOB-594 - user activities feed now returns all activities (including own) - also have optional filters to either exclude own or exclude others
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -4,11 +4,12 @@
|
|||||||
<url>/api/activities/feed/user/{userId}</url>
|
<url>/api/activities/feed/user/{userId}</url>
|
||||||
<url>/api/activities/feed/user/{userId}?format=atomfeed</url>
|
<url>/api/activities/feed/user/{userId}?format=atomfeed</url>
|
||||||
<url>/api/activities/feed/user/{userId}?format=json</url>
|
<url>/api/activities/feed/user/{userId}?format=json</url>
|
||||||
<url>/api/activities/feed/user/{userId}?format=rss</url>
|
|
||||||
<url>/api/activities/feed/user/{userId}?s={siteId}</url>
|
<url>/api/activities/feed/user/{userId}?s={siteId}</url>
|
||||||
<url>/api/activities/feed/user/{userId}?s={siteId}&format=atomfeed</url>
|
<url>/api/activities/feed/user/{userId}?s={siteId}&format=atomfeed</url>
|
||||||
<url>/api/activities/feed/user/{userId}?s={siteId}&format=json</url>
|
<url>/api/activities/feed/user/{userId}?s={siteId}&format=json</url>
|
||||||
<url>/api/activities/feed/user/{userId}?s={siteId}&format=rss</url>
|
<url>/api/activities/feed/user/{userId}?s={siteId?}&exclUser={false?}&exclOthers={false?}</url>
|
||||||
|
<url>/api/activities/feed/user/{userId}?s={siteId?}&exclUser={false?}&exclOthers={false?}&format=atomfeed</url>
|
||||||
|
<url>/api/activities/feed/user/{userId}?s={siteId?}&exclUser={false?}&exclOthers={false?}&format=json</url>
|
||||||
<format default="atomfeed">argument</format>
|
<format default="atomfeed">argument</format>
|
||||||
<authentication>admin</authentication>
|
<authentication>admin</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
|
@@ -4,11 +4,12 @@
|
|||||||
<url>/api/activities/feed/user</url>
|
<url>/api/activities/feed/user</url>
|
||||||
<url>/api/activities/feed/user?format=atomfeed</url>
|
<url>/api/activities/feed/user?format=atomfeed</url>
|
||||||
<url>/api/activities/feed/user?format=json</url>
|
<url>/api/activities/feed/user?format=json</url>
|
||||||
<url>/api/activities/feed/user?format=rss</url>
|
<url>/api/activities/feed/user?s={siteId?}</url>
|
||||||
<url>/api/activities/feed/user?s={siteId}</url>
|
<url>/api/activities/feed/user?s={siteId?}&format=atomfeed</url>
|
||||||
<url>/api/activities/feed/user?s={siteId}&format=atomfeed</url>
|
<url>/api/activities/feed/user?s={siteId?}&format=json</url>
|
||||||
<url>/api/activities/feed/user?s={siteId}&format=json</url>
|
<url>/api/activities/feed/user?s={siteId?}&exclUser={false?}&exclOthers={false?}</url>
|
||||||
<url>/api/activities/feed/user?s={siteId}&format=rss</url>
|
<url>/api/activities/feed/user?s={siteId?}&exclUser={false?}&exclOthers={false?}&format=atomfeed</url>
|
||||||
|
<url>/api/activities/feed/user?s={siteId?}&exclUser={false?}&exclOthers={false?}&format=json</url>
|
||||||
<format default="atomfeed"></format>
|
<format default="atomfeed"></format>
|
||||||
<authentication>user</authentication>
|
<authentication>user</authentication>
|
||||||
<transaction>required</transaction>
|
<transaction>required</transaction>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -38,8 +38,8 @@ import java.util.Date;
|
|||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
|
import org.alfresco.repo.web.scripts.activities.feed.UserFeedRetrieverWebScript;
|
||||||
import org.alfresco.util.Base64;
|
import org.alfresco.util.Base64;
|
||||||
import org.alfresco.util.ISO8601DateFormat;
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -272,6 +272,8 @@ public class SiteActivitySystemTest extends TestCase
|
|||||||
{
|
{
|
||||||
testCreateSites();
|
testCreateSites();
|
||||||
|
|
||||||
|
// as admin
|
||||||
|
|
||||||
String ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, ADMIN_USER, ADMIN_PW);
|
String ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, ADMIN_USER, ADMIN_PW);
|
||||||
|
|
||||||
getUserFeed(user1, ticket, true, 0);
|
getUserFeed(user1, ticket, true, 0);
|
||||||
@@ -279,10 +281,14 @@ public class SiteActivitySystemTest extends TestCase
|
|||||||
getUserFeed(user3, ticket, true, 0);
|
getUserFeed(user3, ticket, true, 0);
|
||||||
getUserFeed(user4, ticket, true, 0);
|
getUserFeed(user4, ticket, true, 0);
|
||||||
|
|
||||||
|
// as user1
|
||||||
|
|
||||||
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user1, USER_PW);
|
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user1, USER_PW);
|
||||||
|
|
||||||
getUserFeed(user1, ticket, false, 0);
|
getUserFeed(user1, ticket, false, 0);
|
||||||
|
|
||||||
|
// as user2
|
||||||
|
|
||||||
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user2, USER_PW);
|
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user2, USER_PW);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -295,11 +301,41 @@ public class SiteActivitySystemTest extends TestCase
|
|||||||
{
|
{
|
||||||
assertTrue(ioe.getMessage().contains("HTTP response code: 401"));
|
assertTrue(ioe.getMessage().contains("HTTP response code: 401"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// as user1 - with filter args ...
|
||||||
|
|
||||||
|
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user1, USER_PW);
|
||||||
|
|
||||||
|
getUserFeed(null, site1, ticket, false, false, false, 0);
|
||||||
|
getUserFeed(null, site2, ticket, false, false, false, 0);
|
||||||
|
getUserFeed(null, site3, ticket, false, false, false, 0);
|
||||||
|
|
||||||
|
getUserFeed(null, null, ticket, false, true, false, 0);
|
||||||
|
getUserFeed(null, null, ticket, false, false, true, 0);
|
||||||
|
getUserFeed(null, null, ticket, false, true, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getUserFeed(String userId, String ticket, boolean isAdmin, int expectedCount) throws Exception
|
protected void getUserFeed(String userId, String ticket, boolean isAdmin, int expectedCount) throws Exception
|
||||||
{
|
{
|
||||||
String url = WEBSCRIPT_ENDPOINT + URL_ACTIVITIES + URL_USER_FEED + (isAdmin ? "/" + userId : "") + "?format=json";
|
getUserFeed(userId, null, ticket, isAdmin, false, false, expectedCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void getUserFeed(String userId, String siteId, String ticket, boolean isAdmin, boolean excludeThisUser, boolean excludeOtherUsers, int expectedCount) throws Exception
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append(WEBSCRIPT_ENDPOINT).
|
||||||
|
append(URL_ACTIVITIES).
|
||||||
|
append(URL_USER_FEED).
|
||||||
|
append(isAdmin ? "/" + userId : ""). // optional
|
||||||
|
append("?").
|
||||||
|
append((siteId != null) ? UserFeedRetrieverWebScript.PARAM_SITE_ID + "=" + siteId + "&": ""). // optional
|
||||||
|
append(excludeThisUser ? UserFeedRetrieverWebScript.PARAM_EXCLUDE_THIS_USER + "=true&" : ""). // optional
|
||||||
|
append(excludeOtherUsers ? UserFeedRetrieverWebScript.PARAM_EXCLUDE_OTHER_USERS + "=true&" : ""). // optional
|
||||||
|
append("format=json");
|
||||||
|
|
||||||
|
String url = sb.toString();
|
||||||
String jsonArrayResult = callGetWebScript(url, ticket);
|
String jsonArrayResult = callGetWebScript(url, ticket);
|
||||||
|
|
||||||
if (jsonArrayResult != null)
|
if (jsonArrayResult != null)
|
||||||
@@ -482,6 +518,8 @@ public class SiteActivitySystemTest extends TestCase
|
|||||||
testRemoveMembershipsWithPause();
|
testRemoveMembershipsWithPause();
|
||||||
testUserFeedControls();
|
testUserFeedControls();
|
||||||
|
|
||||||
|
// as admin
|
||||||
|
|
||||||
String ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, ADMIN_USER, ADMIN_PW);
|
String ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, ADMIN_USER, ADMIN_PW);
|
||||||
|
|
||||||
// 2 sites, with 4 users, each with 1 join and 1 role change = 8x2
|
// 2 sites, with 4 users, each with 1 join and 1 role change = 8x2
|
||||||
@@ -492,10 +530,14 @@ public class SiteActivitySystemTest extends TestCase
|
|||||||
getUserFeed(user3, ticket, true, 14); // 8 = due to feed control - exclude site membership activities for site 1
|
getUserFeed(user3, ticket, true, 14); // 8 = due to feed control - exclude site membership activities for site 1
|
||||||
getUserFeed(user4, ticket, true, 16); // 16 = no feed control
|
getUserFeed(user4, ticket, true, 16); // 16 = no feed control
|
||||||
|
|
||||||
|
// as user1
|
||||||
|
|
||||||
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user1, USER_PW);
|
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user1, USER_PW);
|
||||||
|
|
||||||
getUserFeed(user1, ticket, false, 14);
|
getUserFeed(user1, ticket, false, 14);
|
||||||
|
|
||||||
|
// as user2
|
||||||
|
|
||||||
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user2, USER_PW);
|
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user2, USER_PW);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -508,6 +550,21 @@ public class SiteActivitySystemTest extends TestCase
|
|||||||
{
|
{
|
||||||
assertTrue(ioe.getMessage().contains("HTTP response code: 401"));
|
assertTrue(ioe.getMessage().contains("HTTP response code: 401"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// as user1 - with filter args ...
|
||||||
|
|
||||||
|
ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, user1, USER_PW);
|
||||||
|
|
||||||
|
getUserFeed(null, site1, ticket, false, false, false, 0);
|
||||||
|
getUserFeed(null, site2, ticket, false, false, false, 8);
|
||||||
|
getUserFeed(null, site3, ticket, false, false, false, 6);
|
||||||
|
|
||||||
|
getUserFeed(null, null, ticket, false, false, false, 14); // no filter
|
||||||
|
getUserFeed(null, null, ticket, false, true, false, 14); // exclude any from user1
|
||||||
|
getUserFeed(null, null, ticket, false, false, true, 0); // exclude all except user1
|
||||||
|
getUserFeed(null, null, ticket, false, true, true, 0); // exclude all (NOOP)
|
||||||
|
|
||||||
|
// TODO - add more (eg. other non-admin user activities)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMembership(String siteId, String userName, String ticket, String role) throws Exception
|
private void addMembership(String siteId, String userName, String ticket, String role) throws Exception
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -31,6 +31,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
import org.alfresco.service.cmr.activities.ActivityService;
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
@@ -100,7 +101,17 @@ public class SiteFeedRetrieverWebScript extends DeclarativeWebScript
|
|||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
|
|
||||||
// if site is null then either does not exist or is private (and current user is not admin or a member) - hence return 401 (unauthorised)
|
// if site is null then either does not exist or is private (and current user is not admin or a member) - hence return 401 (unauthorised)
|
||||||
SiteInfo siteInfo = siteService.getSite(siteId);
|
|
||||||
|
SiteInfo siteInfo = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
siteInfo = siteService.getSite(siteId);
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException ade)
|
||||||
|
{
|
||||||
|
// ignore - fall through
|
||||||
|
}
|
||||||
|
|
||||||
if (siteInfo == null)
|
if (siteInfo == null)
|
||||||
{
|
{
|
||||||
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
|
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -48,6 +48,11 @@ public class UserFeedRetrieverWebScript extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
private static final Log logger = LogFactory.getLog(UserFeedRetrieverWebScript.class);
|
private static final Log logger = LogFactory.getLog(UserFeedRetrieverWebScript.class);
|
||||||
|
|
||||||
|
// URL request parameter names
|
||||||
|
public static final String PARAM_SITE_ID = "s";
|
||||||
|
public static final String PARAM_EXCLUDE_THIS_USER = "exclUser";
|
||||||
|
public static final String PARAM_EXCLUDE_OTHER_USERS = "exclOthers";
|
||||||
|
|
||||||
private ActivityService activityService;
|
private ActivityService activityService;
|
||||||
private AuthorityService authorityService;
|
private AuthorityService authorityService;
|
||||||
|
|
||||||
@@ -90,7 +95,21 @@ public class UserFeedRetrieverWebScript extends DeclarativeWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process arguments
|
// process arguments
|
||||||
String siteId = req.getParameter("s"); // optional
|
String siteId = req.getParameter(PARAM_SITE_ID); // optional
|
||||||
|
String exclThisUserStr = req.getParameter(PARAM_EXCLUDE_THIS_USER); // optional
|
||||||
|
String exclOtherUsersStr = req.getParameter(PARAM_EXCLUDE_OTHER_USERS); // optional
|
||||||
|
|
||||||
|
boolean exclThisUser = false;
|
||||||
|
if ((exclThisUserStr != null) && (exclThisUserStr.equalsIgnoreCase("true") || exclThisUserStr.equalsIgnoreCase("t")))
|
||||||
|
{
|
||||||
|
exclThisUser = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean exclOtherUsers = false;
|
||||||
|
if ((exclOtherUsersStr != null) && (exclOtherUsersStr.equalsIgnoreCase("true") || exclOtherUsersStr.equalsIgnoreCase("t")))
|
||||||
|
{
|
||||||
|
exclOtherUsers = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ((feedUserId == null) || (feedUserId.length() == 0))
|
if ((feedUserId == null) || (feedUserId.length() == 0))
|
||||||
{
|
{
|
||||||
@@ -118,7 +137,7 @@ public class UserFeedRetrieverWebScript extends DeclarativeWebScript
|
|||||||
|
|
||||||
Map<String, Object> model = new HashMap<String, Object>();
|
Map<String, Object> model = new HashMap<String, Object>();
|
||||||
|
|
||||||
List<String> feedEntries = activityService.getUserFeedEntries(feedUserId, format, siteId);
|
List<String> feedEntries = activityService.getUserFeedEntries(feedUserId, format, siteId, exclThisUser, exclOtherUsers);
|
||||||
|
|
||||||
if (format.equals("json"))
|
if (format.equals("json"))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user