Merged V3.2 to HEAD

17542: Fix ETHREEOH-3390 - "Could not load activities list" - for usernames with upper-case characters


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17549 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-11-18 14:29:07 +00:00
parent f351590801
commit 512e7c8cb5
2 changed files with 44 additions and 27 deletions

View File

@@ -139,7 +139,7 @@ public class ActivityPostServiceImpl implements ActivityPostService
private void postActivity(String activityType, String siteId, String appTool, String activityData, ActivityPostEntity.STATUS status) private void postActivity(String activityType, String siteId, String appTool, String activityData, ActivityPostEntity.STATUS status)
{ {
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); String currentUser = getCurrentUser();
try try
{ {
@@ -188,11 +188,6 @@ public class ActivityPostServiceImpl implements ActivityPostService
{ {
throw new AlfrescoRuntimeException("Invalid user - exceeds " + MAX_LEN_USER_ID + " chars: " + currentUser); throw new AlfrescoRuntimeException("Invalid user - exceeds " + MAX_LEN_USER_ID + " chars: " + currentUser);
} }
else if ((! currentUser.equals(AuthenticationUtil.SYSTEM_USER_NAME)) && (! userNamesAreCaseSensitive))
{
// user names are not case-sensitive
currentUser = currentUser.toLowerCase();
}
} }
catch (AlfrescoRuntimeException e) catch (AlfrescoRuntimeException e)
{ {
@@ -248,4 +243,16 @@ public class ActivityPostServiceImpl implements ActivityPostService
logger.error(e); logger.error(e);
} }
} }
private String getCurrentUser()
{
String userId = AuthenticationUtil.getFullyAuthenticatedUser();
if ((userId != null) && (! userId.equals(AuthenticationUtil.SYSTEM_USER_NAME)) && (! userNamesAreCaseSensitive))
{
// user names are not case-sensitive
userId = userId.toLowerCase();
}
return userId;
}
} }

View File

@@ -170,7 +170,7 @@ public class ActivityServiceImpl implements ActivityService
feedUserId = feedUserId.toLowerCase(); feedUserId = feedUserId.toLowerCase();
} }
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); String currentUser = getCurrentUser();
if (! ((currentUser == null) || if (! ((currentUser == null) ||
(currentUser.equals(AuthenticationUtil.getSystemUserName())) || (currentUser.equals(AuthenticationUtil.getSystemUserName())) ||
(authorityService.isAdminAuthority(currentUser)) || (authorityService.isAdminAuthority(currentUser)) ||
@@ -279,10 +279,11 @@ public class ActivityServiceImpl implements ActivityService
{ {
ParameterCheck.mandatory("feedControl", feedControl); ParameterCheck.mandatory("feedControl", feedControl);
String userId = AuthenticationUtil.getFullyAuthenticatedUser(); String userId = getCurrentUser();
if (! userNamesAreCaseSensitive)
if (userId == null)
{ {
userId = userId.toLowerCase(); throw new AlfrescoRuntimeException("Current user " + userId + " is not permitted to set feed control");
} }
try try
@@ -305,7 +306,7 @@ public class ActivityServiceImpl implements ActivityService
*/ */
public List<FeedControl> getFeedControls() public List<FeedControl> getFeedControls()
{ {
String userId = AuthenticationUtil.getFullyAuthenticatedUser(); String userId = getCurrentUser();
return getFeedControlsImpl(userId); return getFeedControlsImpl(userId);
} }
@@ -315,7 +316,13 @@ public class ActivityServiceImpl implements ActivityService
public List<FeedControl> getFeedControls(String userId) public List<FeedControl> getFeedControls(String userId)
{ {
ParameterCheck.mandatoryString("userId", userId); ParameterCheck.mandatoryString("userId", userId);
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
if (! userNamesAreCaseSensitive)
{
userId = userId.toLowerCase();
}
String currentUser = getCurrentUser();
if ((currentUser == null) || ((! currentUser.equals(AuthenticationUtil.getSystemUserName())) && (! currentUser.equals(userId)) && (! authorityService.isAdminAuthority(currentUser)))) if ((currentUser == null) || ((! currentUser.equals(AuthenticationUtil.getSystemUserName())) && (! currentUser.equals(userId)) && (! authorityService.isAdminAuthority(currentUser))))
{ {
@@ -329,11 +336,6 @@ public class ActivityServiceImpl implements ActivityService
{ {
ParameterCheck.mandatoryString("userId", userId); ParameterCheck.mandatoryString("userId", userId);
if (! userNamesAreCaseSensitive)
{
userId = userId.toLowerCase();
}
try try
{ {
List<FeedControlEntity> feedControlDaos = feedControlDAO.selectFeedControls(userId); List<FeedControlEntity> feedControlDaos = feedControlDAO.selectFeedControls(userId);
@@ -360,10 +362,11 @@ public class ActivityServiceImpl implements ActivityService
{ {
ParameterCheck.mandatory("feedControl", feedControl); ParameterCheck.mandatory("feedControl", feedControl);
String userId = AuthenticationUtil.getFullyAuthenticatedUser(); String userId = getCurrentUser();
if (! userNamesAreCaseSensitive)
if (userId == null)
{ {
userId = userId.toLowerCase(); throw new AlfrescoRuntimeException("Current user " + userId + " is not permitted to unset feed control");
} }
try try
@@ -385,12 +388,7 @@ public class ActivityServiceImpl implements ActivityService
{ {
ParameterCheck.mandatory("feedControl", feedControl); ParameterCheck.mandatory("feedControl", feedControl);
String userId = AuthenticationUtil.getFullyAuthenticatedUser(); String userId = getCurrentUser();
if (! userNamesAreCaseSensitive)
{
userId = userId.toLowerCase();
}
try try
{ {
@@ -405,6 +403,18 @@ public class ActivityServiceImpl implements ActivityService
} }
} }
private String getCurrentUser()
{
String userId = AuthenticationUtil.getFullyAuthenticatedUser();
if ((userId != null) && (! userId.equals(AuthenticationUtil.SYSTEM_USER_NAME)) && (! userNamesAreCaseSensitive))
{
// user names are not case-sensitive
userId = userId.toLowerCase();
}
return userId;
}
private FeedControl getTenantFeedControl(FeedControl feedControl) private FeedControl getTenantFeedControl(FeedControl feedControl)
{ {
// TODO // TODO