From 23c1b5d032826c5bdde5499394025cb528e699cb Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 8 Jul 2015 10:09:20 +0000 Subject: [PATCH] Added method for getting portal instance name git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@117072 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gcube/common/portal/PortalContext.java | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/common/portal/PortalContext.java b/src/main/java/org/gcube/common/portal/PortalContext.java index 378b62e..634eef8 100644 --- a/src/main/java/org/gcube/common/portal/PortalContext.java +++ b/src/main/java/org/gcube/common/portal/PortalContext.java @@ -26,8 +26,9 @@ public class PortalContext { private static final String INFRASTRUCTURE_NAME = "infrastructure"; private static final String SCOPES = "scopes"; - private static final String SENDER_EMAIL_PROPNAME = "notificationSenderEmail";; - + private static final String SENDER_EMAIL = "notificationSenderEmail"; + private static final String GATEWAY_NAME = "portalinstancename"; + private static PortalContext singleton = new PortalContext(); private String infra; @@ -89,9 +90,32 @@ public class PortalContext { } return toReturn; } - /** - * read the sender email for notifications name from a property file and returns it + * read the portal instance name from a property file and returns it + */ + public static String getPortalInstanceName() { + //get the portles to look for from the property file + Properties props = new Properties(); + String toReturn = ""; + + try { + String propertyfile = getCatalinaHome() + File.separator + "conf" + File.separator + "gcube-data.properties"; + File propsFile = new File(propertyfile); + FileInputStream fis = new FileInputStream(propsFile); + props.load( fis); + toReturn = props.getProperty(GATEWAY_NAME); + } + //catch exception in case properties file does not exist + catch(IOException e) { + toReturn = "D4science Gateway"; + _log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default Portal Name " + toReturn); + return toReturn; + } + _log.debug("Returning Gateway Name: " + toReturn ); + return toReturn; + } + /** + * read the sender (from) email address for notifications name from a property file and returns it */ public String getSenderEmail() { //get the portles to look for from the property file @@ -103,7 +127,7 @@ public class PortalContext { File propsFile = new File(propertyfile); FileInputStream fis = new FileInputStream(propsFile); props.load( fis); - toReturn = props.getProperty(SENDER_EMAIL_PROPNAME); + toReturn = props.getProperty(SENDER_EMAIL); } //catch exception in case properties file does not exist catch(IOException e) {