From 512e7c8cb5866032df7f39a4babae3d7d34af1f4 Mon Sep 17 00:00:00 2001 From: Jan Vonka Date: Wed, 18 Nov 2009 14:29:07 +0000 Subject: [PATCH] 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 --- .../activities/ActivityPostServiceImpl.java | 19 ++++--- .../repo/activities/ActivityServiceImpl.java | 52 +++++++++++-------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/source/java/org/alfresco/repo/activities/ActivityPostServiceImpl.java b/source/java/org/alfresco/repo/activities/ActivityPostServiceImpl.java index 0d61ed6d23..12004cedeb 100644 --- a/source/java/org/alfresco/repo/activities/ActivityPostServiceImpl.java +++ b/source/java/org/alfresco/repo/activities/ActivityPostServiceImpl.java @@ -139,7 +139,7 @@ public class ActivityPostServiceImpl implements ActivityPostService private void postActivity(String activityType, String siteId, String appTool, String activityData, ActivityPostEntity.STATUS status) { - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); + String currentUser = getCurrentUser(); try { @@ -188,11 +188,6 @@ public class ActivityPostServiceImpl implements ActivityPostService { 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) { @@ -248,4 +243,16 @@ public class ActivityPostServiceImpl implements ActivityPostService 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; + } } diff --git a/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java b/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java index ea95646c6e..c8eaa420a6 100644 --- a/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java +++ b/source/java/org/alfresco/repo/activities/ActivityServiceImpl.java @@ -170,7 +170,7 @@ public class ActivityServiceImpl implements ActivityService feedUserId = feedUserId.toLowerCase(); } - String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); + String currentUser = getCurrentUser(); if (! ((currentUser == null) || (currentUser.equals(AuthenticationUtil.getSystemUserName())) || (authorityService.isAdminAuthority(currentUser)) || @@ -279,12 +279,13 @@ public class ActivityServiceImpl implements ActivityService { ParameterCheck.mandatory("feedControl", feedControl); - String userId = AuthenticationUtil.getFullyAuthenticatedUser(); - if (! userNamesAreCaseSensitive) + String userId = getCurrentUser(); + + if (userId == null) { - userId = userId.toLowerCase(); + throw new AlfrescoRuntimeException("Current user " + userId + " is not permitted to set feed control"); } - + try { if (! existsFeedControl(feedControl)) @@ -305,7 +306,7 @@ public class ActivityServiceImpl implements ActivityService */ public List getFeedControls() { - String userId = AuthenticationUtil.getFullyAuthenticatedUser(); + String userId = getCurrentUser(); return getFeedControlsImpl(userId); } @@ -315,7 +316,13 @@ public class ActivityServiceImpl implements ActivityService public List getFeedControls(String 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)))) { @@ -329,11 +336,6 @@ public class ActivityServiceImpl implements ActivityService { ParameterCheck.mandatoryString("userId", userId); - if (! userNamesAreCaseSensitive) - { - userId = userId.toLowerCase(); - } - try { List feedControlDaos = feedControlDAO.selectFeedControls(userId); @@ -360,10 +362,11 @@ public class ActivityServiceImpl implements ActivityService { ParameterCheck.mandatory("feedControl", feedControl); - String userId = AuthenticationUtil.getFullyAuthenticatedUser(); - if (! userNamesAreCaseSensitive) + String userId = getCurrentUser(); + + if (userId == null) { - userId = userId.toLowerCase(); + throw new AlfrescoRuntimeException("Current user " + userId + " is not permitted to unset feed control"); } try @@ -385,12 +388,7 @@ public class ActivityServiceImpl implements ActivityService { ParameterCheck.mandatory("feedControl", feedControl); - String userId = AuthenticationUtil.getFullyAuthenticatedUser(); - - if (! userNamesAreCaseSensitive) - { - userId = userId.toLowerCase(); - } + String userId = getCurrentUser(); 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) { // TODO