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/29 14:15:26 UTC
[airavata-sandbox] branch master updated: Adding initial part of
micro service admin (#18)
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
The following commit(s) were added to refs/heads/master by this push:
new 1ab0e6b Adding initial part of micro service admin (#18)
1ab0e6b is described below
commit 1ab0e6b78a4c77489331c13a3048bce2e19b129e
Author: nikchett <ni...@iu.edu>
AuthorDate: Wed Nov 29 09:15:24 2017 -0500
Adding initial part of micro service admin (#18)
* Added cpi methods
* Adding cpi methods
* Adding new admin related project
* Update README
---
.../authenticator/NotificationDetails.java | 21 +++++++++----
.../models/NotificationInformation.java | 21 +++++++++++++
.../receiver/NotificationReceiver.java | 7 +++--
.../src/main/resources/messages.properties | 2 +-
.../notification/sender/MailNotification.java | 16 +++++-----
allocation-manager/README | 35 ++++++++++++++++++++++
.../airavata-allocation-admin/pom.xml | 7 +++++
.../db/repositories/UserDetailRepository.java | 23 +++++++++-----
.../allocation/manager/db/utils/DBConstants.java | 8 +++++
.../server/AllocationManagerServerHandler.java | 9 ++++++
10 files changed, 126 insertions(+), 23 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
index b0f3f97..e2d693b 100644
--- 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
@@ -1,18 +1,27 @@
package org.apache.airavata.allocation.manager.notification.authenticator;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.airavata.allocation.manager.notification.models.NotificationInformation;
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] ;
+ public NotificationInformation getRequestDetails(String projectID) {
+ NotificationInformation result = new NotificationInformation() ;
AllocationManagerServerHandler obj = new AllocationManagerServerHandler();
try {
- result[0] = obj.getAllocationRequestStatus(projectID);
- if(result[0].equals("IN_PROCESS")) {
- result[1] = obj.getAllocationRequestUserName(projectID);
- }
+ String status = obj.getAllocationRequestStatus(projectID);
+
+ List<String>senderList = new ArrayList<String>() ;
+
+ senderList.add(obj.getAllocationRequestUserName(projectID));
+ senderList.add(obj.getAllocationRequestAdminEmail());
+
+ result.setStatus(status);
+
} catch (TException e) {
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/allocation-manager/Notification-Manager/Notification-Authenticator/src/main/java/org/apache/airavata/allocation/manager/notification/models/NotificationInformation.java b/allocation-manager/Notification-Manager/Notification-Authenticator/src/main/java/org/apache/airavata/allocation/manager/notification/models/NotificationInformation.java
new file mode 100644
index 0000000..e501a42
--- /dev/null
+++ b/allocation-manager/Notification-Manager/Notification-Authenticator/src/main/java/org/apache/airavata/allocation/manager/notification/models/NotificationInformation.java
@@ -0,0 +1,21 @@
+package org.apache.airavata.allocation.manager.notification.models;
+
+import java.util.List;
+
+public class NotificationInformation {
+
+ private String status;
+ List<String> SenderList;
+ public String getStatus() {
+ return status;
+ }
+ public void setStatus(String status) {
+ this.status = status;
+ }
+ public List<String> getSenderList() {
+ return SenderList;
+ }
+ public void setSenderList(List<String> senderList) {
+ SenderList = senderList;
+ }
+ }
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 aeb7cb7..5297050 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,7 @@
package org.apache.airavata.allocation.manager.notification.receiver;
import org.apache.airavata.allocation.manager.notification.authenticator.NotificationDetails;
+import org.apache.airavata.allocation.manager.notification.models.NotificationInformation;
import org.apache.airavata.allocation.manager.notification.sender.MailNotification;
import org.apache.thrift.transport.TServerSocket;
import com.rabbitmq.client.*;
@@ -33,8 +34,10 @@ 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 NotificationDetails()).getRequestDetails(requestID)[0],
- (new NotificationDetails()).getRequestDetails(requestID)[1]);
+
+ NotificationInformation information = (new NotificationDetails()).getRequestDetails(requestID);
+ (new MailNotification()).sendMail(requestID, information.getStatus(), information.getSenderList());
+
}
};
channel.basicConsume("notify", true, consumer);
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
index 694683f..b490727 100644
--- a/allocation-manager/Notification-Manager/Notification-Receiver/src/main/resources/messages.properties
+++ b/allocation-manager/Notification-Manager/Notification-Receiver/src/main/resources/messages.properties
@@ -3,6 +3,6 @@ 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
+MESSAGE_IN_PROCESS=The new request has been submitted and 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/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 873a502..ddc9a1e 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
@@ -1,7 +1,7 @@
package org.apache.airavata.allocation.manager.notification.sender;
-import java.util.ArrayList;
+import java.util.List;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
@@ -10,7 +10,8 @@ import org.apache.commons.mail.SimpleEmail;
public class MailNotification {
- public void sendMail(String requestId, String status, String senderList) {
+
+ public void sendMail(String requestId, String status, List<String> senderList) {
EmailNotificationMessage message = new EmailNotificationMessage();
EmailNotificationConfiguration emailConfiguration = new EmailNotificationConfiguration();
@@ -25,7 +26,7 @@ public class MailNotification {
}
- public void mail(String username, String password, String subject, String body, String senderList) {
+ public void mail(String username, String password, String subject, String body, List<String> senderList) {
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
@@ -36,10 +37,11 @@ public class MailNotification {
email.setFrom(username);
email.setSubject(subject);
email.setMsg(body);
-// for(String s : senderList) {
-// email.addTo(s);
-// }
- email.addTo(senderList);
+
+ for(String s : senderList) {
+ email.addTo(s);
+ }
+
email.send();
} catch (EmailException e) {
// TODO Auto-generated catch block
diff --git a/allocation-manager/README b/allocation-manager/README
index d39c433..bcf263e 100644
--- a/allocation-manager/README
+++ b/allocation-manager/README
@@ -1 +1,36 @@
The Allocation Manager enables tenant gateways define allocation policies and available resources. Users of gateways (typically researchers and educators) can request appropriate resources to accomplish their research objectives by providing a justification.
+Notification Manager. https://issues.apache.org/jira/browse/AIRAVATA-1893
+
+The allocation manager feauture consists of three types of users:
+* User - Requests for an allocation
+* Reviewer - reviews the request and makes decision for allocation
+* Admin - Initiates and manages the review process
+
+The airvata-allocation-manager is a multi-module consists of the the following modules:
+* airvata-allocation-manager-server - This consists of details of the database connections and the entity classes.
+* airvata-allocation-manager-stubs - This consists of the models which represent the database table entities and also the servicehandler.
+The service handler (AllocationManagerServerHandler) functions interact with the database repository functions.
+
+Currently, the implementation consists of a notification- manager
+
+The notification manager of Allocation manager performs the functions of notifying the user/admin/reviewer the status of a request.
+* Send notification/email to admin, reviewers about a new process.
+* Notify updates of the requests to the users.
+
+Implemenation of the notification - manager is as follows:
+
+The notification manager is a maven multi module project. The modules are as follows:
+
+* Notification-Receiver - This module accepts the request from a microservice. The request sent is the Project ID.
+ The project id is queued using the RabbitMq message broker. The project ID is accepted and forwarded to then Notification-Authenticator Module.
+
+
+ * Notification-Authenticator - This module consists of the methods which connecg to the database through Apache Thrift. The NotificationDetails.java
+ consists of methods which calls the functions in the AllocationManagerServerHandler which connect to database functions and fetch the necessary details.
+
+ * Notification-Sender - This module contains method which is called by the Notification-Receiver. The method sends email to the specified sender.
+ The method reads messages to be sent to the user from a messages.properties resource file. The email server details should be stored in a
+ config.properties file which should be stored directly under the Notification-Receiver project.
+
+
+
diff --git a/allocation-manager/airavata-allocation-admin/pom.xml b/allocation-manager/airavata-allocation-admin/pom.xml
new file mode 100644
index 0000000..c66ecfe
--- /dev/null
+++ b/allocation-manager/airavata-allocation-admin/pom.xml
@@ -0,0 +1,7 @@
+<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>org.apache.airavata</groupId>
+ <artifactId>airavata-allocation-admin</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>airavata-allocation-admin</name>
+</project>
\ No newline at end of file
diff --git a/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java b/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java
index c05ff5c..9e71b71 100644
--- a/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java
+++ b/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/repositories/UserDetailRepository.java
@@ -1,19 +1,28 @@
package org.apache.airavata.allocation.manager.db.repositories;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.airavata.allocation.manager.db.entities.UserDetailEntity;
+import org.apache.airavata.allocation.manager.db.utils.DBConstants;
import org.apache.airavata.allocation.manager.models.UserDetail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserDetailRepository extends AbstractRepository<UserDetail, UserDetailEntity, String> {
- private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+ private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
- public UserDetailRepository(){
- super(UserDetail.class, UserDetailEntity.class);
- }
+ public UserDetailRepository() {
+ super(UserDetail.class, UserDetailEntity.class);
+ }
- public static void main(String args[])
- {
+ public UserDetail getAdminDetails() throws Exception {
+ String userType = "ADMIN";
+ String queryString = "SELECT * FROM " + UserDetailEntity.class.getSimpleName() + "WHERE"
+ + DBConstants.UserDetailTable.USERTYPE + "=" + userType;
+ Map<String, Object> queryParameters = new HashMap<>();
+ queryParameters.put(DBConstants.UserDetailTable.USERTYPE, userType);
- }
+ return (UserDetail) select(queryString, queryParameters, 0, -1);
+ }
}
\ No newline at end of file
diff --git a/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/utils/DBConstants.java b/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/utils/DBConstants.java
index 1de1363..749fb40 100644
--- a/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/utils/DBConstants.java
+++ b/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/db/utils/DBConstants.java
@@ -103,4 +103,12 @@ public class DBConstants {
public static final String CREATED_TIME = "createdTime";
public static final String UPDATED_TIME = "updatedTime";
}
+ // Added the UserDetail table fields
+ public static class UserDetailTable {
+ public static final String USERNAME = "username";
+ public static final String EMAIL = "email";
+ public static final String FULLNAME = "fullName";
+ public static final String PASSWORD = "password";
+ public static final String USERTYPE = "userType";
+ }
}
\ No newline at end of file
diff --git a/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/server/AllocationManagerServerHandler.java b/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/server/AllocationManagerServerHandler.java
index fe6fb22..b6c9ee8 100644
--- a/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/server/AllocationManagerServerHandler.java
+++ b/allocation-manager/airavata-allocation-manager/airavata-allocation-manager-server/src/main/java/org/apache/airavata/allocation/manager/server/AllocationManagerServerHandler.java
@@ -52,4 +52,13 @@ public class AllocationManagerServerHandler implements AllocationRegistryService
throw new Exception("Could not get project status");
}
}
+
+ public String getAllocationRequestAdminEmail() throws org.apache.thrift.TException{
+ try{
+ return (new UserDetailRepository()).getAdminDetails().getEmail();
+
+ }catch (Throwable ex) {
+ throw new Exception("Could not get project status");
+ }
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
['"commits@airavata.apache.org" <co...@airavata.apache.org>'].