diff --git a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java index 5e1bab37e7..e1158a8bca 100644 --- a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java +++ b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java @@ -434,12 +434,11 @@ public final class AuthenticationHelper // Portal vendor has decided to encode the objects in the session if (portalUserKeyName.get() == null) { - String userKeyPostfix = "?" + AUTHENTICATION_USER; Enumeration enumNames = session.getAttributeNames(); while (enumNames.hasMoreElements()) { String name = (String)enumNames.nextElement(); - if (name.endsWith(userKeyPostfix)) + if (name.endsWith(AUTHENTICATION_USER)) { // cache the key value once found! portalUserKeyName.set(name); diff --git a/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java b/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java index 2e3d5a5a46..3fe8390ff4 100644 --- a/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java +++ b/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java @@ -24,6 +24,7 @@ */ package org.alfresco.web.bean.ajax; +import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; @@ -135,7 +136,7 @@ public class FileUploadBean InputStream is = null; try { - is = new FileInputStream(file); + is = new BufferedInputStream(new FileInputStream(file)); encoding = Repository.guessEncoding(fc, is, mimetype); } catch (Throwable e) diff --git a/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java b/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java index 4ca53d1547..fa81833b01 100644 --- a/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java +++ b/source/java/org/alfresco/web/scripts/portlet/WebScriptPortlet.java @@ -45,6 +45,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.web.app.Application; import org.alfresco.web.scripts.DeclarativeWebScriptRegistry; import org.alfresco.web.scripts.WebScript; import org.alfresco.web.scripts.WebScriptDescription; @@ -111,6 +112,7 @@ public class WebScriptPortlet implements Portlet */ public void processAction(ActionRequest req, ActionResponse res) throws PortletException, PortletSecurityException, IOException { + Application.setInPortalServer(true); Map params = req.getParameterMap(); for (Map.Entry param : params.entrySet()) { @@ -127,6 +129,7 @@ public class WebScriptPortlet implements Portlet */ public void render(RenderRequest req, RenderResponse res) throws PortletException, PortletSecurityException, IOException { + Application.setInPortalServer(true); PortletMode portletMode = req.getPortletMode(); if (PortletMode.VIEW.equals(portletMode)) { diff --git a/source/java/org/alfresco/web/scripts/portlet/WebScriptPortletRequest.java b/source/java/org/alfresco/web/scripts/portlet/WebScriptPortletRequest.java index cf41d94fd5..6832a22759 100644 --- a/source/java/org/alfresco/web/scripts/portlet/WebScriptPortletRequest.java +++ b/source/java/org/alfresco/web/scripts/portlet/WebScriptPortletRequest.java @@ -68,21 +68,24 @@ public class WebScriptPortletRequest extends WebScriptURLRequest { super(scriptUrlParts, serviceMatch); this.req = req; - // look for the user info map in the portlet request - populated by the portlet container - Map userInfo = (Map)req.getAttribute(PortletRequest.USER_INFO); - if (userInfo != null) + if (req != null) { - // look for the special Liferay email (username) key - String liferayUsername = (String)userInfo.get("user.home-info.online.email"); - if (liferayUsername != null) + // look for the user info map in the portlet request - populated by the portlet container + Map userInfo = (Map)req.getAttribute(PortletRequest.USER_INFO); + if (userInfo != null) { - // strip suffix from email address - we only need username part - if (liferayUsername.indexOf('@') != -1) + // look for the special Liferay email (username) key + String liferayUsername = (String)userInfo.get("user.home-info.online.email"); + if (liferayUsername != null) { - liferayUsername = liferayUsername.substring(0, liferayUsername.indexOf('@')); + // strip suffix from email address - we only need username part + if (liferayUsername.indexOf('@') != -1) + { + liferayUsername = liferayUsername.substring(0, liferayUsername.indexOf('@')); + } + // save in session for use by alfresco portlet authenticator + this.req.getPortletSession().setAttribute(ALFPORTLETUSERNAME, liferayUsername); } - // save in session for use by alfresco portlet authenticator - this.req.getPortletSession().setAttribute(ALFPORTLETUSERNAME, liferayUsername); } } }