diff --git a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java index 30e45ae967..46a6bd1d00 100644 --- a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java +++ b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java @@ -86,9 +86,6 @@ public final class AuthenticationHelper /** cookie names */ private static final String COOKIE_ALFUSER = "alfUser"; - /** portal mode key name */ - private static ThreadLocal portalUserKeyName = new ThreadLocal(); - private static Log logger = LogFactory.getLog(AuthenticationHelper.class); @@ -434,24 +431,16 @@ public final class AuthenticationHelper // naff solution as we need to enumerate all session keys until we find the one that // should match our User objects - this is weak but we don't know how the underlying // Portal vendor has decided to encode the objects in the session - if (portalUserKeyName.get() == null) + Enumeration enumNames = session.getAttributeNames(); + while (enumNames.hasMoreElements()) { - Enumeration enumNames = session.getAttributeNames(); - while (enumNames.hasMoreElements()) + String name = (String)enumNames.nextElement(); + if (name.endsWith(AUTHENTICATION_USER)) { - String name = (String)enumNames.nextElement(); - if (name.endsWith(AUTHENTICATION_USER)) - { - // cache the key value once found! - portalUserKeyName.set(name); - break; - } + user = (User)session.getAttribute(name); + break; } } - if (portalUserKeyName.get() != null) - { - user = (User)session.getAttribute(portalUserKeyName.get()); - } } return user; diff --git a/source/java/org/alfresco/web/bean/repository/Repository.java b/source/java/org/alfresco/web/bean/repository/Repository.java index c98235516e..6ff6ec043d 100644 --- a/source/java/org/alfresco/web/bean/repository/Repository.java +++ b/source/java/org/alfresco/web/bean/repository/Repository.java @@ -46,6 +46,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.lock.LockService; @@ -476,6 +477,36 @@ public final class Repository } } + /** + * Resolve a Path by converting each element into its display NAME attribute. + * Note: This method resolves path regardless access permissions. + * Fixes the UI part of the ETWOONE-214 and ETWOONE-238 issues + * + * @param path Path to convert + * @param separator Separator to user between path elements + * @param prefix To prepend to the path + * + * @return Path converted using NAME attribute on each element + */ + public static String getNamePathEx(FacesContext context, final Path path, final NodeRef rootNode, final String separator, final String prefix) + { + String result = null; + + RetryingTransactionHelper transactionHelper = getRetryingTransactionHelper(context); + transactionHelper.setMaxRetries(1); + final NodeService runtimeNodeService = (NodeService)FacesContextUtils.getRequiredWebApplicationContext(context).getBean("nodeService"); + result = transactionHelper.doInTransaction( + new RetryingTransactionCallback() + { + public String execute() throws Throwable + { + return getNamePath(runtimeNodeService, path, rootNode, separator, prefix); + } + }); + + return result; + } + /** * Return the mimetype code for the specified file name. *

diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java index 9f541f8556..02db405535 100644 --- a/source/java/org/alfresco/web/ui/common/Utils.java +++ b/source/java/org/alfresco/web/ui/common/Utils.java @@ -406,7 +406,7 @@ public final class Utils extends StringUtils NodeRef rootNode = contentCtx.getRootNode(); try { - url = Repository.getNamePath(nodeService, node.getNodePath(), rootNode, "\\", + url = Repository.getNamePathEx(context, node.getNodePath(), rootNode, "\\", "file:///" + navBean.getCIFSServerPath(diskShare)); } catch (AccessDeniedException e) diff --git a/source/java/org/alfresco/web/ui/repo/renderer/MultilingualTextAreaRenderer.java b/source/java/org/alfresco/web/ui/repo/renderer/MultilingualTextAreaRenderer.java index 7cbdacdf87..4d2f5033c2 100644 --- a/source/java/org/alfresco/web/ui/repo/renderer/MultilingualTextAreaRenderer.java +++ b/source/java/org/alfresco/web/ui/repo/renderer/MultilingualTextAreaRenderer.java @@ -27,6 +27,7 @@ package org.alfresco.web.ui.repo.renderer; import java.io.IOException; import javax.faces.component.UIComponent; +import javax.faces.component.ValueHolder; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; @@ -44,6 +45,17 @@ import org.apache.myfaces.renderkit.html.HtmlTextareaRenderer; */ public class MultilingualTextAreaRenderer extends HtmlTextareaRenderer { + @Override + protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException + { + // to workaround a bug in MyFaces where it appears a new line gets removed + // in the process view/edit process add it back (ETWOONE-91) + Object value = ((ValueHolder) uiComponent).getValue(); + String valueStr = "\r\n" + (String)value; + ((ValueHolder) uiComponent).setValue(valueStr); + super.encodeTextArea(facesContext, uiComponent); +} + @Override public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {