You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2017/11/21 01:45:19 UTC

[airavata-sandbox] 02/02: Adding cpi methods

This is an automated email from the ASF dual-hosted git repository.

smarru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-sandbox.git

commit a59f4a991e5f1eb416d6533a3ceac7e16d2414d6
Author: nikchett <ni...@iu.edu>
AuthorDate: Mon Nov 20 19:31:01 2017 -0500

    Adding cpi methods
---
 .../authenticator/NotificationDetails.java         | 23 ++++++++++++++++++++++
 .../receiver/NotificationReceiver.java             |  6 +++---
 .../notification/sender/MailNotification.java      | 11 ++++++-----
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/allocation-manager/Notification-Manager/Notification-Authenticator/src/main/java/org/apache/airavata/allocation/manager/notification/authenticator/NotificationDetails.java b/allocation-manager/Notification-Manager/Notification-Authenticator/src/main/java/org/apache/airavata/allocation/manager/notification/authenticator/NotificationDetails.java
new file mode 100644
index 0000000..b0f3f97
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Authenticator/src/main/java/org/apache/airavata/allocation/manager/notification/authenticator/NotificationDetails.java
@@ -0,0 +1,23 @@
+package org.apache.airavata.allocation.manager.notification.authenticator;
+
+import org.apache.airavata.allocation.manager.server.AllocationManagerServerHandler;
+import org.apache.thrift.TException;
+
+public class NotificationDetails {
+
+	public String[] getRequestDetails(String projectID) {
+		String result[] = new String[2] ;
+		AllocationManagerServerHandler obj  = new AllocationManagerServerHandler();
+		 try {
+			result[0] = obj.getAllocationRequestStatus(projectID);
+			if(result[0].equals("IN_PROCESS")) {
+				result[1] = obj.getAllocationRequestUserName(projectID);
+			}
+		} catch (TException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		return result;
+	}
+}
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
index 1830128..aeb7cb7 100644
--- 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
@@ -1,6 +1,6 @@
 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.authenticator.NotificationDetails;
 import org.apache.airavata.allocation.manager.notification.sender.MailNotification;
 import org.apache.thrift.transport.TServerSocket;
 import com.rabbitmq.client.*;
@@ -33,8 +33,8 @@ public class NotificationReceiver {
 				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));
+					(new MailNotification()).sendMail(requestID, (new NotificationDetails()).getRequestDetails(requestID)[0],
+							(new NotificationDetails()).getRequestDetails(requestID)[1]);
 				}
 			};
 			channel.basicConsume("notify", true, consumer);
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
index a3bfecb..873a502 100644
--- 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
@@ -10,7 +10,7 @@ import org.apache.commons.mail.SimpleEmail;
 
 public class MailNotification {
 
-	public void sendMail(String requestId, String status, ArrayList<String> senderList) {
+	public void sendMail(String requestId, String status, String senderList) {
 
 		EmailNotificationMessage message = new EmailNotificationMessage();
 		EmailNotificationConfiguration emailConfiguration = new EmailNotificationConfiguration();
@@ -25,7 +25,7 @@ public class MailNotification {
 
 	}
 	
-	public void mail(String username, String password, String subject, String body, ArrayList<String> senderList) {
+	public void mail(String username, String password, String subject, String body, String senderList) {
 		Email email = new SimpleEmail();
 		email.setHostName("smtp.googlemail.com");
 		email.setSmtpPort(465);
@@ -36,9 +36,10 @@ public class MailNotification {
 			email.setFrom(username);
 			email.setSubject(subject);
 			email.setMsg(body);
-			for(String s : senderList) {
-				email.addTo(s);
-			}
+//			for(String s : senderList) {
+//				email.addTo(s);
+//			}
+			email.addTo(senderList);
 			email.send();
 		} catch (EmailException e) {
 			// TODO Auto-generated catch block

-- 
To stop receiving notification emails like this one, please contact
"commits@airavata.apache.org" <co...@airavata.apache.org>.