mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Activity Service - fix JSON feed
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9156 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,7 +28,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.activities.feed.ActivityFeedDAO;
|
import org.alfresco.repo.activities.feed.ActivityFeedDAO;
|
||||||
@@ -44,7 +43,6 @@ import org.alfresco.service.cmr.activities.FeedControl;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.JSONtoFmModel;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -221,7 +219,7 @@ public class ActivityServiceImpl implements ActivityService
|
|||||||
}
|
}
|
||||||
else if ((! currentUser.equals(AuthenticationUtil.SYSTEM_USER_NAME)) && (! userNamesAreCaseSensitive))
|
else if ((! currentUser.equals(AuthenticationUtil.SYSTEM_USER_NAME)) && (! userNamesAreCaseSensitive))
|
||||||
{
|
{
|
||||||
// user names are case-insensitive
|
// user names are not case-sensitive
|
||||||
currentUser = currentUser.toLowerCase();
|
currentUser = currentUser.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -277,22 +275,23 @@ public class ActivityServiceImpl implements ActivityService
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.activities.ActivityService#getUserFeedEntries(java.lang.String, java.lang.String, java.lang.String)
|
* @see org.alfresco.service.cmr.activities.ActivityService#getUserFeedEntries(java.lang.String, java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> getUserFeedEntries(String feedUserId, String format, String siteId)
|
public List<String> getUserFeedEntries(String feedUserId, String format, String siteId)
|
||||||
{
|
{
|
||||||
// NOTE: siteId is optional
|
// NOTE: siteId is optional
|
||||||
ParameterCheck.mandatoryString("feedUserId", feedUserId);
|
ParameterCheck.mandatoryString("feedUserId", feedUserId);
|
||||||
ParameterCheck.mandatoryString("format", format);
|
ParameterCheck.mandatoryString("format", format);
|
||||||
|
|
||||||
List<Map<String, Object>> activityFeedModels = new ArrayList<Map<String, Object>>();
|
List<String> activityFeedEntries = new ArrayList<String>();
|
||||||
|
|
||||||
if (! userNamesAreCaseSensitive)
|
|
||||||
{
|
|
||||||
feedUserId = feedUserId.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
String currentUser = AuthenticationUtil.getCurrentUserName();
|
String currentUser = AuthenticationUtil.getCurrentUserName();
|
||||||
if (currentUser != null)
|
if (currentUser != null)
|
||||||
{
|
{
|
||||||
|
if (! userNamesAreCaseSensitive)
|
||||||
|
{
|
||||||
|
feedUserId = feedUserId.toLowerCase();
|
||||||
|
currentUser = currentUser.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
if ((! authorityService.isAdminAuthority(currentUser)) && (! currentUser.equals(feedUserId)))
|
if ((! authorityService.isAdminAuthority(currentUser)) && (! currentUser.equals(feedUserId)))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unable to get feed entries for '" + feedUserId + "' - currently logged in as '" + currentUser +"'");
|
throw new AlfrescoRuntimeException("Unable to get feed entries for '" + feedUserId + "' - currently logged in as '" + currentUser +"'");
|
||||||
@@ -318,7 +317,7 @@ public class ActivityServiceImpl implements ActivityService
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
activityFeedModels.add(JSONtoFmModel.convertJSONObjectToMap(activityFeed.getJSONString()));
|
activityFeedEntries.add(activityFeed.getJSONString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException se)
|
catch (SQLException se)
|
||||||
@@ -335,18 +334,18 @@ public class ActivityServiceImpl implements ActivityService
|
|||||||
throw new AlfrescoRuntimeException("Unable to get user feed entries - current user is null");
|
throw new AlfrescoRuntimeException("Unable to get user feed entries - current user is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return activityFeedModels;
|
return activityFeedEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.activities.ActivityService#getSiteFeedEntries(java.lang.String, java.lang.String)
|
* @see org.alfresco.service.cmr.activities.ActivityService#getSiteFeedEntries(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> getSiteFeedEntries(String siteId, String format)
|
public List<String> getSiteFeedEntries(String siteId, String format)
|
||||||
{
|
{
|
||||||
ParameterCheck.mandatoryString("siteId", siteId);
|
ParameterCheck.mandatoryString("siteId", siteId);
|
||||||
ParameterCheck.mandatoryString("format", format);
|
ParameterCheck.mandatoryString("format", format);
|
||||||
|
|
||||||
List<Map<String, Object>> activityFeedModels = new ArrayList<Map<String, Object>>();
|
List<String> activityFeedEntries = new ArrayList<String>();
|
||||||
|
|
||||||
String currentUser = AuthenticationUtil.getCurrentUserName();
|
String currentUser = AuthenticationUtil.getCurrentUserName();
|
||||||
if (currentUser != null)
|
if (currentUser != null)
|
||||||
@@ -364,7 +363,7 @@ public class ActivityServiceImpl implements ActivityService
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
activityFeedModels.add(JSONtoFmModel.convertJSONObjectToMap(activityFeed.getJSONString()));
|
activityFeedEntries.add(activityFeed.getJSONString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException se)
|
catch (SQLException se)
|
||||||
@@ -381,7 +380,7 @@ public class ActivityServiceImpl implements ActivityService
|
|||||||
throw new AlfrescoRuntimeException("Unable to get site feed entries - current user is null");
|
throw new AlfrescoRuntimeException("Unable to get site feed entries - current user is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return activityFeedModels;
|
return activityFeedEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -26,7 +26,6 @@ package org.alfresco.repo.activities;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.repo.jscript.ClasspathScriptLocation;
|
import org.alfresco.repo.jscript.ClasspathScriptLocation;
|
||||||
import org.alfresco.service.cmr.activities.ActivityService;
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
@@ -113,7 +112,7 @@ public class ActivityServiceImplTest extends BaseSpringTest
|
|||||||
}
|
}
|
||||||
authenticationService.authenticate(USER_UN, USER_PW.toCharArray());
|
authenticationService.authenticate(USER_UN, USER_PW.toCharArray());
|
||||||
|
|
||||||
List<Map<String, Object>> siteFeedEntries = this.activityService.getSiteFeedEntries("unknown site", "some format");
|
List<String> siteFeedEntries = this.activityService.getSiteFeedEntries("unknown site", "some format");
|
||||||
|
|
||||||
assertNotNull(siteFeedEntries);
|
assertNotNull(siteFeedEntries);
|
||||||
assertTrue(siteFeedEntries.isEmpty());
|
assertTrue(siteFeedEntries.isEmpty());
|
||||||
@@ -121,8 +120,7 @@ public class ActivityServiceImplTest extends BaseSpringTest
|
|||||||
|
|
||||||
public void testGetEmptyUserFeed() throws Exception
|
public void testGetEmptyUserFeed() throws Exception
|
||||||
{
|
{
|
||||||
|
List<String> userFeedEntries = this.activityService.getUserFeedEntries("unknown user", "some format", null);
|
||||||
List<Map<String, Object>> userFeedEntries = this.activityService.getUserFeedEntries("unknown user", "some format", null);
|
|
||||||
|
|
||||||
assertNotNull(userFeedEntries);
|
assertNotNull(userFeedEntries);
|
||||||
assertTrue(userFeedEntries.isEmpty());
|
assertTrue(userFeedEntries.isEmpty());
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
package org.alfresco.service.cmr.activities;
|
package org.alfresco.service.cmr.activities;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -98,16 +97,18 @@ public interface ActivityService
|
|||||||
* @param userId - required
|
* @param userId - required
|
||||||
* @param format - required
|
* @param format - required
|
||||||
* @param siteId - optional, if set then will filter by given siteId else return all sites
|
* @param siteId - optional, if set then will filter by given siteId else return all sites
|
||||||
|
* @return list of JSON feed entries
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> getUserFeedEntries(String userId, String format, String siteId);
|
public List<String> getUserFeedEntries(String userId, String format, String siteId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve site feed
|
* Retrieve site feed
|
||||||
*
|
*
|
||||||
* @param activityType - required
|
* @param activityType - required
|
||||||
* @param format - required
|
* @param format - required
|
||||||
|
* @return list of JSON feed entries
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> getSiteFeedEntries(String siteId, String format);
|
public List<String> getSiteFeedEntries(String siteId, String format);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user