updated get Gaetway name method

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@124582 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-02-25 14:55:46 +00:00
parent 3cdb063a96
commit 8b0353e3bf
2 changed files with 36 additions and 2 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>gCube Portal Manager</name>
<description>

View File

@ -28,6 +28,7 @@ public class PortalContext {
private static final String SENDER_EMAIL = "notificationSenderEmail";
private static final String GATEWAY_NAME = "portalinstancename";
private static final String ADMIN_USERNAME = "administratorUsername";
private static PortalContext singleton = new PortalContext();
@ -91,9 +92,18 @@ public class PortalContext {
return toReturn;
}
/**
* read the portal instance name from a property file and returns it
*
* @deprecated use getConfiguration().getGatewayName() method
* read the portal instance name from a property file and returns it
*/
@Deprecated
public static String getPortalInstanceName() {
return getConfiguration().getGatewayName();
}
/**
* read the infrastructure gateway name from a property file and returns it
*/
public String getGatewayName() {
//get the portles to look for from the property file
Properties props = new Properties();
String toReturn = "";
@ -138,6 +148,30 @@ public class PortalContext {
_log.debug("Returning SENDER_EMAIL: " + toReturn );
return toReturn;
}
/**
* read the sender (from) email address for notifications name from a property file and returns it
*/
public String getAdministratorUsername() {
//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(ADMIN_USERNAME);
}
//catch exception in case properties file does not exist
catch(IOException e) {
toReturn = "massimiliano.assante";
_log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default administrator" + toReturn);
return toReturn;
}
_log.debug("Returning Administrator username: " + toReturn );
return toReturn;
}
/**
*
* @return $CATALINA_HOME