This commit is contained in:
Nunzio Andrea Galante 2017-07-24 14:50:38 +00:00
parent 0d82f32a3b
commit 02587bf725
3 changed files with 55 additions and 4 deletions

View File

@ -34,6 +34,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-app</artifactId>
<!-- <version>[1.0.0-SNAPSHOT,1.2.7)</version>-->
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>

View File

@ -18,6 +18,8 @@ import org.gcube.dataanalysis.dataminer.poolmanager.util.NotificationHelper;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SVNUpdater;
import org.gcube.dataanalysis.dataminer.poolmanager.util.SendMail;
import org.gcube.dataanalysis.dataminer.poolmanager.util.ServiceConfiguration;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.context.application.ApplicationContext;
public class StagingJob extends DMPMJob {
@ -150,4 +152,6 @@ public class StagingJob extends DMPMJob {
"Target VRE: "+rProtoVREName;
***REMOVED***
***REMOVED***

View File

@ -1,6 +1,8 @@
package org.gcube.dataanalysis.dataminer.poolmanager.util;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.net.URLEncoder;
***REMOVED***
@ -14,11 +16,18 @@ import org.apache.http.util.EntityUtils;
***REMOVED***
import org.gcube.common.authorization.library.AuthorizationEntry;
***REMOVED***
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.ServiceEndpoint;
***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.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.json.JSONArray;
import org.json.JSONObject;
@ -138,6 +147,32 @@ public class SendMail extends StandardLocalInfraAlgorithm {
return s.toString().replace("[", "").replace("]", "");
***REMOVED***
public String getRootToken() throws Exception {
***REMOVED***ApplicationContext ctx = ContextProvider.get(); ***REMOVED*** get this info from
***REMOVED*** SmartGears
***REMOVED***System.out.println(ctx.container().configuration().infrastructure());
String a = "";
SimpleQuery query2 = queryFor(ServiceEndpoint.class);
query2.addCondition("$resource/Profile/Name/text() eq 'SAIService'").setResult("$resource");
DiscoveryClient<ServiceEndpoint> client2 = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> df = client2.submit(query2);
for (ServiceEndpoint b : df) {
a = StringEncrypter.getEncrypter().decrypt(b.profile().accessPoints().iterator().next().password());
***REMOVED***
return a;
***REMOVED***
@Override
public String getDescription() {
***REMOVED*** TODO Auto-generated method stub
@ -169,16 +204,21 @@ public class SendMail extends StandardLocalInfraAlgorithm {
***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");
***REMOVED***ScopeProvider.instance.set("/gcube/devNext");
***REMOVED***SecurityTokenProvider.instance.set("aa6eec71-fe07-43ab-bd1c-f03df293e430-98187548");
NotificationHelper nh = new NotificationHelper();
***REMOVED***NotificationHelper nh = new NotificationHelper();
SendMail sm = new SendMail();
sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("test failed"));
ScopeProvider.instance.set("/gcube/devNext/NextNext");
System.out.println(sm.getRootToken());
***REMOVED***sm.getGenericResourceByName("");
***REMOVED***sm.sendNotification(nh.getFailedSubject(), nh.getFailedBody("test failed"));
***REMOVED*** sm.username(SecurityTokenProvider.instance.get());
***REMOVED***sm.retrieveAdminRole();
***REMOVED***sm.getAdminRoles();