ALFCOM-3083 Failure to 'post activity' when a Group is added as a Site member

- implemented "activities" for Web Site, group add, remove and update.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15016 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2009-06-29 16:17:11 +00:00
parent b5d4daa46a
commit ab81f0f310
3 changed files with 55 additions and 27 deletions

View File

@@ -1291,13 +1291,13 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
activityService.postActivity(
ActivityType.SITE_USER_REMOVED, shortName,
ACTIVITY_TOOL, getActivityData(authorityName, ""));
ACTIVITY_TOOL, getActivityUserData(authorityName, ""));
}
else
{
// TODO - update this, if sites support groups
logger.error("setMembership - failed to post activity: unexpected authority type: "
+ AuthorityType.getAuthorityType(authorityName));
activityService.postActivity(
ActivityType.SITE_GROUP_REMOVED, shortName,
ACTIVITY_TOOL, getActivityUserData(authorityName, ""));
}
}
else
@@ -1394,14 +1394,13 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
activityService.postActivity(
ActivityType.SITE_USER_JOINED, shortName,
ACTIVITY_TOOL, getActivityData(authorityName, role));
ACTIVITY_TOOL, getActivityUserData(authorityName, role));
}
else
{
// TODO - update this, if sites support groups
logger
.error("setMembership - failed to post activity: unexpected authority type: "
+ AuthorityType.getAuthorityType(authorityName));
activityService.postActivity(
ActivityType.SITE_GROUP_ADDED, shortName,
ACTIVITY_TOOL, getActivityGroupData(authorityName, role));
}
}
else
@@ -1410,13 +1409,13 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
activityService.postActivity(
ActivityType.SITE_USER_ROLE_UPDATE, shortName,
ACTIVITY_TOOL, getActivityData(authorityName, role));
ACTIVITY_TOOL, getActivityUserData(authorityName, role));
}
else
{
// TODO - update this, if sites support groups
logger.error("setMembership - failed to post activity: unexpected authority type: "
+ AuthorityType.getAuthorityType(authorityName));
activityService.postActivity(
ActivityType.SITE_GROUP_ROLE_UPDATE, shortName,
ACTIVITY_TOOL, getActivityUserData(authorityName, role));
}
}
}
@@ -1584,7 +1583,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
* @param role role
* @return
*/
private String getActivityData(String userName, String role)
private String getActivityUserData(String userName, String role)
{
String memberFN = "";
String memberLN = "";
@@ -1615,6 +1614,32 @@ public class SiteServiceImpl implements SiteService, SiteModel
}
}
/**
* Helper method to get the activity data for a group
*
* @param groupName user name
* @param role role
* @return Activity data in JSON format
*/
private String getActivityGroupData(String groupName, String role)
{
try
{
JSONObject activityData = new JSONObject();
activityData.put("role", role);
activityData.put("groupName", groupName);
return activityData.toString();
}
catch (JSONException je)
{
// log error, subsume exception
logger.error("Failed to get activity data: " + je);
return "";
}
}
public void setRoleComparator(Comparator<String> roleComparator) {
this.roleComparator = roleComparator;
}