Merged V2.2 to HEAD

8121: Merged V2.1 to V2.2
      8088: Turned off debug logging.
      8090: Tweaked session cache limiting for AVM.
      8095: Fix for issue raised in ACT 402
      8108: Fix for AWC-1816
      8115: Build fix 
      8117: Fix AR-1217: OpenOffice connection is actively maintained

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8480 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-03-10 15:22:43 +00:00
parent 086838b020
commit c560aef6bd
7 changed files with 210 additions and 94 deletions

View File

@@ -27,6 +27,7 @@ package org.alfresco.web.bean;
import java.io.IOException;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
import javax.faces.application.FacesMessage;
@@ -374,6 +375,7 @@ public class LoginBean implements Serializable
// need to capture this value before invalidating the session
boolean externalAuth = isAlfrescoAuth();
Locale language = Application.getLanguage(context);
// Invalidate Session for this user.
if (Application.inPortalServer() == false)
@@ -407,12 +409,8 @@ public class LoginBean implements Serializable
Map session = context.getExternalContext().getSessionMap();
session.put(AuthenticationHelper.SESSION_INVALIDATED, true);
// set language to last used
String language = preferences.getLanguage();
if (language != null && language.length() != 0)
{
Application.setLanguage(context, language);
}
// set language to last used on the login page
Application.setLanguage(context, language.toString());
return externalAuth ? "logout" : "relogin";
}

View File

@@ -25,6 +25,7 @@
package org.alfresco.web.bean.repository;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import org.alfresco.web.app.Application;
@@ -57,15 +58,16 @@ public final class PreferencesService
public static Preferences getPreferences(FacesContext fc)
{
User user = Application.getCurrentUser(fc);
return getPreferences(user);
return user != null ? user.getPreferences(fc) : null;
}
/**
* @param user User instance
* @return The Preferences for the current User instance.
*/
public static Preferences getPreferences(User user)
public static Preferences getPreferences(HttpSession session)
{
return user.getPreferences();
User user = Application.getCurrentUser(session);
return user != null ? user.getPreferences(session.getServletContext()) : null;
}
}

View File

@@ -29,7 +29,10 @@ import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.configuration.ConfigurableService;
@@ -40,7 +43,9 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.jsf.FacesContextUtils;
/**
* Bean that represents the currently logged in user
@@ -180,65 +185,90 @@ public final class User implements Serializable
/**
* @return The Preferences for the User
*/
Preferences getPreferences()
Preferences getPreferences(FacesContext fc)
{
if (this.preferences == null)
{
this.preferences = new Preferences(getUserPreferencesRef());
this.preferences = new Preferences(getUserPreferencesRef(
FacesContextUtils.getRequiredWebApplicationContext(fc)));
}
return this.preferences;
}
/**
* @return The Preferences for the User
*/
Preferences getPreferences(ServletContext sc)
{
if (this.preferences == null)
{
this.preferences = new Preferences(getUserPreferencesRef(
WebApplicationContextUtils.getRequiredWebApplicationContext(sc)));
}
return this.preferences;
}
/**
* Get or create the node used to store user preferences.
* Utilises the 'configurable' aspect on the Person linked to this user.
*/
synchronized NodeRef getUserPreferencesRef()
synchronized NodeRef getUserPreferencesRef(WebApplicationContext context)
{
FacesContext fc = FacesContext.getCurrentInstance();
ServiceRegistry registry = Repository.getServiceRegistry(fc);
ServiceRegistry registry = (ServiceRegistry)context.getBean("ServiceRegistry");
NodeService nodeService = registry.getNodeService();
SearchService searchService = registry.getSearchService();
NamespaceService namespaceService = registry.getNamespaceService();
ConfigurableService configurableService = Repository.getConfigurableService(fc);
ConfigurableService configurableService = (ConfigurableService)context.getBean("ConfigurableService");
UserTransaction txn = registry.getTransactionService().getUserTransaction();
NodeRef person = getPerson();
if (nodeService.hasAspect(person, ApplicationModel.ASPECT_CONFIGURABLE) == false)
NodeRef prefRef = null;
try
{
// create the configuration folder for this Person node
configurableService.makeConfigurable(person);
txn.begin();
NodeRef person = getPerson();
if (nodeService.hasAspect(person, ApplicationModel.ASPECT_CONFIGURABLE) == false)
{
// create the configuration folder for this Person node
configurableService.makeConfigurable(person);
}
// target of the assoc is the configurations folder ref
NodeRef configRef = configurableService.getConfigurationFolder(person);
if (configRef == null)
{
throw new IllegalStateException("Unable to find associated 'configurations' folder for node: " + person);
}
String xpath = NamespaceService.APP_MODEL_PREFIX + ":" + "preferences";
List<NodeRef> nodes = searchService.selectNodes(
configRef,
xpath,
null,
namespaceService,
false);
if (nodes.size() == 1)
{
prefRef = nodes.get(0);
}
else
{
// create the preferences Node for this user
ChildAssociationRef childRef = nodeService.createNode(
configRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "preferences"),
ContentModel.TYPE_CMOBJECT);
prefRef = childRef.getChildRef();
}
txn.commit();
}
// target of the assoc is the configurations folder ref
NodeRef configRef = configurableService.getConfigurationFolder(person);
if (configRef == null)
catch (Throwable err)
{
throw new IllegalStateException("Unable to find associated 'configurations' folder for node: " + person);
}
String xpath = NamespaceService.APP_MODEL_PREFIX + ":" + "preferences";
List<NodeRef> nodes = searchService.selectNodes(
configRef,
xpath,
null,
namespaceService,
false);
NodeRef prefRef;
if (nodes.size() == 1)
{
prefRef = nodes.get(0);
}
else
{
// create the preferences Node for this user
ChildAssociationRef childRef = nodeService.createNode(
configRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "preferences"),
ContentModel.TYPE_CMOBJECT);
prefRef = childRef.getChildRef();
try { txn.rollback(); } catch (Exception tex) {}
throw new AlfrescoRuntimeException("Error during getUserPreferencesRef(): " + err.getMessage(), err);
}
return prefRef;

