Author: kien_nguyen
Date: 2011-10-19 00:41:43 -0400 (Wed, 19 Oct 2011)
New Revision: 7773
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java
Log:
GTNPORTAL-2184 Problem with gadgets when the host name includes the word portal
Modified:
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl
===================================================================
---
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl 2011-10-19
04:39:39 UTC (rev 7772)
+++
portal/trunk/portlet/dashboard/src/main/webapp/groovy/gadget/webui/component/UIGadgetViewMode.gtmpl 2011-10-19
04:41:43 UTC (rev 7773)
@@ -4,7 +4,7 @@
import org.exoplatform.portal.webui.application.GadgetUtil;
import org.exoplatform.webui.application.portlet.PortletRequestContext;
- def hostName = GadgetUtil.getRelGadgetServerUrl();
+ def hostName = GadgetUtil.getGadgetServerUrl();
def rcontext = _ctx.getRequestContext() ;
def windowId = rcontext.getWindowId();
def id = uicomponent.getId() + "-" + windowId ;
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2011-10-19
04:39:39 UTC (rev 7772)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIGadget.gtmpl 2011-10-19
04:41:43 UTC (rev 7773)
@@ -4,7 +4,7 @@
def rcontext = _ctx.getRequestContext();
JavascriptManager jsmanager = rcontext.getJavascriptManager();
- def hostName = GadgetUtil.getRelGadgetServerUrl();
+ def hostName = GadgetUtil.getGadgetServerUrl();
def url = null;
def metadata = "";
def posX = uicomponent.getProperties().getIntValue("locationX") +
"px";
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java 2011-10-19
04:39:39 UTC (rev 7772)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/GadgetUtil.java 2011-10-19
04:41:43 UTC (rev 7773)
@@ -40,6 +40,8 @@
import java.util.Iterator;
import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
/**
* Created by The eXo Platform SAS Author : Pham Thanh Tung
* thanhtungty(a)gmail.com Oct 2, 2008
@@ -200,84 +202,46 @@
return getLocalHostBase() + "/" +
PortalContainer.getCurrentRestContextName() + "/private/" + uri;
}
- // TODO: TanPham:Replace by getGadgetServerUrl to make server url
- // static private String getHostBase() {
- // String hostName = getHostName();
- // URL url = null;
- // try {
- // url = new URL(hostName);
- // } catch (Exception e) {}
- // if(url == null) return hostName ;
- // int index = hostName.indexOf(url.getPath()) ;
- // if(index < 1) return hostName ;
- // return hostName.substring(0, index) ;
- // }
+ /**
+ * Make full URL of gadget server
+ * @return URL String
+ */
public static String getGadgetServerUrl()
{
- String hostName = getHostName();
+ String uriString = getGadgetServerURI();
try
{
- new URL(hostName);
+ new URL(uriString);
}
catch (Exception e)
{
- try
- {
- String newHostName = getLocalHostName() + "/" + hostName;
- new URL(newHostName);
- hostName = newHostName;
- }
- catch (Exception e2)
- {
- }
+ return getLocalHostBase() + (uriString.startsWith("/") ? uriString :
("/" + uriString));
}
- return hostName;
+ return uriString;
}
- // TODO: Using in gtmpl templates
+ /**
+ * See getGadgetServerUrl()
+ * @return URL String
+ */
+ @Deprecated
public static String getRelGadgetServerUrl()
{
- String url = getGadgetServerUrl();
- String localHostBase = getLocalHostBase();
- int index = url.indexOf(localHostBase);
- if (index >= 0)
- return url.substring(index + localHostBase.length());
- return url;
+ return getGadgetServerUrl();
}
- static private String getLocalHostBase()
+ static private String getGadgetServerURI()
{
- String hostName = getLocalHostName();
- URL url = null;
- try
- {
- url = new URL(hostName);
- }
- catch (Exception e)
- {
- }
- if (url == null)
- return hostName;
- int index = hostName.indexOf(url.getPath());
- if (index < 1)
- return hostName;
- return hostName.substring(0, index);
- }
-
- static private String getHostName()
- {
ExoContainer container = ExoContainerContext.getCurrentContainer();
GadgetRegistryService gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
return gadgetService.getHostName();
}
- static private String getLocalHostName()
+ static private String getLocalHostBase()
{
- PortalRequestContext pContext = Util.getPortalRequestContext();
- StringBuffer requestUrl = pContext.getRequest().getRequestURL();
- int index = requestUrl.indexOf(pContext.getRequestContextPath());
- return requestUrl.substring(0, index);
+ HttpServletRequest request = Util.getPortalRequestContext().getRequest();
+ return request.getScheme() + "://" + request.getServerName() +
((request.getServerPort() != 80) ? ":" + request.getServerPort() :
"");
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java 2011-10-19
04:39:39 UTC (rev 7772)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UIForgetPassword.java 2011-10-19
04:41:43 UTC (rev 7773)
@@ -45,6 +45,8 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import javax.servlet.http.HttpServletRequest;
+
/**
* Created by The eXo Platform SARL
* Author : dang.tung
@@ -75,7 +77,6 @@
UILogin uilogin = uiForm.getParent();
WebuiRequestContext requestContext = event.getRequestContext();
PortalRequestContext portalContext = PortalRequestContext.getCurrentInstance();
- String url = portalContext.getRequest().getRequestURL().toString();
MailService mailSrc = uiForm.getApplicationComponent(MailService.class);
OrganizationService orgSrc =
uiForm.getApplicationComponent(OrganizationService.class);
String userName = uiForm.getUIStringInput(Username).getValue();
@@ -141,7 +142,8 @@
{
e.printStackTrace();
}
- String host = url.substring(0,
url.indexOf(requestContext.getRequestContextPath()));
+ HttpServletRequest request = portalContext.getRequest();
+ String host = request.getScheme() + "://" + request.getServerName() +
":" + request.getServerPort();
String activeLink = host + requestContext.getRequestContextPath() +
"/public/" + portalName
+
"?portal:componentId=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
+ tokenId;
Show replies by date