Added the notification manager
diff --git a/allocation-manager/Notification-Manager/Notification-Authenticator/pom.xml b/allocation-manager/Notification-Manager/Notification-Authenticator/pom.xml
new file mode 100644
index 0000000..81875d2
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Authenticator/pom.xml
@@ -0,0 +1,27 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>Notification-Manager</groupId>
+ <artifactId>Notification-Manager</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>Notification-Authenticator</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.thrift</groupId>
+ <artifactId>libthrift</artifactId>
+ <version>0.10.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-allocation-manager-server</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/allocation-manager/Notification-Manager/Notification-Receiver/pom.xml b/allocation-manager/Notification-Manager/Notification-Receiver/pom.xml
new file mode 100644
index 0000000..17e3bf0
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Receiver/pom.xml
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>Notification-Manager</groupId>
+ <artifactId>Notification-Manager</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>Notification-Receiver</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>Notification-Manager</groupId>
+ <artifactId>Notification-Sender</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>Notification-Manager</groupId>
+ <artifactId>Notification-Authenticator</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.amqp</groupId>
+ <artifactId>spring-rabbit</artifactId>
+ <version>1.7.3.RELEASE</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/allocation-manager/Notification-Manager/Notification-Receiver/src/main/java/org/apache/airavata/allocation/manager/notification/receiver/NotificationReceiver.java b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/java/org/apache/airavata/allocation/manager/notification/receiver/NotificationReceiver.java
new file mode 100644
index 0000000..1830128
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/java/org/apache/airavata/allocation/manager/notification/receiver/NotificationReceiver.java
@@ -0,0 +1,51 @@
+package org.apache.airavata.allocation.manager.notification.receiver;
+
+import org.apache.airavata.allocation.manager.notification.authenticator.server.NotificationRequestDetail;
+import org.apache.airavata.allocation.manager.notification.sender.MailNotification;
+import org.apache.thrift.transport.TServerSocket;
+import com.rabbitmq.client.*;
+import com.rabbitmq.client.Consumer;
+import com.rabbitmq.client.Connection;
+import com.rabbitmq.client.Channel;
+
+import java.io.IOException;
+
+public class NotificationReceiver {
+ public static void StartsimpleServer() {
+ try {
+
+ // Create a connection factory
+ ConnectionFactory factory = new ConnectionFactory();
+ // Set the host to the location of the RabbitMQ server
+ factory.setHost("localHost");
+ // Open a new connection
+ Connection connection = factory.newConnection();
+
+ Channel channel = connection.createChannel();
+
+ channel.queueDeclare("notify", false, false, false, null);
+ // Comfort logging
+ System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
+ System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
+
+ Consumer consumer = new DefaultConsumer(channel) {
+ @Override
+ public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
+ byte[] body) throws IOException {
+ String requestID = new String(body, "UTF-8");
+ (new MailNotification()).sendMail(requestID, (new NotificationRequestDetail()).getStatus(requestID),
+ (new NotificationRequestDetail()).getReceiverList(requestID));
+ }
+ };
+ channel.basicConsume("notify", true, consumer);
+
+ } catch (Exception e) {
+ // Dump any error to the console
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ StartsimpleServer();
+ }
+}
diff --git a/allocation-manager/Notification-Manager/Notification-Receiver/src/main/java/org/apache/airavata/allocation/manager/notification/receiver/NotificationSender.java b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/java/org/apache/airavata/allocation/manager/notification/receiver/NotificationSender.java
new file mode 100644
index 0000000..dfa6345
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/java/org/apache/airavata/allocation/manager/notification/receiver/NotificationSender.java
@@ -0,0 +1,44 @@
+package org.apache.airavata.allocation.manager.notification.receiver;
+
+import com.rabbitmq.client.Channel;
+import com.rabbitmq.client.Connection;
+import com.rabbitmq.client.ConnectionFactory;
+
+public class NotificationSender {
+ private final static String QUEUE_NAME = "notify";
+ public static void main(String[] args) {
+
+ try {
+
+ //Create a connection factory
+ ConnectionFactory factory = new ConnectionFactory();
+ //Set the host to the location of the RabbitMQ server
+ factory.setHost("localhost");
+ //Open a new connection
+ Connection connection = factory.newConnection();
+ //Channel is the abstraction for interacting with a queue
+ Channel channel = connection.createChannel();
+ //Create the Queue if it does not exist
+ channel.queueDeclare(QUEUE_NAME, false, false, false, null);
+ //assuming this is the request id send
+ String project_ID = "1001" ;
+
+
+ channel.basicPublish("", QUEUE_NAME, null, project_ID.getBytes());
+
+ System.out.println(
+ " [x] Sent the request");
+
+
+ //Close the channel
+ channel.close();
+ //Close the connection
+ connection.close();
+
+ } catch (Exception e) {
+ //Dump any exception to the console
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/allocation-manager/Notification-Manager/Notification-Receiver/src/main/resources/messages.properties b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/resources/messages.properties
new file mode 100644
index 0000000..694683f
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/resources/messages.properties
@@ -0,0 +1,8 @@
+SUBJECT_APPROVED=Request status
+MESSAGE_APPROVED=The request is approved
+SUBJECT_REJECTED=Request status
+MESSAGE_REJECTED=The request is rejected
+SUBJECT_IN_PROCESS=Request status
+MESSAGE_IN_PROCESS=The request is being processed
+SUBJECT_NEW_REQUEST=Request status
+MESSAGE_NEW_REQUEST=New request is submit
diff --git a/allocation-manager/Notification-Manager/Notification-Sender/pom.xml b/allocation-manager/Notification-Manager/Notification-Sender/pom.xml
new file mode 100644
index 0000000..18f68d4
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Sender/pom.xml
@@ -0,0 +1,32 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>Notification-Manager</groupId>
+ <artifactId>Notification-Manager</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>Notification-Sender</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/models/EmailCredentials.java b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/models/EmailCredentials.java
new file mode 100644
index 0000000..a167e45
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/models/EmailCredentials.java
@@ -0,0 +1,20 @@
+package org.apache.airavata.allocation.manager.notification.models;
+
+public class EmailCredentials {
+ String userName;
+ String password;
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+}
diff --git a/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/models/NotificationMessage.java b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/models/NotificationMessage.java
new file mode 100644
index 0000000..aa6d333
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/models/NotificationMessage.java
@@ -0,0 +1,21 @@
+/*The program in this file works to fetch a notification message for the given status from a resource file*/
+package org.apache.airavata.allocation.manager.notification.models ;
+
+public class NotificationMessage {
+
+ private String subject;
+ private String message;
+
+ public String getSubject() {
+ return subject;
+ }
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/EmailNotificationConfiguration.java b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/EmailNotificationConfiguration.java
new file mode 100644
index 0000000..376aeee
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/EmailNotificationConfiguration.java
@@ -0,0 +1,42 @@
+package org.apache.airavata.allocation.manager.notification.sender;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.airavata.allocation.manager.notification.models.EmailCredentials;
+
+public class EmailNotificationConfiguration {
+public static void main(String args[]) {
+ EmailNotificationConfiguration obj = new EmailNotificationConfiguration();
+
+}
+
+ public EmailCredentials getCredentials()
+ {
+ EmailCredentials result = new EmailCredentials();
+ Properties prop = new Properties();
+ InputStream input = null;
+
+ try {
+ InputStream input2 = new FileInputStream("./config.properties");
+ prop.load(input2);
+
+ result.setUserName(prop.getProperty("username"));
+ result.setPassword(prop.getProperty("password"));
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/EmailNotificationMessage.java b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/EmailNotificationMessage.java
new file mode 100644
index 0000000..06a1083
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/EmailNotificationMessage.java
@@ -0,0 +1,52 @@
+package org.apache.airavata.allocation.manager.notification.sender;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.airavata.allocation.manager.notification.models.NotificationMessage;
+
+public class EmailNotificationMessage {
+ public NotificationMessage getEmailMessage(String status) {
+ NotificationMessage result = new NotificationMessage();
+ Properties prop = new Properties();
+ InputStream input = null;
+
+ try {
+ InputStream input2 = new FileInputStream("./src/main/resources/messages.properties");
+ prop.load(input2);
+
+ switch (status) {
+ case "APRROVED":
+ result.setMessage(prop.getProperty("SUBJECT_APPROVED"));
+ result.setSubject(prop.getProperty("MESSAGE_APPROVED"));
+ break;
+ case "REJECTED":
+ result.setMessage(prop.getProperty("SUBJECT_REJECTED"));
+ result.setSubject(prop.getProperty("MESSAGE_REJECTED"));
+ break;
+ case "IN_PROGRESS":
+ result.setMessage(prop.getProperty("SUBJECT_IN_PROCESS"));
+ result.setSubject(prop.getProperty("MESSAGE_IN_PROCESS"));
+ break;
+ case "NEW_REQUEST":
+ result.setMessage(prop.getProperty("SUBJECT_NEW_REQUEST"));
+ result.setSubject(prop.getProperty("MESSAGE_NEW_REQUEST"));
+ break;
+ }
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/MailNotification.java b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/MailNotification.java
new file mode 100644
index 0000000..a3bfecb
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Sender/src/main/java/org/apache/airavata/allocation/manager/notification/sender/MailNotification.java
@@ -0,0 +1,48 @@
+package org.apache.airavata.allocation.manager.notification.sender;
+
+
+import java.util.ArrayList;
+
+import org.apache.commons.mail.DefaultAuthenticator;
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.SimpleEmail;
+
+public class MailNotification {
+
+ public void sendMail(String requestId, String status, ArrayList<String> senderList) {
+
+ EmailNotificationMessage message = new EmailNotificationMessage();
+ EmailNotificationConfiguration emailConfiguration = new EmailNotificationConfiguration();
+
+ String username = emailConfiguration.getCredentials().getUserName();
+ String password = emailConfiguration.getCredentials().getPassword();
+
+ String subject = message.getEmailMessage(status).getSubject();
+ String body = message.getEmailMessage(status).getMessage();
+
+ mail( username, password, subject, body, senderList);
+
+ }
+
+ public void mail(String username, String password, String subject, String body, ArrayList<String> senderList) {
+ Email email = new SimpleEmail();
+ email.setHostName("smtp.googlemail.com");
+ email.setSmtpPort(465);
+
+ email.setAuthenticator(new DefaultAuthenticator(username, password));
+ email.setSSLOnConnect(true);
+ try {
+ email.setFrom(username);
+ email.setSubject(subject);
+ email.setMsg(body);
+ for(String s : senderList) {
+ email.addTo(s);
+ }
+ email.send();
+ } catch (EmailException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/allocation-manager/Notification-Manager/pom.xml b/allocation-manager/Notification-Manager/pom.xml
new file mode 100644
index 0000000..8f3cdb2
--- /dev/null
+++ b/allocation-manager/Notification-Manager/pom.xml
@@ -0,0 +1,13 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>Notification-Manager</groupId>
+ <artifactId>Notification-Manager</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Notification-Manager</name>
+ <modules>
+ <module>Notification-Receiver</module>
+ <module>Notification-Sender</module>
+ <module>Notification-Authenticator</module>
+ </modules>
+</project>
\ No newline at end of file