From 1f9e62cbbe4dd58f7c0298d80e375cf375698e6c Mon Sep 17 00:00:00 2001 From: Alfredo Oliviero Date: Thu, 30 May 2024 16:33:12 +0200 Subject: [PATCH] config portlet, all is working --- .../CloudComputingConfigPortlet.java | 2 + .../CloudComputingBootPlatformPortlet.java | 19 ----- .../CloudComputingConfigurationPortlet.java | 71 +++++++++++++++++++ src/main/webapp/WEB-INF/liferay-display.xml | 1 + src/main/webapp/WEB-INF/liferay-portlet.xml | 10 ++- src/main/webapp/WEB-INF/portlet.xml | 33 +++++++++ src/main/webapp/html/boot/boot.jsp | 46 +----------- src/main/webapp/html/config/configuration.jsp | 39 ++++++++++ src/main/webapp/html/init.jsp | 8 +++ .../webapp/html/methods/edit/methodeditor.jsp | 10 --- .../html/methods/exec/methodexecutor.jsp | 11 --- .../webapp/html/methods/list/methodslist.jsp | 8 --- .../html/methods/monitor/methodmonitor.jsp | 11 --- 13 files changed, 163 insertions(+), 106 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/cloudcomputing/config/CloudComputingConfigurationPortlet.java create mode 100644 src/main/webapp/html/config/configuration.jsp diff --git a/src/main/java/org/gcube/portlets/user/cloudcomputing/CloudComputingConfigPortlet.java b/src/main/java/org/gcube/portlets/user/cloudcomputing/CloudComputingConfigPortlet.java index e7451c5..7722c13 100644 --- a/src/main/java/org/gcube/portlets/user/cloudcomputing/CloudComputingConfigPortlet.java +++ b/src/main/java/org/gcube/portlets/user/cloudcomputing/CloudComputingConfigPortlet.java @@ -121,6 +121,8 @@ public class CloudComputingConfigPortlet extends MVCPortlet { CloudComputingConfig config = getConfig(renderRequest); + renderRequest.setAttribute("config", config); + renderRequest.setAttribute("encoded_context", config.encoded_context); renderRequest.setAttribute("gateway", config.gateway); renderRequest.setAttribute("redirect_url", config.redirect_url); diff --git a/src/main/java/org/gcube/portlets/user/cloudcomputing/boot/CloudComputingBootPlatformPortlet.java b/src/main/java/org/gcube/portlets/user/cloudcomputing/boot/CloudComputingBootPlatformPortlet.java index 0d04246..3fd933d 100644 --- a/src/main/java/org/gcube/portlets/user/cloudcomputing/boot/CloudComputingBootPlatformPortlet.java +++ b/src/main/java/org/gcube/portlets/user/cloudcomputing/boot/CloudComputingBootPlatformPortlet.java @@ -26,29 +26,10 @@ public class CloudComputingBootPlatformPortlet extends CloudComputingConfigPortl public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { super.render(renderRequest, renderResponse); - - // addDebugParams(renderRequest); } public void addDebugParams(RenderRequest renderRequest) { - try { - CloudComputingConfig config = getConfig(renderRequest); - renderRequest.setAttribute("encoded_context", config.encoded_context); - renderRequest.setAttribute("gateway", config.gateway); - renderRequest.setAttribute("redirect_url", config.redirect_url); - renderRequest.setAttribute("auth_url", config.auth_url); - renderRequest.setAttribute("ccp_url", config.ccp_url); - renderRequest.setAttribute("cdn_url", config.cdn_url); - - } catch (ServerException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - String current_url = PortalUtil.getCurrentURL(renderRequest); renderRequest.setAttribute("current_url", current_url); diff --git a/src/main/java/org/gcube/portlets/user/cloudcomputing/config/CloudComputingConfigurationPortlet.java b/src/main/java/org/gcube/portlets/user/cloudcomputing/config/CloudComputingConfigurationPortlet.java new file mode 100644 index 0000000..b08f7c7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/cloudcomputing/config/CloudComputingConfigurationPortlet.java @@ -0,0 +1,71 @@ +package org.gcube.portlets.user.cloudcomputing.config; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.servlet.http.HttpServletRequest; + +import org.gcube.common.portal.PortalContext; +import org.gcube.portlets.user.cloudcomputing.CloudComputingConfigPortlet; + +import com.liferay.portal.kernel.log.LogFactoryUtil; +import com.liferay.portal.model.Group; +import com.liferay.portal.service.GroupLocalServiceUtil; +import com.liferay.portal.util.PortalUtil; + +public class CloudComputingConfigurationPortlet extends CloudComputingConfigPortlet { + private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil + .getLog(CloudComputingConfigurationPortlet.class); + + public void render(RenderRequest renderRequest, RenderResponse renderResponse) + throws PortletException, IOException { + + String current_url = PortalUtil.getCurrentURL(renderRequest); + renderRequest.setAttribute("current_url", current_url); + + String infrastructure = PortalContext.getConfiguration().getInfrastructureName(); + renderRequest.setAttribute("infrastructure", infrastructure); + + HttpServletRequest httpReq = PortalUtil + .getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest)); + String absolute_current_url = PortalUtil.getAbsoluteURL(httpReq, current_url); + renderRequest.setAttribute("absolute_current_url", absolute_current_url); + + String base_url = PortalUtil.getAbsoluteURL(httpReq, "/"); + renderRequest.setAttribute("base_url", base_url); + + try { + URL burl = new URL(base_url); + renderRequest.setAttribute("host", burl.getHost()); + + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + renderRequest.setAttribute("host", e.getMessage()); + } + + try { + Group group = (Group) GroupLocalServiceUtil.getGroup(PortalUtil.getScopeGroupId(renderRequest)); + String group_url = group.getFriendlyURL(); + renderRequest.setAttribute("group_url", group_url); + renderRequest.setAttribute("group_name", group.getName()); + + } catch (Exception e) { + e.printStackTrace(); + renderRequest.setAttribute("group_url", e.getMessage()); + renderRequest.setAttribute("group_name", e.getMessage()); + } + + String completeURL = PortalUtil.getCurrentCompleteURL(httpReq); + renderRequest.setAttribute("completeURL", completeURL); + + // User theUser = PortalUtil.getUser(renderRequest); + String currentContext = getCurrentContext(renderRequest); + renderRequest.setAttribute("current_context", currentContext); + super.render(renderRequest, renderResponse); + } +} diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml index 2f9e22d..35d1db1 100644 --- a/src/main/webapp/WEB-INF/liferay-display.xml +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -4,6 +4,7 @@ + diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml index 58dba5e..8389ff9 100644 --- a/src/main/webapp/WEB-INF/liferay-portlet.xml +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -8,13 +8,20 @@ /css/main.css /js/main.js --> - + cloudcomputing-boot-platform-portlet /icon.png /css/main.css /js/main.js + + cloudcomputing-config-portlet + /icon.png + /css/main.css + /js/main.js + + cloudcomputing-methods-list-portlet /icon.png @@ -33,7 +40,6 @@ /css/main.css /js/main.js - cloudcomputing-method-monitor-portlet /icon.png diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml index c317957..51c4bc7 100644 --- a/src/main/webapp/WEB-INF/portlet.xml +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -37,6 +37,39 @@ + + cloudcomputing-config-portlet + cloudcomputing-config-portlet + + org.gcube.portlets.user.cloudcomputing.config.CloudComputingConfigurationPortlet + + + view-template + /html/config/configuration.jsp + + 0 + + text/html + + + cloudcomputing-config-portlet + cloudcomputing-config-portlet + cloudcomputing-config-portlet + + + administrator + + + guest + + + power-user + + + user + + + cloudcomputing-methods-list-portlet cloudcomputing-methods-list-portlet diff --git a/src/main/webapp/html/boot/boot.jsp b/src/main/webapp/html/boot/boot.jsp index 23e5ada..a50a280 100644 --- a/src/main/webapp/html/boot/boot.jsp +++ b/src/main/webapp/html/boot/boot.jsp @@ -1,25 +1,6 @@ <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> <%@ include file="../init.jsp"%> -<% -pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context")); -pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url")); -pageContext.setAttribute("auth_url", request.getAttribute("auth_url")); -pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url")); -pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); - -pageContext.setAttribute("current_context", request.getAttribute("current_context")); - -pageContext.setAttribute("current_url", request.getAttribute("current_url")); -pageContext.setAttribute("infrastructure", request.getAttribute("infrastructure")); -pageContext.setAttribute("absolute_current_url", request.getAttribute("absolute_current_url")); -pageContext.setAttribute("calculated_gateway", request.getAttribute("calculated_gateway")); -pageContext.setAttribute("base_url", request.getAttribute("base_url")); -pageContext.setAttribute("group_url", request.getAttribute("group_url")); -pageContext.setAttribute("group_name", request.getAttribute("group_name")); -pageContext.setAttribute("host", request.getAttribute("host")); -%> - @@ -34,29 +15,4 @@ pageContext.setAttribute("host", request.getAttribute("host")); -Boot Portlet - -
- -
    - -
  • current_context = ${current_context}
  • -
  • encoded_context = ${encoded_context}
  • -
  • gateway = ${gateway}
  • -
  • redirect_url = ${redirect_url}
  • -
  • auth_url = ${auth_url}
  • -
  • ccp_url = ${ccp_url}
  • -
  • cdn_url = ${cdn_url}
  • - - -
  • current_url = ${current_url}
  • -
  • infrastructure = ${infrastructure}
  • -
  • absolute_current_url = ${absolute_current_url}
  • -
  • calculated_gateway = ${calculated_gateway}
  • - -
  • base_url = ${base_url}
  • -
  • group_url = ${group_url}
  • -
  • group_name = ${group_name}
  • -
  • host = ${host}
  • -
-
+Boot Portlet - tohide diff --git a/src/main/webapp/html/config/configuration.jsp b/src/main/webapp/html/config/configuration.jsp new file mode 100644 index 0000000..87bcf23 --- /dev/null +++ b/src/main/webapp/html/config/configuration.jsp @@ -0,0 +1,39 @@ +<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> +<%@ include file="../init.jsp"%> + +<% +pageContext.setAttribute("current_context", request.getAttribute("current_context")); + +pageContext.setAttribute("current_url", request.getAttribute("current_url")); +pageContext.setAttribute("infrastructure", request.getAttribute("infrastructure")); +pageContext.setAttribute("absolute_current_url", request.getAttribute("absolute_current_url")); +pageContext.setAttribute("base_url", request.getAttribute("base_url")); +pageContext.setAttribute("group_url", request.getAttribute("group_url")); +pageContext.setAttribute("group_name", request.getAttribute("group_name")); +pageContext.setAttribute("host", request.getAttribute("host")); +%> + +
+ +
    +
  • current_context = ${current_context}
  • +
  • encoded_context = ${encoded_context}
  • +
  • gateway = ${gateway}
  • +
  • redirect_url = ${redirect_url}
  • +
  • auth_url = ${auth_url}
  • +
  • ccp_url = ${ccp_url}
  • +
  • cdn_url = ${cdn_url}
  • + + +
  • current_url = ${current_url}
  • +
  • infrastructure = ${infrastructure}
  • +
  • absolute_current_url = ${absolute_current_url}
  • + +
  • base_url = ${base_url}
  • +
  • group_url = ${group_url}
  • +
  • group_name = ${group_name}
  • +
  • host = ${host}
  • +
+
+ + \ No newline at end of file diff --git a/src/main/webapp/html/init.jsp b/src/main/webapp/html/init.jsp index 7e911ea..ea612b1 100644 --- a/src/main/webapp/html/init.jsp +++ b/src/main/webapp/html/init.jsp @@ -52,3 +52,11 @@ + +<% +pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context")); +pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url")); +pageContext.setAttribute("auth_url", request.getAttribute("auth_url")); +pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url")); +pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); +%> diff --git a/src/main/webapp/html/methods/edit/methodeditor.jsp b/src/main/webapp/html/methods/edit/methodeditor.jsp index 0825d28..d0243a7 100644 --- a/src/main/webapp/html/methods/edit/methodeditor.jsp +++ b/src/main/webapp/html/methods/edit/methodeditor.jsp @@ -2,16 +2,6 @@ <%@ include file="../../init.jsp"%> -<% -pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context")); -pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url")); -pageContext.setAttribute("auth_url", request.getAttribute("auth_url")); -pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url")); -pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); -%> - - - diff --git a/src/main/webapp/html/methods/exec/methodexecutor.jsp b/src/main/webapp/html/methods/exec/methodexecutor.jsp index 45c2149..2d23367 100644 --- a/src/main/webapp/html/methods/exec/methodexecutor.jsp +++ b/src/main/webapp/html/methods/exec/methodexecutor.jsp @@ -2,17 +2,6 @@ <%@ include file="../../init.jsp"%> -<% -pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context")); -pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url")); -pageContext.setAttribute("auth_url", request.getAttribute("auth_url")); -pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url")); -pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); -%> - - - -
diff --git a/src/main/webapp/html/methods/list/methodslist.jsp b/src/main/webapp/html/methods/list/methodslist.jsp index e3d03c1..d3e9a52 100644 --- a/src/main/webapp/html/methods/list/methodslist.jsp +++ b/src/main/webapp/html/methods/list/methodslist.jsp @@ -2,14 +2,6 @@ <%@ include file="../../init.jsp"%> -<% -pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context")); -pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url")); -pageContext.setAttribute("auth_url", request.getAttribute("auth_url")); -pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url")); -pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); -%> -
diff --git a/src/main/webapp/html/methods/monitor/methodmonitor.jsp b/src/main/webapp/html/methods/monitor/methodmonitor.jsp index cb26a96..ac2daa7 100644 --- a/src/main/webapp/html/methods/monitor/methodmonitor.jsp +++ b/src/main/webapp/html/methods/monitor/methodmonitor.jsp @@ -2,18 +2,7 @@ <%@ include file="../../init.jsp"%> -<% -pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context")); -pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url")); -pageContext.setAttribute("auth_url", request.getAttribute("auth_url")); -pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url")); -pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); -%> - -
- -Method List Portlet \ No newline at end of file