diff --git a/pom.xml b/pom.xml
index 6f7a41f..5924f75 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,11 @@
+
+ org.json
+ json
+ 20090211
+
org.tmatesoft.svnkit
diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java
index 5851ef0..e7a4b2b 100644
--- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java
+++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java
@@ -87,8 +87,8 @@ public class RestPoolManager implements PoolManager {
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab");
***REMOVED*** SecurityTokenProvider.instance.set("708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548");
- ***REMOVED***AuthorizationEntry entry = authorizationService().get("708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548");
- ***REMOVED***System.out.println(entry.getContext());
+***REMOVED*** AuthorizationEntry entry = authorizationService().get("708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548");
+***REMOVED*** System.out.println(entry.getContext());
RestPoolManager a = new RestPoolManager();
diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java
index 91ce468..bca4fd7 100644
--- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java
+++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/service/StagingJob.java
@@ -9,6 +9,7 @@ import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.util.CheckMethod;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
+import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
import org.gcube.dataanalysis.dataminer.poolmanager.util.ServiceConfiguration;
public class StagingJob extends DMPMJob {
@@ -36,35 +37,32 @@ public class StagingJob extends DMPMJob {
protected void execute() {
ServiceConfiguration a = new ServiceConfiguration();
CheckMethod b = new CheckMethod();
+ SendMail sm = new SendMail();
+
try {
- if (this.svnUpdater.checkIfAvaialable(this.algorithm.getLanguage(), this.algorithm.getDependencies())) {
+ this.svnUpdater.readRPRotoDeps(this.algorithm);
int ret = this.executeAnsibleWorker(createWorker(this.algorithm, this.stagingCluster, false, "root"));
-
-
-
if (ret == 0) {
if (b.checkMethod(a.getStagingHost(), SecurityTokenProvider.instance.get())
&& (b.algoExists(this.algorithm))) {
+ sm.sendNotification("", "");
***REMOVED*** this.svnUpdater.updateRPRotoDeps(this.algorithm);
this.svnUpdater.updateSVNRProtoAlgorithmList(this.algorithm, this.rProtoVREName,
this.algorithm.getFullname(), "Proto");
-
-
-
-
+
***REMOVED*** int ret2 = this.executeAnsibleWorker(
***REMOVED*** createWorker(this.algorithm, this.rProtoCluster,
***REMOVED*** false, "gcube"));
***REMOVED***
***REMOVED***
- ***REMOVED***
+ else sm.sendNotification("", "");
***REMOVED*** catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/NotificationHelper.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/NotificationHelper.java
index 1925509..f13d8b2 100644
--- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/NotificationHelper.java
+++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/NotificationHelper.java
@@ -33,7 +33,7 @@ public class NotificationHelper {
***REMOVED***
private String getSubjectHeader() {
- return "[[DataMinerGhostInstallationRequestReport]]";
+ return "[DataMinerGhostInstallationRequestReport]";
***REMOVED***
private String getSpecificVREName() {
diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java
index f6925a2..f0d3d96 100644
--- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java
+++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SVNUpdater.java
@@ -190,6 +190,9 @@ public class SVNUpdater {
public boolean checkIfAvaialable(String file, Collection deps) throws SVNException {
+ SendMail sm = new SendMail();
+ NotificationHelper nh = new NotificationHelper();
+
boolean check = false;
try{
System.out.println("Checking dependencies list: " + file);
@@ -198,9 +201,8 @@ public class SVNUpdater {
String lines[] = byteArrayOutputStream.toString().split("\\r?\\n");
if(deps.isEmpty()){
- SendMail sm = new SendMail();
- NotificationHelper nh = new NotificationHelper();
- sm.sendNotification(nh.getSubject(), nh.getBody());
+ Exception e = new Exception("No dependency specified for this algorithm");
+ throw e;
***REMOVED***
@@ -216,6 +218,8 @@ public class SVNUpdater {
check = true;
***REMOVED*** else
check = false;
+ Exception e = new Exception("One or more of the following dependencies are not correctly written: "+b);
+ throw e;
***REMOVED***
***REMOVED***
***REMOVED***
diff --git a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SendMail.java b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SendMail.java
index 2d82840..86b5e15 100644
--- a/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SendMail.java
+++ b/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/util/SendMail.java
@@ -1,14 +1,24 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util;
+import static org.gcube.common.authorization.client.Constants.authorizationService;
+
import java.net.URLEncoder;
+***REMOVED***
+***REMOVED***
import org.apache.activemq.transport.stomp.Stomp.Headers.Send;
***REMOVED***
+import org.gcube.common.authorization.library.AuthorizationEntry;
+***REMOVED***
***REMOVED***
import org.gcube.contentmanagement.graphtools.utils.HttpRequest;
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
import org.gcube.dataanalysis.ecoengine.interfaces.StandardLocalInfraAlgorithm;
import org.gcube.dataanalysis.executor.util.InfraRetrieval;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
public class SendMail extends StandardLocalInfraAlgorithm {
@@ -30,11 +40,13 @@ public void sendNotification(String subject, String body) throws Exception {
AnalysisLogger.getLogger().debug("Emailing System->Request url is going to be " + requestForMessage);
+
***REMOVED*** put the sender, the recipients, subject and body of the mail here
subject=URLEncoder.encode(subject,"UTF-8");
body=URLEncoder.encode(body,"UTF-8");
- String requestParameters = "sender=dataminer&recipients="+SecurityTokenProvider.instance.get()+"&subject="+subject+"&body="+body;
-
+ String requestParameters = "&sender=dataminer&recipients="+this.getAdmins()+"&subject="+subject+"&body="+body;
+
+
String response = HttpRequest.sendPostRequest(requestForMessage, requestParameters);
AnalysisLogger.getLogger().debug("Emailing System->Emailing response OK ");
@@ -52,6 +64,63 @@ public void sendNotification(String subject, String body) throws Exception {
+ public String username(String token) throws ObjectNotFound, Exception{
+ AuthorizationEntry entry = authorizationService().get(token);
+ System.out.println(entry.getClientInfo().getId());
+ return entry.getClientInfo().getId();
+
+***REMOVED***
+
+
+
+
+
+
+
+ public String retrieveAdminRole() throws Exception{
+ String serviceAddress = InfraRetrieval.findEmailingSystemAddress(ScopeProvider.instance.get());
+
+ if (!serviceAddress.endsWith("/"))
+ serviceAddress = serviceAddress+"/";
+
+ String requestForMessage = serviceAddress + "2/users/get-usernames-by-global-role";
+ requestForMessage = requestForMessage.replace("https:***REMOVED***", "http:***REMOVED***").replace(":80", ""); ***REMOVED*** remove the port (or set it to 443) otherwise you get an SSL error
+ String requestParameters = "role-name=Administrator"+"&gcube-token=" + SecurityTokenProvider.instance.get();
+
+ String response = HttpRequest.sendGetRequest(requestForMessage,requestParameters);
+ System.out.println(response.toString());
+
+ if (response==null){
+ Exception e = new Exception("Error in querying the recipient");
+ throw e;
+ ***REMOVED***
+ return response;
+
+
+***REMOVED***
+
+
+
+ public String getAdmins() throws Exception {
+ List s = new LinkedList();
+ JSONObject obj = new JSONObject(this.retrieveAdminRole());
+ JSONArray data = obj.getJSONArray("result");
+ if (data != null) {
+ String[] names = new String[data.length()];
+ for (int i = 0; i < data.length(); i++) {
+ names[i] = data.getString(i);
+ s.add(names[i]);
+ ***REMOVED***
+ s.add(this.username(SecurityTokenProvider.instance.get()));
+ ***REMOVED***
+
+ System.out.println(s);
+ return s.toString();
+***REMOVED***
+
+
+
+
@Override
public String getDescription() {
***REMOVED*** TODO Auto-generated method stub
@@ -91,11 +160,20 @@ public void sendNotification(String subject, String body) throws Exception {
***REMOVED***
public static void main(String[] args) throws Exception {
- ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab");
- SecurityTokenProvider.instance.set("3a23bfa4-4dfe-44fc-988f-194b91071dd2-843339462");
+***REMOVED*** ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab");
+***REMOVED*** SecurityTokenProvider.instance.set("3a23bfa4-4dfe-44fc-988f-194b91071dd2-843339462");
+ ScopeProvider.instance.set("/gcube/devNext");
+ SecurityTokenProvider.instance.set("708e7eb8-11a7-4e9a-816b-c9ed7e7e99fe-98187548");
+
+
+
NotificationHelper nh = new NotificationHelper();
+
SendMail sm = new SendMail();
- sm.sendNotification(nh.getSubject(), nh.getBody());
+ ***REMOVED***sm.username(SecurityTokenProvider.instance.get());
+ ***REMOVED***sm.retrieveAdminRole();
+ sm.getAdmins();
+ ***REMOVED***sm.sendNotification("test", "test");
***REMOVED***
***REMOVED***