mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Made following messages human readable
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28524 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -8,22 +8,23 @@
|
|||||||
<value>org.alfresco.service.cmr.subscriptions.SubscriptionService</value>
|
<value>org.alfresco.service.cmr.subscriptions.SubscriptionService</value>
|
||||||
</property>
|
</property>
|
||||||
<property name="target">
|
<property name="target">
|
||||||
<ref bean="subscriptionService"/>
|
<ref bean="subscriptionService" />
|
||||||
</property>
|
</property>
|
||||||
<property name="interceptorNames">
|
<property name="interceptorNames">
|
||||||
<list>
|
<list>
|
||||||
<idref bean="AuditMethodInterceptor"/>
|
<idref bean="AuditMethodInterceptor" />
|
||||||
<idref bean="exceptionTranslator"/>
|
<idref bean="exceptionTranslator" />
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Subscription implementation bean -->
|
<!-- Subscription implementation bean -->
|
||||||
<bean id="subscriptionService" class="org.alfresco.repo.subscriptions.SubscriptionServiceImpl" >
|
<bean id="subscriptionService" class="org.alfresco.repo.subscriptions.SubscriptionServiceImpl">
|
||||||
<property name="subscriptionsDAO" ref="subscriptionsDAO" />
|
<property name="subscriptionsDAO" ref="subscriptionsDAO" />
|
||||||
<property name="nodeService" ref="nodeService" />
|
<property name="nodeService" ref="NodeService" />
|
||||||
<property name="personService" ref="personService" />
|
<property name="personService" ref="PersonService" />
|
||||||
<property name="activityService" ref="activityService" />
|
<property name="activityService" ref="activityService" />
|
||||||
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -451,7 +451,7 @@ public class LocalFeedTaskProcessor extends FeedTaskProcessor implements Applica
|
|||||||
{
|
{
|
||||||
Set<String> result = new HashSet<String>();
|
Set<String> result = new HashSet<String>();
|
||||||
|
|
||||||
if (!subscriptionService.isSubscriptionListPrivate(userId))
|
if (subscriptionService.subscriptionsEnabled())
|
||||||
{
|
{
|
||||||
PagingFollowingResults fr = subscriptionService.getFollowers(userId, new PagingRequest(1000000, null));
|
PagingFollowingResults fr = subscriptionService.getFollowers(userId, new PagingRequest(1000000, null));
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@ 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.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.subscriptions.PagingFollowingResults;
|
import org.alfresco.service.cmr.subscriptions.PagingFollowingResults;
|
||||||
import org.alfresco.service.cmr.subscriptions.PagingSubscriptionResults;
|
import org.alfresco.service.cmr.subscriptions.PagingSubscriptionResults;
|
||||||
@@ -50,14 +51,23 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
private static final String ACTIVITY_TOOL = "subscriptionService";
|
private static final String ACTIVITY_TOOL = "subscriptionService";
|
||||||
|
|
||||||
/** Activity values */
|
/** Activity values */
|
||||||
private static final String SUB_USER = "user";
|
private static final String FOLLOWER_FIRSTNAME = "followerFirstName";
|
||||||
private static final String SUB_USER_TO_FOLLOW = "userToFollow";
|
private static final String FOLLOWER_LASTNAME = "followerLastName";
|
||||||
private static final String SUB_NODE = "node";
|
private static final String FOLLOWER_USERNAME = "followerUserName";
|
||||||
|
private static final String USER_FIRSTNAME = "userFirstName";
|
||||||
|
private static final String USER_LASTNAME = "userLastName";
|
||||||
|
private static final String USER_USERNAME = "userUserName";
|
||||||
|
|
||||||
|
private static final String SUBSCRIBER_FIRSTNAME = "subscriberFirstName";
|
||||||
|
private static final String SUBSCRIBER_LASTNAME = "subscriberLastName";
|
||||||
|
private static final String SUBSCRIBER_USERNAME = "subscriberUserName";
|
||||||
|
private static final String NODE = "node";
|
||||||
|
|
||||||
protected SubscriptionsDAO subscriptionsDAO;
|
protected SubscriptionsDAO subscriptionsDAO;
|
||||||
protected NodeService nodeService;
|
protected NodeService nodeService;
|
||||||
protected PersonService personService;
|
protected PersonService personService;
|
||||||
protected ActivityService activityService;
|
protected ActivityService activityService;
|
||||||
|
protected AuthorityService authorityService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the subscriptions DAO.
|
* Sets the subscriptions DAO.
|
||||||
@@ -91,12 +101,20 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
this.activityService = activictyService;
|
this.activityService = activictyService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the authority service.
|
||||||
|
*/
|
||||||
|
public final void setAuthorityService(AuthorityService authorityService)
|
||||||
|
{
|
||||||
|
this.authorityService = authorityService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PagingSubscriptionResults getSubscriptions(String userId, SubscriptionItemTypeEnum type,
|
public PagingSubscriptionResults getSubscriptions(String userId, SubscriptionItemTypeEnum type,
|
||||||
PagingRequest pagingRequest)
|
PagingRequest pagingRequest)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, true);
|
||||||
return subscriptionsDAO.selectSubscriptions(userId, type, pagingRequest);
|
return subscriptionsDAO.selectSubscriptions(userId, type, pagingRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +122,7 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
public int getSubscriptionCount(String userId, SubscriptionItemTypeEnum type)
|
public int getSubscriptionCount(String userId, SubscriptionItemTypeEnum type)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, true);
|
||||||
return subscriptionsDAO.countSubscriptions(userId, type);
|
return subscriptionsDAO.countSubscriptions(userId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +139,14 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
String activityDataJSON = null;
|
String activityDataJSON = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
NodeRef subscriberNode = personService.getPerson(userId, false);
|
||||||
JSONObject activityData = new JSONObject();
|
JSONObject activityData = new JSONObject();
|
||||||
activityData.put(SUB_USER, userId);
|
activityData.put(SUBSCRIBER_USERNAME, userId);
|
||||||
activityData.put(SUB_NODE, node.toString());
|
activityData.put(SUBSCRIBER_FIRSTNAME,
|
||||||
|
nodeService.getProperty(subscriberNode, ContentModel.PROP_FIRSTNAME));
|
||||||
|
activityData.put(SUBSCRIBER_LASTNAME,
|
||||||
|
nodeService.getProperty(subscriberNode, ContentModel.PROP_LASTNAME));
|
||||||
|
activityData.put(NODE, node.toString());
|
||||||
activityDataJSON = activityData.toString();
|
activityDataJSON = activityData.toString();
|
||||||
} catch (JSONException je)
|
} catch (JSONException je)
|
||||||
{
|
{
|
||||||
@@ -147,7 +170,7 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
public boolean hasSubscribed(String userId, NodeRef node)
|
public boolean hasSubscribed(String userId, NodeRef node)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, true);
|
||||||
return subscriptionsDAO.hasSubscribed(userId, node);
|
return subscriptionsDAO.hasSubscribed(userId, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,15 +178,23 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
public PagingFollowingResults getFollowing(String userId, PagingRequest pagingRequest)
|
public PagingFollowingResults getFollowing(String userId, PagingRequest pagingRequest)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, true);
|
||||||
return subscriptionsDAO.selectFollowing(userId, pagingRequest);
|
return subscriptionsDAO.selectFollowing(userId, pagingRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFollowingCount(String userId)
|
||||||
|
{
|
||||||
|
checkEnabled();
|
||||||
|
checkRead(userId, true);
|
||||||
|
return getSubscriptionCount(userId, SubscriptionItemTypeEnum.USER);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PagingFollowingResults getFollowers(String userId, PagingRequest pagingRequest)
|
public PagingFollowingResults getFollowers(String userId, PagingRequest pagingRequest)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, false);
|
||||||
return subscriptionsDAO.selectFollowers(userId, pagingRequest);
|
return subscriptionsDAO.selectFollowers(userId, pagingRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,18 +202,10 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
public int getFollowersCount(String userId)
|
public int getFollowersCount(String userId)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, false);
|
||||||
return subscriptionsDAO.countFollowers(userId);
|
return subscriptionsDAO.countFollowers(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFollowingCount(String userId)
|
|
||||||
{
|
|
||||||
checkEnabled();
|
|
||||||
checkRead(userId);
|
|
||||||
return getSubscriptionCount(userId, SubscriptionItemTypeEnum.USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void follow(String userId, String userToFollow)
|
public void follow(String userId, String userToFollow)
|
||||||
{
|
{
|
||||||
@@ -195,9 +218,16 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
String activityDataJSON = null;
|
String activityDataJSON = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
NodeRef followerNode = personService.getPerson(userId, false);
|
||||||
|
NodeRef userNode = personService.getPerson(userToFollow, false);
|
||||||
JSONObject activityData = new JSONObject();
|
JSONObject activityData = new JSONObject();
|
||||||
activityData.put(SUB_USER, userId);
|
activityData.put(FOLLOWER_USERNAME, userId);
|
||||||
activityData.put(SUB_USER_TO_FOLLOW, userToFollow);
|
activityData
|
||||||
|
.put(FOLLOWER_FIRSTNAME, nodeService.getProperty(followerNode, ContentModel.PROP_FIRSTNAME));
|
||||||
|
activityData.put(FOLLOWER_LASTNAME, nodeService.getProperty(followerNode, ContentModel.PROP_LASTNAME));
|
||||||
|
activityData.put(USER_USERNAME, userToFollow);
|
||||||
|
activityData.put(USER_FIRSTNAME, nodeService.getProperty(userNode, ContentModel.PROP_FIRSTNAME));
|
||||||
|
activityData.put(USER_LASTNAME, nodeService.getProperty(userNode, ContentModel.PROP_LASTNAME));
|
||||||
activityDataJSON = activityData.toString();
|
activityDataJSON = activityData.toString();
|
||||||
} catch (JSONException je)
|
} catch (JSONException je)
|
||||||
{
|
{
|
||||||
@@ -221,7 +251,7 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
public boolean follows(String userId, String userToFollow)
|
public boolean follows(String userId, String userToFollow)
|
||||||
{
|
{
|
||||||
checkEnabled();
|
checkEnabled();
|
||||||
checkRead(userId);
|
checkRead(userId, true);
|
||||||
return subscriptionsDAO.hasSubscribed(userId, getUserNodeRef(userToFollow));
|
return subscriptionsDAO.hasSubscribed(userId, getUserNodeRef(userToFollow));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,20 +308,25 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
/**
|
/**
|
||||||
* Checks if the current user is allowed to get subscription data.
|
* Checks if the current user is allowed to get subscription data.
|
||||||
*/
|
*/
|
||||||
protected void checkRead(String userId)
|
protected void checkRead(String userId, boolean checkPrivate)
|
||||||
{
|
{
|
||||||
if (userId == null)
|
if (userId == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("User Id may not be null!");
|
throw new IllegalArgumentException("User Id may not be null!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!checkPrivate)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String currentUser = AuthenticationUtil.getRunAsUser();
|
String currentUser = AuthenticationUtil.getRunAsUser();
|
||||||
if (currentUser == null)
|
if (currentUser == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("No current user!");
|
throw new IllegalArgumentException("No current user!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUser.equalsIgnoreCase(userId) || currentUser.equalsIgnoreCase(AuthenticationUtil.getAdminUserName())
|
if (currentUser.equalsIgnoreCase(userId) || authorityService.isAdminAuthority(currentUser)
|
||||||
|| AuthenticationUtil.isRunAsUserTheSystemUser() || !isSubscriptionListPrivate(userId))
|
|| AuthenticationUtil.isRunAsUserTheSystemUser() || !isSubscriptionListPrivate(userId))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -316,7 +351,7 @@ public class SubscriptionServiceImpl implements SubscriptionService
|
|||||||
throw new IllegalArgumentException("No current user!");
|
throw new IllegalArgumentException("No current user!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUser.equalsIgnoreCase(userId) || currentUser.equalsIgnoreCase(AuthenticationUtil.getAdminUserName())
|
if (currentUser.equalsIgnoreCase(userId) || authorityService.isAdminAuthority(currentUser)
|
||||||
|| AuthenticationUtil.isRunAsUserTheSystemUser())
|
|| AuthenticationUtil.isRunAsUserTheSystemUser())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user