Added method for getting portal email sender

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@115456 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-06-22 13:24:39 +00:00
parent d0bc4985b5
commit 363e0701f2
3 changed files with 36 additions and 7 deletions

View File

@ -1,7 +1,9 @@
<ReleaseNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xsd/changelog.xsd">
<Changeset component="org.gcube.common.portal.portal-manager.1-0-0">
date="2013-10-21">
<Changeset component="org.gcube.common.portal.portal-manager.1-1-0" date="2015-06-22">
<Change>Added method for getting portal email sender</Change>
</Changeset>
<Changeset component="org.gcube.common.portal.portal-manager.1-0-0" date="2013-10-21">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>gCube Portal Manager</name>
<description>
@ -23,8 +23,8 @@
</scm>
<properties>
<distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

View File

@ -24,7 +24,9 @@ public class PortalContext {
private static final Logger _log = LoggerFactory.getLogger(PortalContext.class);
private static final String INFRASTRUCTURE_NAME = "infrastructure";
private static final String SCOPES = "scopes";
private static final String SCOPES = "scopes";
private static final String SENDER_EMAIL_PROPNAME = "notificationSenderEmail";;
private static PortalContext singleton = new PortalContext();
@ -87,7 +89,32 @@ public class PortalContext {
}
return toReturn;
}
/**
/**
* read the sender email for notifications name from a property file and returns it
*/
private static String getSenderEmail() {
//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(SENDER_EMAIL_PROPNAME);
}
//catch exception in case properties file does not exist
catch(IOException e) {
toReturn = "do-not-reply@d4science.org";
_log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default Email" + toReturn);
return toReturn;
}
_log.debug("Returning SENDER_EMAIL: " + toReturn );
return toReturn;
}
/**
*
* @return $CATALINA_HOME
*/