From 6583a37b9f61db18f30e4b7f494f9892e69cce61 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Mon, 14 Oct 2013 17:32:24 +0000 Subject: [PATCH] Merged V4.2-BUG-FIX (4.2.1) to HEAD (Cloud/4.3) 56634: Merged V4.2.0 (4.2) to V4.2-BUG-FIX (4.2.1) 56458: Fix for ALF-20277 - Impossible to login to Alfresco JSF client when alfresco is read only. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@56652 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../java/org/alfresco/web/bean/LoginBean.java | 2 +- .../alfresco/web/bean/repository/User.java | 4 +- .../web/bean/users/UserPreferencesBean.java | 40 +++++++++++++++++-- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/source/java/org/alfresco/web/bean/LoginBean.java b/source/java/org/alfresco/web/bean/LoginBean.java index fa6efb3c2b..98bf59f141 100644 --- a/source/java/org/alfresco/web/bean/LoginBean.java +++ b/source/java/org/alfresco/web/bean/LoginBean.java @@ -423,7 +423,7 @@ public class LoginBean implements Serializable // note: to enable MT runtime client config customization, need to re-init NavigationBean // in context of tenant login page this.navigator.initFromClientConfig(); - + if (NavigationBean.LOCATION_MYALFRESCO.equals(this.preferences.getStartLocation())) { return "myalfresco"; diff --git a/source/java/org/alfresco/web/bean/repository/User.java b/source/java/org/alfresco/web/bean/repository/User.java index fcdb9332be..685d2d87c2 100644 --- a/source/java/org/alfresco/web/bean/repository/User.java +++ b/source/java/org/alfresco/web/bean/repository/User.java @@ -203,7 +203,7 @@ public final class User implements SessionUser } return this.preferences; } - + /** * Get or create the node used to store user preferences. * Utilises the 'configurable' aspect on the Person linked to this user. @@ -267,7 +267,7 @@ public final class User implements SessionUser } return prefRef; } - }); + }, txService.isReadOnly()); } /** diff --git a/source/java/org/alfresco/web/bean/users/UserPreferencesBean.java b/source/java/org/alfresco/web/bean/users/UserPreferencesBean.java index 07eb7ee908..60faf7c403 100644 --- a/source/java/org/alfresco/web/bean/users/UserPreferencesBean.java +++ b/source/java/org/alfresco/web/bean/users/UserPreferencesBean.java @@ -26,9 +26,8 @@ import java.util.ResourceBundle; import javax.faces.context.FacesContext; import javax.faces.model.SelectItem; +import javax.transaction.UserTransaction; -import org.springframework.extensions.config.Config; -import org.springframework.extensions.surf.util.I18NUtil; import org.alfresco.service.cmr.ml.ContentFilterLanguagesService; import org.alfresco.service.cmr.ml.MultilingualContentService; import org.alfresco.service.cmr.repository.NodeRef; @@ -40,6 +39,8 @@ import org.alfresco.web.bean.NavigationBean; import org.alfresco.web.bean.repository.PreferencesService; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.config.LanguagesConfigElement; +import org.springframework.extensions.config.Config; +import org.springframework.extensions.surf.util.I18NUtil; /** * Simple bean backing the user preferences settings. @@ -113,7 +114,23 @@ public class UserPreferencesBean implements Serializable { if (this.contentFilterLanguage == null) { - Locale locale = (Locale) PreferencesService.getPreferences().getValue(PREF_CONTENTFILTERLANGUAGE); + Locale locale = null; + UserTransaction tx = null; + try + { + FacesContext context = FacesContext.getCurrentInstance(); + tx = Repository.getUserTransaction(context, true); + tx.begin(); + + locale = (Locale) PreferencesService.getPreferences().getValue(PREF_CONTENTFILTERLANGUAGE); + + tx.commit(); + } + catch (Throwable err) + { + try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} + } + // Null means All Languages if (locale == null) { @@ -260,7 +277,22 @@ public class UserPreferencesBean implements Serializable */ public String getStartLocation() { - String location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION); + String location = null; + UserTransaction tx = null; + try + { + FacesContext context = FacesContext.getCurrentInstance(); + tx = Repository.getUserTransaction(context, true); + tx.begin(); + + location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION); + + tx.commit(); + } + catch (Throwable err) + { + try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} + } if (location == null) { // default to value from client config