diff --git a/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java b/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java index c8f460f..ed03135 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java @@ -13,9 +13,16 @@ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; + +import org.apache.axis.message.addressing.EndpointReferenceType; +import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.faults.GCUBEFault; +import org.gcube.common.core.informationsystem.client.AtomicCondition; +import org.gcube.common.core.informationsystem.client.ISClient; +import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery; import org.gcube.common.core.resources.GCUBECollection; import org.gcube.common.core.resources.GCUBEMCollection; +import org.gcube.common.core.resources.GCUBERunningInstance; import org.gcube.common.core.resources.impl.kxml.KGCUBEResource; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl; @@ -69,7 +76,7 @@ public class DeployVRE extends Thread{ while (resRelatedGHN.next()) GHNList.add(resRelatedGHN.getString(1)); deployManagerOnVRE(firstGHNId); - createVRE(GHNList); + createVRE(GHNList, firstGHNId); logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED"); }catch(Exception e){ logger.error("Error deploying the VRE with id "+this.resourceId+" "+e); @@ -147,9 +154,29 @@ public class DeployVRE extends Thread{ } - private void createVRE(List ghnList) throws GCUBEFault{ + private void createVRE(List ghnList, String ghnId) throws GCUBEFault{ VREManagerServiceHandler, String>> vreManagerHandler= new VREManagerServiceHandler, String>>(){ + + @Override + protected List findInstances() throws Exception { + System.out.println("findinstance called"); + try{ + ISClient client = GHNContext.getImplementation(ISClient.class); + GCUBERIQuery query = client.getQuery(GCUBERIQuery.class); + query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"), new AtomicCondition("/Profile/GHN/@UniqueID", this.relatedGhnId)); + + List eprs = new ArrayList(); + for (GCUBERunningInstance instance : client.execute(query, scope)) + eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager")); + System.out.println("EPRs: "); + for (EndpointReferenceType epr: eprs) + System.out.println(epr); + return eprs; + }catch(Exception e){e.printStackTrace(); throw e;} + } + + //the parameter is resourceID @SuppressWarnings("static-access") @Override @@ -269,6 +296,7 @@ public class DeployVRE extends Thread{ }; vreManagerHandler.clearState(); + vreManagerHandler.relatedGhnId=ghnId; vreManagerHandler.setHandled(new GCUBEServiceClientImpl()); vreManagerHandler.setParameter(new Couple, String>(ghnList,this.resourceId)); vreManagerHandler.scope=GCUBEScope.getScope(this.startingScope+"/"+this.vreName); diff --git a/src/org/gcube/vremanagement/vremodeler/impl/util/VREManagerServiceHandler.java b/src/org/gcube/vremanagement/vremodeler/impl/util/VREManagerServiceHandler.java index 68854ae..1e7ad4b 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/util/VREManagerServiceHandler.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/util/VREManagerServiceHandler.java @@ -24,6 +24,7 @@ public abstract class VREManagerServiceHandler extends GCUBEServiceHandler private P parameter; public GCUBEScope scope= ServiceContext.getContext().getScope(); + public String relatedGhnId= null; public T getReturnValue(){ return returnValue; @@ -48,7 +49,7 @@ public abstract class VREManagerServiceHandler extends GCUBEServiceHandler try{ ISClient client = GHNContext.getImplementation(ISClient.class); GCUBERIQuery query = client.getQuery(GCUBERIQuery.class); - query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager")); + query.apublic String relatedGhnId;ddAtomicConditions(new AtomicCondition("//ServiceName", "VREManager")); List eprs = new ArrayList(); for (GCUBERunningInstance instance : client.execute(query, scope)) eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));