View File

@@ -34,7 +34,6 @@ import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.config.Config;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
import org.alfresco.service.cmr.ml.MultilingualContentService;
@@ -58,8 +57,8 @@ public class UserPreferencesBean implements Serializable
private static final long serialVersionUID = -1262481849503163054L;
private static final String PREF_STARTLOCATION = "start-location";
private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language";
public static final String PREF_INTERFACELANGUAGE = "interface-language";
/**
* Remplacement message for set the filter at 'all languages'.
@@ -67,9 +66,6 @@ public class UserPreferencesBean implements Serializable
*/
public static final String MSG_CONTENTALLLANGUAGES = "content_all_languages";
/** language locale selection */
private String language = null;
/** content language locale selection */
private String contentFilterLanguage = null;
@@ -87,48 +83,31 @@ public class UserPreferencesBean implements Serializable
*/
public SelectItem[] getLanguages()
{
// Get the item selection list
SelectItem[] items = getLanguageItems();
// Change the current language
if (this.language == null)
{
// first try to get the language that the current user is using
Locale lastLocale = Application.getLanguage(FacesContext.getCurrentInstance());
if (lastLocale != null)
{
this.language = lastLocale.toString();
}
// else we default to the first item in the list
else if (items.length > 0)
{
this.language = (String) items[0].getValue();
}
else
{
throw new AlfrescoRuntimeException("The language list is empty");
}
}
return items;
// Get the item selection list for the list of languages
return getLanguageItems();
}
/**
* @return Returns the language selection.
* @return Returns the language selection for the current user session.
*/
public String getLanguage()
{
return this.language;
return Application.getLanguage(FacesContext.getCurrentInstance()).toString();
}
/**
* @param language The language selection to set.
*/
public void setLanguage(String language)
{
this.language = language;
// set the language for the current session
Application.setLanguage(FacesContext.getCurrentInstance(), language);
// Set the current locale in the server
I18NUtil.setLocale(I18NUtil.parseLocale(language));
// save user preference
if (Application.getCurrentUser(FacesContext.getCurrentInstance()) != null)
{
PreferencesService.getPreferences().setValue(PREF_INTERFACELANGUAGE, language);
}
}
/**