git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@9517 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bf3f22a043
commit
f4c3f5ba20
|
@ -14,8 +14,6 @@ import org.gcube.common.core.utils.logging.GCUBELog;
|
|||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
||||
import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation;
|
||||
import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CheckStatusResponse;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
||||
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
||||
|
@ -493,21 +491,11 @@ public class ModelerService {
|
|||
}
|
||||
|
||||
|
||||
//only for test
|
||||
LayoutCreation lc= new LayoutCreation(resourceID, "TestScenarioPub");
|
||||
CollectionResourceCreation crc= new CollectionResourceCreation(resourceID, "TestScenarioPub");
|
||||
try {
|
||||
lc.createAndPublishLayout();
|
||||
crc.createAndPublish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/*
|
||||
DeployVRE deployVREThread= new DeployVRE(resourceID, ServiceContext.getContext().getScope() );
|
||||
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
|
||||
logger.trace("Deploy VRE thread started");
|
||||
deployVREThread.start();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ 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.GCUBEGenericResource;
|
||||
import org.gcube.common.core.resources.GCUBEMCollection;
|
||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
||||
import org.gcube.common.core.resources.impl.kxml.KGCUBEResource;
|
||||
|
@ -55,6 +56,8 @@ public class DeployVRE extends Thread{
|
|||
private String resourceId;
|
||||
private GCUBEScope startingScope;
|
||||
private String vreName=null;
|
||||
private LayoutCreation layoutCreation;
|
||||
private CollectionResourceCreation collectionResourceCreation;
|
||||
|
||||
public DeployVRE(String resourceId, GCUBEScope scope){
|
||||
this.resourceId=resourceId;
|
||||
|
@ -80,14 +83,6 @@ public class DeployVRE extends Thread{
|
|||
if (!deployManagerOnVRE(firstGHNId)){
|
||||
if (!createVRE(GHNList, firstGHNId)){
|
||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';");
|
||||
LayoutCreation lc= new LayoutCreation(this.resourceId, this.vreName);
|
||||
CollectionResourceCreation crc= new CollectionResourceCreation(this.resourceId, this.vreName);
|
||||
try {
|
||||
lc.createAndPublishLayout();
|
||||
crc.createAndPublish();
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Cannot create and publish the Layout Generic Resource and the CollectionScenarioInfo",e);
|
||||
}
|
||||
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
|
||||
}
|
||||
else{
|
||||
|
@ -174,6 +169,8 @@ public class DeployVRE extends Thread{
|
|||
return false;
|
||||
}
|
||||
this.vreName= vreName;
|
||||
layoutCreation= new LayoutCreation(this.resourceId, this.vreName);
|
||||
collectionResourceCreation= new CollectionResourceCreation(this.resourceId, this.vreName);
|
||||
return vreManagerHandler.getReturnValue();
|
||||
}
|
||||
|
||||
|
@ -184,12 +181,11 @@ public class DeployVRE extends Thread{
|
|||
|
||||
@Override
|
||||
protected List<EndpointReferenceType> 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));
|
||||
|
||||
System.out.println(this.relatedGhnId);
|
||||
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
|
||||
for (GCUBERunningInstance instance : client.execute(query, scope))
|
||||
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
|
||||
|
@ -207,7 +203,7 @@ public class DeployVRE extends Thread{
|
|||
OptionsParameters ops;
|
||||
|
||||
ResultSet resGenericInfo = DBInterface.queryDB("select VRE.name, VRE.vredesigner, VRE.vremanager, VRE.IntervalTo, VRE.IntervalFrom, VRE.description from VRE where VRE.id='"+this.getParameter().second+"'; ");
|
||||
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+this.getParameter()+" cannot be retrieved");
|
||||
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+this.getParameter().second+" cannot be retrieved");
|
||||
|
||||
ops=new OptionsParameters();
|
||||
ScopeOption[] scopeOptionList= new ScopeOption[6];
|
||||
|
@ -244,6 +240,13 @@ public class DeployVRE extends Thread{
|
|||
ops.setScopeOptionList(scopeOptionList);
|
||||
vreManPortType.setScopeOptions(ops);
|
||||
|
||||
//creating the GenericResource
|
||||
layoutCreation.createAndPublishLayout();
|
||||
collectionResourceCreation.createAndPublish();
|
||||
|
||||
//waiting few seconds to be sure that generic resources will be published
|
||||
Thread.currentThread().sleep(60000);
|
||||
|
||||
//Adding the resources to the new VRE
|
||||
AddResourcesParameters arp= new AddResourcesParameters();
|
||||
ResourceList rl= new ResourceList();
|
||||
|
@ -268,11 +271,27 @@ public class DeployVRE extends Thread{
|
|||
while (resMdColNative.next()){
|
||||
resItem= new ResourceItem();
|
||||
resItem.setID(resMdColNative.getString(1));
|
||||
System.out.println(resItem.getID());
|
||||
//System.out.println(resItem.getID());
|
||||
resItem.setType(GCUBEMCollection.TYPE);
|
||||
resItemList.add(resItem);
|
||||
}
|
||||
}catch(SQLException sqle){logger.error("Error contacting HSQLDB "+sqle);}
|
||||
}catch(SQLException sqle){
|
||||
sqle.printStackTrace();
|
||||
logger.error("Error contacting HSQLDB "+sqle);
|
||||
}
|
||||
|
||||
//adding the Layout genericResource
|
||||
ResourceItem genResItem= new ResourceItem();
|
||||
genResItem.setID(layoutCreation.getCreatedResourceId());
|
||||
genResItem.setType(GCUBEGenericResource.TYPE);
|
||||
resItemList.add(genResItem);
|
||||
|
||||
//adding the CollectionResource genericResource
|
||||
genResItem= new ResourceItem();
|
||||
genResItem.setID(collectionResourceCreation.getCreatedResourceId());
|
||||
genResItem.setType(GCUBEGenericResource.TYPE);
|
||||
resItemList.add(genResItem);
|
||||
|
||||
|
||||
rl.setResource(resItemList.toArray(new ResourceItem[0]));
|
||||
arp.setResources(rl);
|
||||
|
@ -323,6 +342,7 @@ public class DeployVRE extends Thread{
|
|||
try {
|
||||
vreManagerHandler.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("DeployingVRE step 2 -- failed "+e);
|
||||
throw new GCUBEFault(e);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,11 @@ public class CollectionResourceCreation {
|
|||
|
||||
private String vreId;
|
||||
private String vreName;
|
||||
private String createdResourceId=null;
|
||||
|
||||
public String getCreatedResourceId(){
|
||||
return this.createdResourceId;
|
||||
}
|
||||
|
||||
public CollectionResourceCreation(String vreId, String vreName){
|
||||
this.vreId= vreId;
|
||||
|
@ -49,19 +54,18 @@ public class CollectionResourceCreation {
|
|||
res.load(new StringReader(this.transformCollectionResource()));
|
||||
ISPublisher pub= GHNContext.getImplementation(ISPublisher.class);
|
||||
res.setID("");
|
||||
pub.registerGCUBEResource(res, ServiceContext.getContext().getScope(), ServiceContext.getContext());
|
||||
res.load(new StringReader(pub.registerGCUBEResource(res, ServiceContext.getContext().getScope(), ServiceContext.getContext())));
|
||||
this.createdResourceId= res.getID();
|
||||
}
|
||||
|
||||
|
||||
private StringBuilder getCollections() throws Exception {
|
||||
ResultSet rs= DBInterface.queryDB("SELECT c.name FROM COLLECTION c, VRERELATEDCOLLECTION vc WHERE c.id=vc.vreid AND vc.vreid='"+this.vreId+"';");
|
||||
ResultSet rs= DBInterface.queryDB("SELECT c.name FROM COLLECTION c, VRERELATEDCOLLECTION vc WHERE c.id=vc.COLLID AND vc.vreid='"+this.vreId+"';");
|
||||
StringBuilder collectionToMaintain=new StringBuilder();
|
||||
while (rs.next()){
|
||||
if (rs.isLast())
|
||||
collectionToMaintain.append("@name='"+rs.getString(1)+"'");
|
||||
else collectionToMaintain.append("@name='"+rs.getString(1)+"' or ");
|
||||
collectionToMaintain.append(" @name='"+rs.getString(1)+"' or");
|
||||
}
|
||||
return collectionToMaintain;
|
||||
return new StringBuilder(collectionToMaintain.subSequence(0, collectionToMaintain.length()-3));
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +77,7 @@ public class CollectionResourceCreation {
|
|||
if (list.size()==0) throw new Exception("No GenericResource founded in IS");
|
||||
StringWriter sw= new StringWriter();
|
||||
list.get(0).store(sw);
|
||||
InputStream is=InputSource.class.getResourceAsStream("/org/gcube/vremanagement/vremodeler/portallayout/xslt/ScenarioCollectionInfoTransformer.xsl");
|
||||
InputStream is=CollectionResourceCreation.class.getResourceAsStream("/org/gcube/vremanagement/vremodeler/portallayout/xslt/ScenarioCollectionInfoTransformer.xsl");
|
||||
StringBuffer out = new StringBuffer();
|
||||
byte[] b = new byte[4096];
|
||||
for (int n; (n = is.read(b)) != -1;) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.vremanagement.vremodeler.portallayout;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
@ -21,7 +22,11 @@ public class LayoutCreation {
|
|||
private GCUBEGenericResource resource;
|
||||
private String vreId;
|
||||
private String vreName;
|
||||
private String createdResourceId= null;
|
||||
|
||||
public String getCreatedResourceId(){
|
||||
return this.createdResourceId;
|
||||
}
|
||||
|
||||
private void publish(Document doc) throws Exception{
|
||||
|
||||
|
@ -32,7 +37,8 @@ public class LayoutCreation {
|
|||
resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName);
|
||||
resource.setSecondaryType("VRE");
|
||||
ISPublisher publisher= GHNContext.getImplementation(ISPublisher.class);
|
||||
publisher.registerGCUBEResource(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext());
|
||||
resource.load(new StringReader(publisher.registerGCUBEResource(resource, ServiceContext.getContext().getScope(), ServiceContext.getContext())));
|
||||
this.createdResourceId= resource.getID();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TreeLeaf extends AbstractTree{
|
|||
frame.setAttribute("transparent", "true");
|
||||
frame.setAttribute("visible", "true");
|
||||
frame.setAttribute("width", "");
|
||||
Element portlet= doc.createElement("portletClass");
|
||||
Element portlet= doc.createElement("portlet-class");
|
||||
portlet.setTextContent(this.getPortletClass());
|
||||
frame.appendChild(portlet);
|
||||
column.appendChild(frame);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TreeNode extends AbstractTree{
|
|||
root.setAttribute("can-modify", "false");
|
||||
root.setAttribute("label", "");
|
||||
root.setAttribute("required-role", "");
|
||||
root.setAttribute("style", "sub-menu");
|
||||
root.setAttribute("style", "menu");
|
||||
root.setAttribute("visible", "true");
|
||||
root.setAttribute("width", "");
|
||||
|
||||
|
|
Loading…
Reference in New Issue