summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2013-08-09 01:32:22 (EDT)
committerStephan Born2013-09-23 04:59:16 (EDT)
commit741ba0e15430061742b64e364ed85b19a8345990 (patch)
tree22c521f46f239f06b342f36293bc6e9319e31e3f
parentc7d8b02b15cde0067227ac105240c2d9636eb573 (diff)
downloadorg.eclipse.stardust.ui.web-741ba0e15430061742b64e364ed85b19a8345990.zip
org.eclipse.stardust.ui.web-741ba0e15430061742b64e364ed85b19a8345990.tar.gz
org.eclipse.stardust.ui.web-741ba0e15430061742b64e364ed85b19a8345990.tar.bz2
Jira-ID: CRNT-29875
Added method to retrieve display preference for user. git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ui.web@66580 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Sidharth Singh <sidharth.singh@sungard.com>
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/MyPicturePreferenceUtils.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/MyPicturePreferenceUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/MyPicturePreferenceUtils.java
index e5f6426..bf6edf9 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/MyPicturePreferenceUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/MyPicturePreferenceUtils.java
@@ -11,12 +11,16 @@
package org.eclipse.stardust.ui.web.viewscommon.utils;
import java.net.URL;
+import java.util.List;
import org.eclipse.stardust.common.StringUtils;
+import org.eclipse.stardust.engine.api.query.PreferenceQuery;
import org.eclipse.stardust.engine.api.runtime.DmsUtils;
import org.eclipse.stardust.engine.api.runtime.Document;
import org.eclipse.stardust.engine.api.runtime.DocumentManagementService;
+import org.eclipse.stardust.engine.api.runtime.QueryService;
import org.eclipse.stardust.engine.api.runtime.User;
+import org.eclipse.stardust.engine.core.preferences.Preferences;
import org.eclipse.stardust.engine.core.repository.DocumentRepositoryFolderNames;
import org.eclipse.stardust.engine.core.repository.DocumentRepositoryUtils;
import org.eclipse.stardust.ui.web.common.configuration.UserPreferencesHelper;
@@ -128,12 +132,25 @@ public class MyPicturePreferenceUtils
if (user != null)
{
- String picturePreference = (String) user.getAttribute(getPreferencesId(UserPreferencesEntries.F_MY_PICTURE_TYPE));
+ String picturePreference = (String) user
+ .getAttribute(getPreferencesId(UserPreferencesEntries.F_MY_PICTURE_TYPE));
+ if (null == picturePreference)
+ {
+ if (UserUtils.isLoggedInUser(user))
+ {
+ picturePreference = getLoggedInUsersImagePreference();
+ }
+ else
+ {
+ picturePreference = getPicturePreferenceForUser(user);
+ }
+ }
if (F_MY_PICTURE_TYPE_HTTP_URL.equals(picturePreference)
|| F_MY_PICTURE_TYPE_MONSTER_ID.equals(picturePreference))
{
- String prefURLStr = (String) user.getAttribute(getPreferencesId(UserPreferencesEntries.F_MY_PICTURE_HTTP_URL));
+ String prefURLStr = (String) user
+ .getAttribute(getPreferencesId(UserPreferencesEntries.F_MY_PICTURE_HTTP_URL));
if (StringUtils.isNotEmpty(prefURLStr))
{
imageURI = prefURLStr;
@@ -153,6 +170,18 @@ public class MyPicturePreferenceUtils
return imageURI;
}
+ public static String getPicturePreferenceForUser(final User user)
+ {
+ String picturePreference = null;
+ QueryService queryService = SessionContext.findSessionContext().getServiceFactory().getQueryService();
+ List<Preferences> prefs = queryService.getAllPreferences(PreferenceQuery.findPreferencesForUsers(user
+ .getRealm().getId(), user.getId(), UserPreferencesEntries.M_VIEWS_COMMON, REFERENCE_ID));
+ for (Preferences userPref : prefs)
+ {
+ picturePreference = (String) userPref.getPreferences().get(getPreferencesId(UserPreferencesEntries.F_MY_PICTURE_TYPE));
+ }
+ return picturePreference;
+ }
/**
* Utility method to get the profile image's JCR folder path.
*