From 9e497e92a6b51b3e2859519db3e08b16635253b9 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Wed, 11 Oct 2017 10:57:08 +0000 Subject: [PATCH] [Feature #9926] read the scope from environment variable git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-explorer-app@155116 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 6 +++--- distro/changelog.xml | 4 ++++ pom.xml | 2 +- .../workspaceexplorerapp/server/WsUtil.java | 17 ++++++++++------- src/main/webapp/WEB-INF/web.xml | 6 +++--- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.classpath b/.classpath index 8469ccd..9d55208 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -33,5 +33,5 @@ - + diff --git a/distro/changelog.xml b/distro/changelog.xml index f54cd2b..22cfedc 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,8 @@ + + [Feature #9926] read the scope from environment variable + Removed markAsRead method. It is performed by HL diff --git a/pom.xml b/pom.xml index 77309b8..3b2a8b9 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.portlets.user workspace-explorer-app - 1.0.2-SNAPSHOT + 1.1.0-SNAPSHOT war diff --git a/src/main/java/org/gcube/portlets/user/workspaceexplorerapp/server/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspaceexplorerapp/server/WsUtil.java index 4aa7f58..927b2a3 100644 --- a/src/main/java/org/gcube/portlets/user/workspaceexplorerapp/server/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspaceexplorerapp/server/WsUtil.java @@ -25,7 +25,8 @@ import org.slf4j.LoggerFactory; public class WsUtil { public static final Logger logger = LoggerFactory.getLogger(WsUtil.class); - public static final String SCOPE = "scope"; + public static final String ENVIRONMENT_VARIABLE_SCOPE_NAME = "EnvironmentVariableScope"; + public static final String SESSION_SCOPE = "session_scope"; /** * Gets the workspace. @@ -53,16 +54,18 @@ public class WsUtil { * @return the scope */ public static String getScope(HttpSession httpSession){ - String scope = (String) httpSession.getAttribute(SCOPE); - logger.info(SCOPE + " read from httpsession is: "+scope); + String scope = (String) httpSession.getAttribute(SESSION_SCOPE); + logger.info("Variable "+SESSION_SCOPE + " read from httpsession is: "+scope); if(scope==null){ - logger.info(SCOPE + " is null reading from context"); - scope = httpSession.getServletContext().getInitParameter(SCOPE); - logger.info(SCOPE + " read from context is: "+scope); + logger.info("Variable "+SESSION_SCOPE + " is null reading from web.xml context"); + String variableScopeName = httpSession.getServletContext().getInitParameter(ENVIRONMENT_VARIABLE_SCOPE_NAME); + logger.info("Found param-value '"+variableScopeName+"' from web context, reading its value from ENVIRONMENT"); + scope = System.getenv(variableScopeName); + logger.info("Value of "+variableScopeName+" from ENVIRONMENT is: "+scope); } - httpSession.setAttribute(SCOPE, scope); + httpSession.setAttribute(ENVIRONMENT_VARIABLE_SCOPE_NAME, scope); return scope; } } diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 56f4f5e..f7c4cab 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -4,10 +4,10 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> - scope for using HL - scope + Scope used ton instance the HL + EnvironmentVariableScope - /gcube + SCOPE workspaceExplorerAppServlet