git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@6483 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
63ad88d371
commit
3a0a4da776
|
@ -17,12 +17,24 @@
|
||||||
<Service>
|
<Service>
|
||||||
<Class>VREManagement</Class>
|
<Class>VREManagement</Class>
|
||||||
<Name>VREModeler</Name>
|
<Name>VREModeler</Name>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
</Service>
|
</Service>
|
||||||
<Package>VREModeler-stubs</Package>
|
<Package>VREModeler-stubs</Package>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<Scope level="GHN"/>
|
<Scope level="GHN"/>
|
||||||
<Optional>false</Optional>
|
<Optional>false</Optional>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
|
<Dependency>
|
||||||
|
<Service>
|
||||||
|
<Class>VREManagement</Class>
|
||||||
|
<Name>VREManager</Name>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</Service>
|
||||||
|
<Package>VREManager-stubs</Package>
|
||||||
|
<Version>1.00.02</Version>
|
||||||
|
<Scope level="GHN"/>
|
||||||
|
<Optional>false</Optional>
|
||||||
|
</Dependency>
|
||||||
</Dependencies>
|
</Dependencies>
|
||||||
<GARArchive>org.gcube.vremanagement.vremodeler.gar</GARArchive>
|
<GARArchive>org.gcube.vremanagement.vremodeler.gar</GARArchive>
|
||||||
<PortType>
|
<PortType>
|
||||||
|
|
|
@ -3,9 +3,13 @@ package org.gcube.vremanagement.vremodeler.impl;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.rpc.ServiceException;
|
||||||
|
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
import org.gcube.common.core.contexts.GHNContext;
|
||||||
import org.gcube.common.core.faults.GCUBEFault;
|
import org.gcube.common.core.faults.GCUBEFault;
|
||||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||||
|
@ -14,6 +18,7 @@ import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
||||||
import org.gcube.common.core.resources.GCUBECollection;
|
import org.gcube.common.core.resources.GCUBECollection;
|
||||||
import org.gcube.common.core.resources.GCUBEMCollection;
|
import org.gcube.common.core.resources.GCUBEMCollection;
|
||||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||||
|
import org.gcube.common.core.resources.impl.kxml.KGCUBEResource;
|
||||||
import org.gcube.common.core.types.VOID;
|
import org.gcube.common.core.types.VOID;
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.AddResourcesParameters;
|
import org.gcube.vremanagement.vremanager.stubs.vremanager.AddResourcesParameters;
|
||||||
|
@ -60,7 +65,7 @@ public class ModelerService {
|
||||||
{
|
{
|
||||||
dateFrom=new Date(request.getStartTime());
|
dateFrom=new Date(request.getStartTime());
|
||||||
dateTo=new Date(request.getEndTime());
|
dateTo=new Date(request.getEndTime());
|
||||||
DBInterface.queryDB("update VRE set name='"+request.getVREName()+"', description='"+request.getVREDescription()+"', dldesigner='"+request.getVREDesigner()+"', dlmanager= '"+request.getVREManager()+"', intervalfrom='"+dateFrom+"', intervalto='"+dateTo+"' where DL.id='"+getResource().getID()+"'; ");
|
DBInterface.queryDB("update VRE set name='"+request.getVREName()+"', description='"+request.getVREDescription()+"', vredesigner='"+request.getVREDesigner()+"', vremanager= '"+request.getVREManager()+"', intervalfrom='"+dateFrom+"', intervalto='"+dateTo+"' where VRE.id='"+getResource().getID()+"'; ");
|
||||||
}else{
|
}else{
|
||||||
dateFrom=new Date(request.getStartTime());
|
dateFrom=new Date(request.getStartTime());
|
||||||
dateTo=new Date(request.getEndTime());
|
dateTo=new Date(request.getEndTime());
|
||||||
|
@ -447,6 +452,7 @@ public class ModelerService {
|
||||||
* @throws RemoteException -
|
* @throws RemoteException -
|
||||||
*/
|
*/
|
||||||
public void deployVRE(VOID var) throws GCUBEFault{
|
public void deployVRE(VOID var) throws GCUBEFault{
|
||||||
|
boolean contactedVRE= false;
|
||||||
try {
|
try {
|
||||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+getResource().getId()+"';");
|
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+getResource().getId()+"';");
|
||||||
} catch (ResourceException e1) {
|
} catch (ResourceException e1) {
|
||||||
|
@ -455,51 +461,71 @@ public class ModelerService {
|
||||||
|
|
||||||
VREManagerServiceAddressingLocator vreManAL= new VREManagerServiceAddressingLocator();
|
VREManagerServiceAddressingLocator vreManAL= new VREManagerServiceAddressingLocator();
|
||||||
VREManagerPortType vreManagerPT= null;
|
VREManagerPortType vreManagerPT= null;
|
||||||
try {
|
|
||||||
|
List<GCUBERunningInstance> ris= null;
|
||||||
|
try{
|
||||||
ISClient client= GHNContext.getImplementation(ISClient.class);
|
ISClient client= GHNContext.getImplementation(ISClient.class);
|
||||||
GCUBERIQuery query=client.getQuery(GCUBERIQuery.class);
|
GCUBERIQuery query=client.getQuery(GCUBERIQuery.class);
|
||||||
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
|
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
|
||||||
query.addAtomicConditions(new AtomicCondition("//ServiceClass", "VREManagement"));
|
query.addAtomicConditions(new AtomicCondition("//ServiceClass", "VREManagement"));
|
||||||
List<GCUBERunningInstance> ris= client.execute(query, ServiceContext.getContext().getScope());
|
ris = client.execute(query, ServiceContext.getContext().getScope());
|
||||||
|
}catch (Exception e) { logger.error("Error Excecuting Query"); throw new GCUBEFault(e);}
|
||||||
|
|
||||||
|
String resourceID;
|
||||||
|
try {
|
||||||
|
resourceID = getResource().getId();
|
||||||
|
} catch (ResourceException e) {
|
||||||
|
logger.error("Error retrieving the Resource Query"); throw new GCUBEFault(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (GCUBERunningInstance ri: ris){
|
for (GCUBERunningInstance ri: ris){
|
||||||
try{
|
try{
|
||||||
vreManagerPT=vreManAL.getVREManagerPortTypePort(ri.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
|
vreManagerPT=vreManAL.getVREManagerPortTypePort(ri.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
|
||||||
|
|
||||||
|
OptionsParameters ops;
|
||||||
|
try{
|
||||||
|
ResultSet resGenericInfo=DBInterface.queryDB("select * from VRE where VRE.id='"+resourceID+"'; ");
|
||||||
|
|
||||||
|
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+resourceID+" cannot be retrieved");
|
||||||
//TODO: set properties values
|
//TODO: set properties values
|
||||||
OptionsParameters ops=new OptionsParameters();
|
ops=new OptionsParameters();
|
||||||
ScopeOption[] scopeOptionList= new ScopeOption[6];
|
ScopeOption[] scopeOptionList= new ScopeOption[6];
|
||||||
ScopeOption soDesigner= new ScopeOption();
|
ScopeOption soDesigner= new ScopeOption();
|
||||||
soDesigner.setName("DESIGNER");
|
soDesigner.setName("DESIGNER");
|
||||||
|
soDesigner.setValue(resGenericInfo.getString("vredesigner"));
|
||||||
scopeOptionList[0]= soDesigner;
|
scopeOptionList[0]= soDesigner;
|
||||||
|
|
||||||
ScopeOption soCreator= new ScopeOption();
|
ScopeOption soCreator= new ScopeOption();
|
||||||
soCreator.setName("CREATOR");
|
soCreator.setName("CREATOR");
|
||||||
|
soCreator.setValue(resGenericInfo.getString("vremanager"));
|
||||||
scopeOptionList[1]= soCreator;
|
scopeOptionList[1]= soCreator;
|
||||||
|
|
||||||
ScopeOption soEndtime= new ScopeOption();
|
ScopeOption soEndtime= new ScopeOption();
|
||||||
soEndtime.setName("ENDTIME");
|
soEndtime.setName("ENDTIME");
|
||||||
|
soEndtime.setValue(KGCUBEResource.toXMLDateAndTime(resGenericInfo.getDate("IntervalTo")));
|
||||||
scopeOptionList[2]= soEndtime;
|
scopeOptionList[2]= soEndtime;
|
||||||
|
|
||||||
ScopeOption soStarttime= new ScopeOption();
|
ScopeOption soStarttime= new ScopeOption();
|
||||||
soStarttime.setName("STARTTIME");
|
soStarttime.setName("STARTTIME");
|
||||||
|
soStarttime.setValue(KGCUBEResource.toXMLDateAndTime(resGenericInfo.getDate("IntervalFrom")));
|
||||||
scopeOptionList[3]= soStarttime;
|
scopeOptionList[3]= soStarttime;
|
||||||
|
|
||||||
ScopeOption soDescription= new ScopeOption();
|
ScopeOption soDescription= new ScopeOption();
|
||||||
soDescription.setName("DESCRIPTION");
|
soDescription.setName("DESCRIPTION");
|
||||||
|
soDescription.setValue(resGenericInfo.getString("description"));
|
||||||
scopeOptionList[4]= soDescription;
|
scopeOptionList[4]= soDescription;
|
||||||
|
|
||||||
ScopeOption soDisplayname= new ScopeOption();
|
ScopeOption soDisplayname= new ScopeOption();
|
||||||
soDisplayname.setName("DISPLAYNAME");
|
soDisplayname.setName("DISPLAYNAME");
|
||||||
|
soDisplayname.setValue(resGenericInfo.getString("name"));
|
||||||
scopeOptionList[5]= soDisplayname;
|
scopeOptionList[5]= soDisplayname;
|
||||||
|
|
||||||
ops.setScopeOptionList(scopeOptionList);
|
ops.setScopeOptionList(scopeOptionList);
|
||||||
|
}catch(SQLException e) {logger.error("cannot retreive the VRE"); throw new GCUBEFault(e);}
|
||||||
|
//sending scope options
|
||||||
vreManagerPT.setScopeOptions(ops);
|
vreManagerPT.setScopeOptions(ops);
|
||||||
|
|
||||||
//ResourceItem resItem= new ResourceItem();
|
|
||||||
|
|
||||||
AddResourcesParameters arp= new AddResourcesParameters();
|
AddResourcesParameters arp= new AddResourcesParameters();
|
||||||
ResourceList rl= new ResourceList();
|
ResourceList rl= new ResourceList();
|
||||||
|
@ -507,41 +533,38 @@ public class ModelerService {
|
||||||
ResourceItem resItem= null;
|
ResourceItem resItem= null;
|
||||||
|
|
||||||
//retrieving Collection
|
//retrieving Collection
|
||||||
ResultSet resRelatedCol =DBInterface.queryDB("select DLRELATEDCOLLECTION.collid from DLRELATEDCOLLECTION where DLRELATEDCOLLECTION.dlid='"+getResource().getId()+"';");
|
try{
|
||||||
|
ResultSet resRelatedCol =DBInterface.queryDB("select VRERELATEDCOLLECTION.collid from VRERELATEDCOLLECTION where VRERELATEDCOLLECTION.dlid='"+resourceID+"';");
|
||||||
while (resRelatedCol.next()){
|
while (resRelatedCol.next()){
|
||||||
resItem= new ResourceItem();
|
resItem= new ResourceItem();
|
||||||
resItem.setID(resRelatedCol.getString(1));
|
resItem.setID(resRelatedCol.getString(1));
|
||||||
resItem.setType(GCUBECollection.TYPE);
|
resItem.setType(GCUBECollection.TYPE);
|
||||||
|
resItemList.add(resItem);
|
||||||
}
|
}
|
||||||
|
}catch(SQLException sqle){logger.error("Error contacting HSQLDB");}
|
||||||
|
|
||||||
|
/*
|
||||||
ResultSet resRelatedMetadataCol =DBInterface.queryDB("select VRERELATEDCOLLECTION.collid from DLRELATEDCOLLECTION where VRERELATEDCOLLECTION.dlid='"+getResource().getId()+"';");
|
ResultSet resRelatedMetadataCol =DBInterface.queryDB("select VRERELATEDCOLLECTION.collid from DLRELATEDCOLLECTION where VRERELATEDCOLLECTION.dlid='"+getResource().getId()+"';");
|
||||||
while (resRelatedCol.next()){
|
while (resRelatedCol.next()){
|
||||||
resItem= new ResourceItem();
|
resItem= new ResourceItem();
|
||||||
resItem.setID(resRelatedCol.getString(1));
|
resItem.setID(resRelatedCol.getString(1));
|
||||||
resItem.setType(GCUBEMCollection.TYPE);
|
resItem.setType(GCUBEMCollection.TYPE);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
contactedVRE= true;
|
||||||
|
}catch(RemoteException re){logger.warn("Error Contacting VREManager, trying next RI"); contactedVRE= false;}
|
||||||
|
catch(ServiceException se1){logger.warn("Error Contacting VREManager, trying next RI"); contactedVRE= false;}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!contactedVRE) {
|
||||||
//retrieving MetadataCollection
|
logger.error("Error Contacting VREManager");
|
||||||
|
throw new GCUBEFault("Error Contacting VREManager");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//vreManagerPT.addResources(arg0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}catch(Exception e){logger.debug("trying next ri");}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new GCUBEFault("cannot retrieve VREManager");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DLManagementFactoryServiceAddressingLocator dlMan=new DLManagementFactoryServiceAddressingLocator();
|
DLManagementFactoryServiceAddressingLocator dlMan=new DLManagementFactoryServiceAddressingLocator();
|
||||||
|
@ -632,7 +655,7 @@ public class ModelerService {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue