mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Activity Service - add REST API for User Feed Controls & general cleanup/fixes
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9187 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
cecd138ed6
commit
f0883f987f
@ -65,6 +65,7 @@
|
||||
<property name="postDaoService" ref="postDaoService"/>
|
||||
<property name="authenticationService" ref="AuthenticationService"/>
|
||||
<property name="repoEndPoint" value="${repo.remote.endpoint.url}"/>
|
||||
<property name="userNamesAreCaseSensitive" value="${user.name.caseSensitive}"/>
|
||||
<property name="maxItemsPerCycle" value="100"/>
|
||||
</bean>
|
||||
|
||||
|
@ -456,7 +456,7 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to set feed control: " + e, e);
|
||||
throw new AlfrescoRuntimeException("Failed to get feed controls: " + e, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ public class ActivityServiceImpl implements ActivityService
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to set feed control: " + e, e);
|
||||
throw new AlfrescoRuntimeException("Failed to unset feed control: " + e, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ public abstract class AbstractFeedGenerator implements FeedGenerator
|
||||
private AuthenticationService authenticationService;
|
||||
|
||||
private String repoEndPoint; // http://hostname:port/webapp (eg. http://localhost:8080/alfresco)
|
||||
|
||||
private boolean userNamesAreCaseSensitive = false;
|
||||
|
||||
private RepoCtx ctx = null;
|
||||
|
||||
@ -67,6 +69,11 @@ public abstract class AbstractFeedGenerator implements FeedGenerator
|
||||
this.repoEndPoint = repoEndPoint;
|
||||
}
|
||||
|
||||
public void setUserNamesAreCaseSensitive(boolean userNamesAreCaseSensitive)
|
||||
{
|
||||
this.userNamesAreCaseSensitive = userNamesAreCaseSensitive;
|
||||
}
|
||||
|
||||
public void setMaxItemsPerCycle(int maxItemsPerCycle)
|
||||
{
|
||||
this.maxItemsPerCycle = maxItemsPerCycle;
|
||||
@ -95,6 +102,7 @@ public abstract class AbstractFeedGenerator implements FeedGenerator
|
||||
public void init() throws Exception
|
||||
{
|
||||
ctx = new RepoCtx(repoEndPoint);
|
||||
ctx.setUserNamesAreCaseSensitive(userNamesAreCaseSensitive);
|
||||
|
||||
busy = false;
|
||||
}
|
||||
|
@ -408,6 +408,12 @@ public abstract class FeedTaskProcessor
|
||||
{
|
||||
JSONObject member = (JSONObject)ja.get(i);
|
||||
JSONObject person = (JSONObject)member.getJSONObject("person");
|
||||
|
||||
String userName = person.getString("userName");
|
||||
if (! ctx.isUserNamesAreCaseSensitive())
|
||||
{
|
||||
userName = userName.toLowerCase();
|
||||
}
|
||||
members.add(person.getString("userName"));
|
||||
}
|
||||
}
|
||||
@ -523,7 +529,7 @@ public abstract class FeedTaskProcessor
|
||||
|
||||
for (FeedControlDAO feedControl : feedControls)
|
||||
{
|
||||
if ((feedControl.getSiteNetwork() == null) && (feedControl.getAppTool() != null))
|
||||
if (((feedControl.getSiteNetwork() == null) || (feedControl.getSiteNetwork().length() == 0)) && (feedControl.getAppTool() != null))
|
||||
{
|
||||
if (feedControl.getAppTool().equals(activityPost.getAppTool()))
|
||||
{
|
||||
@ -531,7 +537,7 @@ public abstract class FeedTaskProcessor
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ((feedControl.getAppTool() == null) && (feedControl.getSiteNetwork() != null))
|
||||
else if (((feedControl.getAppTool() == null) || (feedControl.getAppTool().length() == 0)) && (feedControl.getSiteNetwork() != null))
|
||||
{
|
||||
if (feedControl.getSiteNetwork().equals(activityPost.getSiteNetwork()))
|
||||
{
|
||||
@ -539,7 +545,8 @@ public abstract class FeedTaskProcessor
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ((feedControl.getSiteNetwork() != null) && (feedControl.getAppTool() != null))
|
||||
else if (((feedControl.getSiteNetwork() != null) && (feedControl.getSiteNetwork().length() > 0)) &&
|
||||
((feedControl.getAppTool() != null) && (feedControl.getAppTool().length() > 0)))
|
||||
{
|
||||
if ((feedControl.getSiteNetwork().equals(activityPost.getSiteNetwork())) &&
|
||||
(feedControl.getAppTool().equals(activityPost.getAppTool())))
|
||||
|
@ -32,6 +32,8 @@ import java.io.Serializable;
|
||||
public class RepoCtx implements Serializable
|
||||
{
|
||||
private String repoEndPoint; // http://hostname:port/webapp (eg. http://localhost:8080/alfresco)
|
||||
private boolean userNamesAreCaseSensitive = false;
|
||||
|
||||
private String ticket;
|
||||
|
||||
public static final long serialVersionUID = -3896042917378679686L;
|
||||
@ -54,4 +56,14 @@ public class RepoCtx implements Serializable
|
||||
{
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public boolean isUserNamesAreCaseSensitive()
|
||||
{
|
||||
return userNamesAreCaseSensitive;
|
||||
}
|
||||
|
||||
public void setUserNamesAreCaseSensitive(boolean userNamesAreCaseSensitive)
|
||||
{
|
||||
this.userNamesAreCaseSensitive = userNamesAreCaseSensitive;
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,11 @@
|
||||
*/
|
||||
package org.alfresco.repo.activities.script;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
|
||||
import org.alfresco.service.cmr.activities.ActivityService;
|
||||
import org.alfresco.service.cmr.activities.FeedControl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
@ -46,6 +49,11 @@ public final class Activity extends BaseScopableProcessorExtension
|
||||
{
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Post Activity
|
||||
*/
|
||||
|
||||
/**
|
||||
* Post a custom activity type
|
||||
@ -108,4 +116,42 @@ public final class Activity extends BaseScopableProcessorExtension
|
||||
{
|
||||
activityService.postActivity(activityType, siteId, appTool, nodeRef, name, typeQName, parentNodeRef);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Manage User Feed Controls
|
||||
*/
|
||||
|
||||
/**
|
||||
* For current user, get feed controls
|
||||
*
|
||||
* @return array of user feed controls
|
||||
*/
|
||||
public FeedControl[] getFeedControls()
|
||||
{
|
||||
List<FeedControl> feedControls = activityService.getFeedControls();
|
||||
return (FeedControl[])feedControls.toArray(new FeedControl[feedControls.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* For current user, set feed control (opt-out) for a site or an appTool or a site/appTool combination
|
||||
*
|
||||
* @param siteId - required (optional, if appToolId is supplied)
|
||||
* @param appToolId - required (optional, if siteId is supplied)
|
||||
*/
|
||||
public void setFeedControl(String siteId, String appToolId)
|
||||
{
|
||||
activityService.setFeedControl(new FeedControl(siteId, appToolId));
|
||||
}
|
||||
|
||||
/**
|
||||
* For current user, unset feed control
|
||||
*
|
||||
* @param siteId - required (optional, if appToolId is supplied)
|
||||
* @param appToolId - required (optional, if siteId is supplied)
|
||||
*/
|
||||
public void unsetFeedControl(String siteId, String appToolId)
|
||||
{
|
||||
activityService.unsetFeedControl(new FeedControl(siteId, appToolId));
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,33 @@ activities.postActivity("test activity type 5", "my site", null, '{ "item2" : 45
|
||||
activities.postActivity("test activity type 6", "my site", "my app tool", '{ "item3" : 789 }');
|
||||
activities.postActivity("test activity type 7", "my site", "my app tool", '{ invalidJSON }');
|
||||
|
||||
// user feed controls
|
||||
var feedControls = activities.getFeedControls();
|
||||
test.assertEquals(0, feedControls.length);
|
||||
|
||||
activities.setFeedControl("my site", "my app tool");
|
||||
|
||||
feedControls = activities.getFeedControls();
|
||||
test.assertEquals(1, feedControls.length);
|
||||
|
||||
activities.setFeedControl("my site", null);
|
||||
|
||||
feedControls = activities.getFeedControls();
|
||||
test.assertEquals(2, feedControls.length);
|
||||
|
||||
activities.setFeedControl("", "my app tool");
|
||||
|
||||
feedControls = activities.getFeedControls();
|
||||
test.assertEquals(3, feedControls.length);
|
||||
|
||||
|
||||
activities.unsetFeedControl("my site", "my app tool");
|
||||
activities.unsetFeedControl("my site", "");
|
||||
activities.unsetFeedControl(null, "my app tool");
|
||||
|
||||
feedControls = activities.getFeedControls();
|
||||
test.assertEquals(0, feedControls.length);
|
||||
|
||||
|
||||
failure = "";
|
||||
|
||||
|
@ -116,7 +116,7 @@ public interface ActivityService
|
||||
*/
|
||||
|
||||
/**
|
||||
* For current user, set feed control (opt-out) for a site or an appTool or a site/appTool
|
||||
* For current user, set feed control (opt-out) for a site or an appTool or a site/appTool combination
|
||||
*
|
||||
* @param feedControl - required
|
||||
*/
|
||||
|
@ -24,11 +24,16 @@
|
||||
*/
|
||||
package org.alfresco.service.cmr.activities;
|
||||
|
||||
public class FeedControl
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FeedControl implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -1934566916718472843L;
|
||||
|
||||
private String siteId;
|
||||
private String appToolId;
|
||||
|
||||
|
||||
public FeedControl(String siteId, String appToolId)
|
||||
{
|
||||
if (siteId == null) siteId = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user