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.db.DBInterface;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
|
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
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.CheckStatusResponse;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
||||||
|
@ -491,23 +489,13 @@ public class ModelerService {
|
||||||
logger.error("HSQLDB Error "+e);
|
logger.error("HSQLDB Error "+e);
|
||||||
throw new GCUBEUnrecoverableFault(e);
|
throw new GCUBEUnrecoverableFault(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//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() );
|
DeployVRE deployVREThread= new DeployVRE(resourceID, ServiceContext.getContext().getScope() );
|
||||||
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
|
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
|
||||||
logger.trace("Deploy VRE thread started");
|
logger.trace("Deploy VRE thread started");
|
||||||
deployVREThread.start();
|
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.ISClient;
|
||||||
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
|
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.GCUBEGenericResource;
|
||||||
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.resources.impl.kxml.KGCUBEResource;
|
||||||
|
@ -55,6 +56,8 @@ public class DeployVRE extends Thread{
|
||||||
private String resourceId;
|
private String resourceId;
|
||||||
private GCUBEScope startingScope;
|
private GCUBEScope startingScope;
|
||||||
private String vreName=null;
|
private String vreName=null;
|
||||||
|
private LayoutCreation layoutCreation;
|
||||||
|
private CollectionResourceCreation collectionResourceCreation;
|
||||||
|
|
||||||
public DeployVRE(String resourceId, GCUBEScope scope){
|
public DeployVRE(String resourceId, GCUBEScope scope){
|
||||||
this.resourceId=resourceId;
|
this.resourceId=resourceId;
|
||||||
|
@ -80,14 +83,6 @@ public class DeployVRE extends Thread{
|
||||||
if (!deployManagerOnVRE(firstGHNId)){
|
if (!deployManagerOnVRE(firstGHNId)){
|
||||||
if (!createVRE(GHNList, firstGHNId)){
|
if (!createVRE(GHNList, firstGHNId)){
|
||||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';");
|
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");
|
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -174,6 +169,8 @@ public class DeployVRE extends Thread{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.vreName= vreName;
|
this.vreName= vreName;
|
||||||
|
layoutCreation= new LayoutCreation(this.resourceId, this.vreName);
|
||||||
|
collectionResourceCreation= new CollectionResourceCreation(this.resourceId, this.vreName);
|
||||||
return vreManagerHandler.getReturnValue();
|
return vreManagerHandler.getReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,12 +181,11 @@ public class DeployVRE extends Thread{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<EndpointReferenceType> findInstances() throws Exception {
|
protected List<EndpointReferenceType> findInstances() throws Exception {
|
||||||
System.out.println("findinstance called");
|
|
||||||
try{
|
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"), new AtomicCondition("/Profile/GHN/@UniqueID", this.relatedGhnId));
|
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"), new AtomicCondition("/Profile/GHN/@UniqueID", this.relatedGhnId));
|
||||||
|
System.out.println(this.relatedGhnId);
|
||||||
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
|
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
|
||||||
for (GCUBERunningInstance instance : client.execute(query, scope))
|
for (GCUBERunningInstance instance : client.execute(query, scope))
|
||||||
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
|
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
|
||||||
|
@ -207,7 +203,7 @@ public class DeployVRE extends Thread{
|
||||||
OptionsParameters ops;
|
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+"'; ");
|
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();
|
ops=new OptionsParameters();
|
||||||
ScopeOption[] scopeOptionList= new ScopeOption[6];
|
ScopeOption[] scopeOptionList= new ScopeOption[6];
|
||||||
|
@ -244,6 +240,13 @@ public class DeployVRE extends Thread{
|
||||||
ops.setScopeOptionList(scopeOptionList);
|
ops.setScopeOptionList(scopeOptionList);
|
||||||
vreManPortType.setScopeOptions(ops);
|
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
|
//Adding the resources to the new VRE
|
||||||
AddResourcesParameters arp= new AddResourcesParameters();
|
AddResourcesParameters arp= new AddResourcesParameters();
|
||||||
ResourceList rl= new ResourceList();
|
ResourceList rl= new ResourceList();
|
||||||
|
@ -268,12 +271,28 @@ public class DeployVRE extends Thread{
|
||||||
while (resMdColNative.next()){
|
while (resMdColNative.next()){
|
||||||
resItem= new ResourceItem();
|
resItem= new ResourceItem();
|
||||||
resItem.setID(resMdColNative.getString(1));
|
resItem.setID(resMdColNative.getString(1));
|
||||||
System.out.println(resItem.getID());
|
//System.out.println(resItem.getID());
|
||||||
resItem.setType(GCUBEMCollection.TYPE);
|
resItem.setType(GCUBEMCollection.TYPE);
|
||||||
resItemList.add(resItem);
|
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]));
|
rl.setResource(resItemList.toArray(new ResourceItem[0]));
|
||||||
arp.setResources(rl);
|
arp.setResources(rl);
|
||||||
|
|
||||||
|
@ -323,6 +342,7 @@ public class DeployVRE extends Thread{
|
||||||
try {
|
try {
|
||||||
vreManagerHandler.run();
|
vreManagerHandler.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
logger.error("DeployingVRE step 2 -- failed "+e);
|
logger.error("DeployingVRE step 2 -- failed "+e);
|
||||||
throw new GCUBEFault(e);
|
throw new GCUBEFault(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,11 @@ public class CollectionResourceCreation {
|
||||||
|
|
||||||
private String vreId;
|
private String vreId;
|
||||||
private String vreName;
|
private String vreName;
|
||||||
|
private String createdResourceId=null;
|
||||||
|
|
||||||
|
public String getCreatedResourceId(){
|
||||||
|
return this.createdResourceId;
|
||||||
|
}
|
||||||
|
|
||||||
public CollectionResourceCreation(String vreId, String vreName){
|
public CollectionResourceCreation(String vreId, String vreName){
|
||||||
this.vreId= vreId;
|
this.vreId= vreId;
|
||||||
|
@ -49,19 +54,18 @@ public class CollectionResourceCreation {
|
||||||
res.load(new StringReader(this.transformCollectionResource()));
|
res.load(new StringReader(this.transformCollectionResource()));
|
||||||
ISPublisher pub= GHNContext.getImplementation(ISPublisher.class);
|
ISPublisher pub= GHNContext.getImplementation(ISPublisher.class);
|
||||||
res.setID("");
|
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 {
|
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();
|
StringBuilder collectionToMaintain=new StringBuilder();
|
||||||
while (rs.next()){
|
while (rs.next()){
|
||||||
if (rs.isLast())
|
collectionToMaintain.append(" @name='"+rs.getString(1)+"' or");
|
||||||
collectionToMaintain.append("@name='"+rs.getString(1)+"'");
|
|
||||||
else collectionToMaintain.append("@name='"+rs.getString(1)+"' or ");
|
|
||||||
}
|
}
|
||||||
return collectionToMaintain;
|
return new StringBuilder(collectionToMaintain.subSequence(0, collectionToMaintain.length()-3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,14 +77,14 @@ public class CollectionResourceCreation {
|
||||||
if (list.size()==0) throw new Exception("No GenericResource founded in IS");
|
if (list.size()==0) throw new Exception("No GenericResource founded in IS");
|
||||||
StringWriter sw= new StringWriter();
|
StringWriter sw= new StringWriter();
|
||||||
list.get(0).store(sw);
|
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();
|
StringBuffer out = new StringBuffer();
|
||||||
byte[] b = new byte[4096];
|
byte[] b = new byte[4096];
|
||||||
for (int n; (n = is.read(b)) != -1;) {
|
for (int n; (n = is.read(b)) != -1;) {
|
||||||
out.append(new String(b, 0, n));
|
out.append(new String(b, 0, n));
|
||||||
}
|
}
|
||||||
String xsltCollectionTransformer=out.toString().replace("%%COLLECATIONCOMPARISON%%", this.getCollections()).replace("%%VRENAME%%", ServiceContext.getContext().getScope()+"/"+this.vreName );
|
String xsltCollectionTransformer=out.toString().replace("%%COLLECATIONCOMPARISON%%", this.getCollections()).replace("%%VRENAME%%", ServiceContext.getContext().getScope()+"/"+this.vreName );
|
||||||
return doXSLTrasformation(sw.toString(),xsltCollectionTransformer );
|
return doXSLTrasformation(sw.toString(),xsltCollectionTransformer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.vremanagement.vremodeler.portallayout;
|
package org.gcube.vremanagement.vremodeler.portallayout;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
@ -21,7 +22,11 @@ public class LayoutCreation {
|
||||||
private GCUBEGenericResource resource;
|
private GCUBEGenericResource resource;
|
||||||
private String vreId;
|
private String vreId;
|
||||||
private String vreName;
|
private String vreName;
|
||||||
|
private String createdResourceId= null;
|
||||||
|
|
||||||
|
public String getCreatedResourceId(){
|
||||||
|
return this.createdResourceId;
|
||||||
|
}
|
||||||
|
|
||||||
private void publish(Document doc) throws Exception{
|
private void publish(Document doc) throws Exception{
|
||||||
|
|
||||||
|
@ -32,7 +37,8 @@ public class LayoutCreation {
|
||||||
resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName);
|
resource.setName("Layout_"+splitScope[1]+"_"+splitScope[2]+"_"+this.vreName);
|
||||||
resource.setSecondaryType("VRE");
|
resource.setSecondaryType("VRE");
|
||||||
ISPublisher publisher= GHNContext.getImplementation(ISPublisher.class);
|
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("transparent", "true");
|
||||||
frame.setAttribute("visible", "true");
|
frame.setAttribute("visible", "true");
|
||||||
frame.setAttribute("width", "");
|
frame.setAttribute("width", "");
|
||||||
Element portlet= doc.createElement("portletClass");
|
Element portlet= doc.createElement("portlet-class");
|
||||||
portlet.setTextContent(this.getPortletClass());
|
portlet.setTextContent(this.getPortletClass());
|
||||||
frame.appendChild(portlet);
|
frame.appendChild(portlet);
|
||||||
column.appendChild(frame);
|
column.appendChild(frame);
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class TreeNode extends AbstractTree{
|
||||||
root.setAttribute("can-modify", "false");
|
root.setAttribute("can-modify", "false");
|
||||||
root.setAttribute("label", "");
|
root.setAttribute("label", "");
|
||||||
root.setAttribute("required-role", "");
|
root.setAttribute("required-role", "");
|
||||||
root.setAttribute("style", "sub-menu");
|
root.setAttribute("style", "menu");
|
||||||
root.setAttribute("visible", "true");
|
root.setAttribute("visible", "true");
|
||||||
root.setAttribute("width", "");
|
root.setAttribute("width", "");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue