commit for release 1.8

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@19616 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Lucio Lelii 2010-05-13 16:20:41 +00:00
parent 419e4a1472
commit 4787123ded
24 changed files with 705 additions and 830 deletions

View File

@ -3,3 +3,4 @@ lib.dir = Dependencies/VREModeler
wsdl.1 = ModelerFactory wsdl.1 = ModelerFactory
wsdl.2 = ModelerService wsdl.2 = ModelerService
namespace.1=http://gcube-system.org/namespaces/vremanagement/vremodeler namespace.1=http://gcube-system.org/namespaces/vremanagement/vremodeler
namespace.2=http://gcube-system.org/namespaces/vremanagement/vremodeler/types

View File

@ -17,7 +17,7 @@
override="false" /> override="false" />
<environment <environment
name="vremanagerTimeout" name="resourceManagerTimeout"
value="600000" value="600000"
type="java.lang.String" type="java.lang.String"
override="false" /> override="false" />

View File

@ -1,7 +1,7 @@
CREATE CACHED TABLE COLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,MEMBERS VARCHAR,CREATION VARCHAR,LASTUPDATE VARCHAR) CREATE CACHED TABLE COLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,MEMBERS VARCHAR,CREATION VARCHAR,LASTUPDATE VARCHAR)
CREATE CACHED TABLE GHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR) CREATE CACHED TABLE GHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR)
CREATE CACHED TABLE MCOLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,RELATEDCOLLECTIONID VARCHAR NOT NULL,CONSTRAINT SYS_FK_50 FOREIGN KEY(RELATEDCOLLECTIONID) REFERENCES COLLECTION(ID)) CREATE CACHED TABLE MCOLLECTION(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR,DESCRIPTION VARCHAR,RELATEDCOLLECTIONID VARCHAR NOT NULL,CONSTRAINT SYS_FK_50 FOREIGN KEY(RELATEDCOLLECTIONID) REFERENCES COLLECTION(ID))
CREATE CACHED TABLE VRE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL,VREDESIGNER VARCHAR NOT NULL,VREMANAGER VARCHAR NOT NULL,INTERVALFROM DATE,INTERVALTO DATE,EPR VARCHAR,STATUS VARCHAR) CREATE CACHED TABLE VRE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL,VREDESIGNER VARCHAR NOT NULL,VREMANAGER VARCHAR NOT NULL,INTERVALFROM DATE,INTERVALTO DATE,STATUS VARCHAR)
CREATE CACHED TABLE CS(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL) CREATE CACHED TABLE CS(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL,DESCRIPTION VARCHAR NOT NULL)
CREATE CACHED TABLE RUNNINGINSTANCE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL) CREATE CACHED TABLE RUNNINGINSTANCE(ID VARCHAR NOT NULL PRIMARY KEY,NAME VARCHAR NOT NULL, CLASS VARCHAR NOT NULL)
CREATE CACHED TABLE GHNRELATEDRI(GHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(GHNID,RIID)) CREATE CACHED TABLE GHNRELATEDRI(GHNID VARCHAR NOT NULL,RIID VARCHAR NOT NULL,PRIMARY KEY(GHNID,RIID))

View File

@ -6,7 +6,8 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:coretypes="http://gcube-system.org/namespaces/common/core/types" xmlns:coretypes="http://gcube-system.org/namespaces/common/core/types"
xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults" xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" > xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:vretypes="http://gcube-system.org/namespaces/vremanagement/vremodeler/types">
<import namespace="http://gcube-system.org/namespaces/common/core/faults" location="../gcube/common/core/faults/GCUBEFaults.wsdl"/> <import namespace="http://gcube-system.org/namespaces/common/core/faults" location="../gcube/common/core/faults/GCUBEFaults.wsdl"/>
@ -24,7 +25,7 @@
<xsd:import namespace="http://gcube-system.org/namespaces/common/core/types" schemaLocation="../gcube/common/core/types/GCUBETypes.xsd"/> <xsd:import namespace="http://gcube-system.org/namespaces/common/core/types" schemaLocation="../gcube/common/core/types/GCUBETypes.xsd"/>
<xsd:import namespace="http://schemas.xmlsoap.org/ws/2004/03/addressing" schemaLocation="../ws/addressing/WS-Addressing.xsd" /> <xsd:import namespace="http://schemas.xmlsoap.org/ws/2004/03/addressing" schemaLocation="../ws/addressing/WS-Addressing.xsd" />
<xsd:import namespace="http://gcube-system.org/namespaces/vremanagement/vremodeler/types" schemaLocation="VRETypes.xsd"/>
<!-- REQUESTS AND RESPONSES --> <!-- REQUESTS AND RESPONSES -->
@ -33,7 +34,7 @@
<xsd:element name="createResourceResponse" type="wsa:EndpointReferenceType"/> <xsd:element name="createResourceResponse" type="wsa:EndpointReferenceType"/>
<xsd:element name="getAllVREsMessageResponse" type="xsd:string"/> <xsd:element name="getAllVREsMessageResponse" type="vretypes:ReportList"/>
<xsd:element name="getAllVREsMessageRequest" type="coretypes:VOID"/> <xsd:element name="getAllVREsMessageRequest" type="coretypes:VOID"/>

View File

@ -8,7 +8,8 @@
xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd" xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"
xmlns:coretypes="http://gcube-system.org/namespaces/common/core/types" xmlns:coretypes="http://gcube-system.org/namespaces/common/core/types"
xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults" xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults"
xmlns:provider="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider"> xmlns:provider="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider"
xmlns:vretypes="http://gcube-system.org/namespaces/vremanagement/vremodeler/types">
<import namespace="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" location="../gcube/common/core/providers/GCUBEProvider.wsdl"/> <import namespace="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" location="../gcube/common/core/providers/GCUBEProvider.wsdl"/>
@ -29,31 +30,22 @@
<xsd:schema targetNamespace="http://gcube-system.org/namespaces/vremanagement/vremodeler" <xsd:schema targetNamespace="http://gcube-system.org/namespaces/vremanagement/vremodeler"
xmlns:tns="http://gcube-system.org/namespaces/vremanagement/vremodeler"> xmlns:tns="http://gcube-system.org/namespaces/vremanagement/vremodeler">
<xsd:import namespace="http://gcube-system.org/namespaces/common/core/types" schemaLocation="../gcube/common/core/types/GCUBETypes.xsd"/> <xsd:import namespace="http://gcube-system.org/namespaces/common/core/types" schemaLocation="../gcube/common/core/types/GCUBETypes.xsd"/>
<xsd:import namespace="http://gcube-system.org/namespaces/vremanagement/vremodeler/types" schemaLocation="VRETypes.xsd"/>
<!-- REQUESTS AND RESPONSES --> <!-- REQUESTS AND RESPONSES -->
<xsd:element name="getVREModelRequestMessage" type="coretypes:VOID"/> <xsd:element name="getDescriptionRequestMessage" type="coretypes:VOID"/>
<xsd:element name="getVREModelResponseMessage" type="xsd:string"/> <xsd:element name="getDescriptionResponseMessage" type="vretypes:VREDescription"/>
<xsd:complexType name="VRERequest"> <xsd:element name="setDescriptionRequestMessage" type="vretypes:VREDescription"/>
<xsd:sequence>
<xsd:element name="VREName" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="VREDescription" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="VREDesigner" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="VREManager" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="StartTime" type="xsd:long" minOccurs="1" maxOccurs="1" />
<xsd:element name="EndTime" type="xsd:long" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="setVREModelRequestMessage" type="tns:VRERequest"/> <xsd:element name="setDescriptionResponseMessage" type="coretypes:VOID"/>
<xsd:element name="setVREModelResponseMessage" type="coretypes:VOID"/>
<xsd:element name="getCollectionRequestMessage" type="coretypes:VOID"/> <xsd:element name="getCollectionRequestMessage" type="coretypes:VOID"/>
<xsd:element name="getCollectionResponseMessage" type="xsd:string"/> <xsd:element name="getCollectionResponseMessage" type="vretypes:CollectionList"/>
<xsd:complexType name="collectionArray"> <xsd:complexType name="collectionArray">
<xsd:sequence> <xsd:sequence>
@ -67,7 +59,7 @@
<xsd:element name="getMDCollectionRequestMessage" type="coretypes:VOID"/> <xsd:element name="getMDCollectionRequestMessage" type="coretypes:VOID"/>
<xsd:element name="getMDCollectionResponseMessage" type="xsd:string"/> <xsd:element name="getMDCollectionResponseMessage" type="vretypes:metadataFormatResponse"/>
<xsd:complexType name="checkedRows"> <xsd:complexType name="checkedRows">
<xsd:sequence> <xsd:sequence>
@ -96,7 +88,7 @@
<xsd:element name="setQualityResponseMessage" type="coretypes:VOID"/> <xsd:element name="setQualityResponseMessage" type="coretypes:VOID"/>
<xsd:element name="getFunctionalityResponseMessage" type="xsd:string"/> <xsd:element name="getFunctionalityResponseMessage" type="vretypes:FunctionalityList"/>
<xsd:element name="getFunctionalityRequestMessage" type="coretypes:VOID"/> <xsd:element name="getFunctionalityRequestMessage" type="coretypes:VOID"/>
@ -111,7 +103,7 @@
<xsd:element name="setFunctionalityRequestMessage" type="tns:functionalityIDArray"/> <xsd:element name="setFunctionalityRequestMessage" type="tns:functionalityIDArray"/>
<xsd:element name="getGHNResponseMessage" type="xsd:string"/> <xsd:element name="getGHNResponseMessage" type="vretypes:GHNList"/>
<xsd:element name="getGHNRequestMessage" type="coretypes:VOID"/> <xsd:element name="getGHNRequestMessage" type="coretypes:VOID"/>
@ -173,18 +165,18 @@
============================================================--> ============================================================-->
<message name="GetVREModelInputMessage"> <message name="GetDescriptionInputMessage">
<part name="request" element="tns:getVREModelRequestMessage"/> <part name="request" element="tns:getDescriptionRequestMessage"/>
</message> </message>
<message name="GetVREModelOutputMessage"> <message name="GetDescriptionOutputMessage">
<part name="response" element="tns:getVREModelResponseMessage"/> <part name="response" element="tns:getDescriptionResponseMessage"/>
</message> </message>
<message name="SetVREModelInputMessage"> <message name="SetDescriptionInputMessage">
<part name="request" element="tns:setVREModelRequestMessage"/> <part name="request" element="tns:setDescriptionRequestMessage"/>
</message> </message>
<message name="SetVREModelOutputMessage"> <message name="SetDescriptionOutputMessage">
<part name="response" element="tns:setVREModelResponseMessage"/> <part name="response" element="tns:setDescriptionResponseMessage"/>
</message> </message>
<message name="GetCollectionInputMessage"> <message name="GetCollectionInputMessage">
@ -290,14 +282,14 @@
wsdlpp:extends="provider:GCUBEProvider" wsdlpp:extends="provider:GCUBEProvider"
wsrp:ResourceProperties="tns:ModelerProperties"> wsrp:ResourceProperties="tns:ModelerProperties">
<operation name="setVREModel"> <operation name="setDescription">
<input message="tns:SetVREModelInputMessage"/> <input message="tns:SetDescriptionInputMessage"/>
<output message="tns:SetVREModelOutputMessage"/> <output message="tns:SetDescriptionOutputMessage"/>
</operation> </operation>
<operation name="getVREModel"> <operation name="getDescription">
<input message="tns:GetVREModelInputMessage"/> <input message="tns:GetDescriptionInputMessage"/>
<output message="tns:GetVREModelOutputMessage"/> <output message="tns:GetDescriptionOutputMessage"/>
</operation> </operation>

157
schema/VRETypes.xsd Normal file
View File

@ -0,0 +1,157 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://gcube-system.org/namespaces/vremanagement/vremodeler/types"
xmlns:tns="http://gcube-system.org/namespaces/vremanagement/vremodeler/types"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- VRE types -->
<xs:complexType name="VREDescription">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="description" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="designer" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="manager" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="startTime" type="xs:dateTime" minOccurs="1" maxOccurs="1" />
<xs:element name="endTime" type="xs:dateTime" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<!-- GHN Type -->
<xs:complexType name="GHNList">
<xs:sequence>
<xs:element name="list" type="tns:GHNType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="GHNType">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="host" type="xs:string"/>
<xs:element name="security" type="xs:string"/>
<xs:element name="upTime" type="xs:string"/>
<xs:element name="memory">
<xs:complexType>
<xs:sequence>
<xs:element name="virtulaAvailable" type="xs:string"/>
<xs:element name="virtulaSize" type="xs:string"/>
<xs:element name="localAvailableSpace" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="site">
<xs:complexType>
<xs:sequence>
<xs:element name="location" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
<xs:element name="domain" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="relatedRIs" type="tns:RunningInstance" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="vreManagerUse" type="xs:boolean"/>
<xs:element name="selectable" type="xs:boolean"/>
<xs:element name="selected" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RunningInstance">
<xs:sequence>
<xs:element name="serviceName" type="xs:string"/>
<xs:element name="serviceClass" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<!-- Collection Type -->
<xs:complexType name="CollectionList">
<xs:sequence>
<xs:element name="list" type="tns:CollectionType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="CollectionType">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="info">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="numberOfMembers" type="xs:int"/>
<xs:element name="creationTime" type="xs:dateTime"/>
<xs:element name="lastUpdateTime" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="selected" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<!-- Metadata Format types -->
<xs:complexType name="MetadataFormatItem">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="uri" type="xs:string"/>
<xs:element name="language" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetadataFormatCollectionRelation">
<xs:sequence>
<xs:element name="collId" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="mfList" type="tns:metadataFormatRelation" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="metadataFormatRelation">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="selected" type="xs:boolean"/>
<xs:element name="selectable" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="metadataFormatResponse">
<xs:sequence>
<xs:element name="metadataFromats" type="tns:MetadataFormatItem" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="collections" type="tns:MetadataFormatCollectionRelation" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- Functionality Types -->
<xs:complexType name="FunctionalityList">
<xs:sequence>
<xs:element name="list" type="tns:FunctionalityItem" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="FunctionalityItem">
<xs:sequence>
<xs:element name="id" type="xs:int"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="selected" type="xs:boolean"/>
<xs:element name="childs" type="tns:FunctionalityItem" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- VRE Report Type -->
<xs:complexType name="ReportList">
<xs:sequence>
<xs:element name="list" type="tns:Report" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Report">
<xs:sequence>
<xs:element name="id" type="xs:string"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -1,13 +1,11 @@
package org.gcube.vremanagement.vremodeler.consumers; package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBECollectionQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer; import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent; import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBECollection;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext; import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
@ -31,16 +29,17 @@ public class CollectionConsumer extends BaseNotificationConsumer{
logger.trace("notificetion received"); logger.trace("notificetion received");
ServiceContext.getContext().setScope(this.scope); ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){ if (operation.compareTo("create")==0){
logger.trace("adding a new GHN in DB"); logger.trace("adding a new GHN in DB");
ISClient client=GHNContext.getImplementation(ISClient.class); GCUBECollection collection= GHNContext.getImplementation(GCUBECollection.class);
GCUBECollectionQuery query= client.getQuery(GCUBECollectionQuery.class); collection.load(new StringReader(profile));
query.addAtomicConditions(new AtomicCondition("/ID",id)); new CollectionHandler().add(collection);
Thread.sleep(60000); } else if (operation.compareTo("destroy")==0){
new CollectionHandler().add(client.execute(query, this.scope).get(0)); logger.trace("removing a collection from DB");
} else if (operation.compareTo("remove")==0){ new CollectionHandler().drop(id);
logger.trace("removing a GHN from DB");
} }
}catch(Exception e){logger.error("error in notification received",e);} }catch(Exception e){logger.error("error in notification received",e);}

View File

@ -1,13 +1,13 @@
package org.gcube.vremanagement.vremodeler.consumers; package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer; import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent; import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext; import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
@ -29,17 +29,18 @@ public class GHNConsumer extends BaseNotificationConsumer{
public void onNotificationReceived(NotificationEvent event){ public void onNotificationReceived(NotificationEvent event){
try{ try{
logger.trace("notificetion received"); logger.trace("notification received");
ServiceContext.getContext().setScope(this.scope); ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
//logger.trace("received id: "+id+" op: "+operation+" profile: "+profile);
if (operation.compareTo("create")==0){ if (operation.compareTo("create")==0){
logger.trace("adding a new GHN in DB"); logger.trace("adding a new GHN in DB");
ISClient client=GHNContext.getImplementation(ISClient.class); GCUBEHostingNode ghn= GHNContext.getImplementation(GCUBEHostingNode.class);
GCUBEGHNQuery query= client.getQuery(GCUBEGHNQuery.class); ghn.load(new StringReader(profile));
query.addAtomicConditions(new AtomicCondition("/ID",id)); new GHNHandler().add(ghn);
Thread.sleep(60000);
new GHNHandler().add(client.execute(query, this.scope).get(0));
} else if (operation.compareTo("destroy")==0){ } else if (operation.compareTo("destroy")==0){
logger.trace("removing a GHN from DB"); logger.trace("removing a GHN from DB");
new GHNHandler().drop(id); new GHNHandler().drop(id);

View File

@ -1,15 +1,8 @@
package org.gcube.vremanagement.vremodeler.consumers; package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader; import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericResourceQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer; import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent; import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBEGenericResource; import org.gcube.common.core.resources.GCUBEGenericResource;
@ -39,39 +32,31 @@ private GCUBELog logger= new GCUBELog(GHNConsumer.class);
try{ try{
ServiceContext.getContext().setScope(this.scope); ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
logger.info("notification received for genericResource "+id+" and operation "+operation); logger.info("notification received for genericResource "+id+" and operation "+operation);
if (id.compareTo(this.functionalityResourceId)==0 && (operation.compareTo("update")==0)){ if (id.compareTo(this.functionalityResourceId)==0 && (operation.compareTo("update")==0)){
logger.trace("notification received for functionalityResource with id "+id+" in scope "+scope.toString()); logger.trace("notification received for functionalityResource with id "+id+" in scope "+scope.toString());
KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource(); KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource();
ISClient client=GHNContext.getImplementation(ISClient.class); resource.load(new StringReader(profile));
GCUBEGenericResourceQuery query= client.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/Profile/Name","FuctionalitiesResource"), new AtomicCondition("/Profile/SecondaryType","VREModelerResource"));
GCUBEGenericQuery genericQuery= client.getQuery(GCUBEGenericQuery.class);
genericQuery.setExpression(query.getExpression());
Thread.sleep(60000);
resource.load(new StringReader(client.execute(genericQuery, ServiceContext.getContext().getScope()).get(0).toString()));
//FunctionalityHandler //FunctionalityHandler
FunctionalityHandler functionalityHandler= new FunctionalityHandler(); FunctionalityHandler functionalityHandler= new FunctionalityHandler();
functionalityHandler.add(resource); functionalityHandler.add(resource);
}else if (operation.compareTo("create")==0){ }else if (operation.compareTo("create")==0){
logger.trace("notification received for generic resource with operation create"); logger.trace("notification received for generic resource with operation create");
ISClient client=GHNContext.getImplementation(ISClient.class);
GCUBEGenericResourceQuery query= client.getQuery(GCUBEGenericResourceQuery.class);
query.addAtomicConditions(new AtomicCondition("/ID",id));
GCUBEGenericResource resource =client.execute(query, ServiceContext.getContext().getScope()).get(0);
if (resource.getName().compareTo("FuctionalitiesResource")==0){ GCUBEGenericResource genericResource= GHNContext.getImplementation(GCUBEGenericResource.class);
genericResource.load(new StringReader(profile));
if (genericResource.getName().compareTo("FuctionalitiesResource")==0){
FunctionalityHandler functionalityHandler= new FunctionalityHandler(); FunctionalityHandler functionalityHandler= new FunctionalityHandler();
KGCUBEGenericFunctionalityResource functResource=new KGCUBEGenericFunctionalityResource(); KGCUBEGenericFunctionalityResource functResource=new KGCUBEGenericFunctionalityResource();
StringWriter sw= new StringWriter(); functResource.load(new StringReader(profile));
resource.store(sw);
functResource.load(new StringReader(sw.toString()));
functionalityHandler.add(functResource); functionalityHandler.add(functResource);
} else } else
if (ServiceContext.getContext().getSecondaryTypeGenericResourceRequired().contains(resource.getSecondaryType())) if (ServiceContext.getContext().getSecondaryTypeGenericResourceRequired().contains(genericResource.getSecondaryType()))
new GenericResourceHandler().add(resource); new GenericResourceHandler().add(genericResource);
}else if (operation.compareTo("destroy")==0){ }else if (operation.compareTo("destroy")==0){
logger.trace("notification received for generic resource with operation destroy"); logger.trace("notification received for generic resource with operation destroy");
new GenericResourceHandler().drop(id); new GenericResourceHandler().drop(id);

View File

@ -1,11 +1,10 @@
package org.gcube.vremanagement.vremodeler.consumers; package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEMCollectionQuery;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer; import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent; import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBEMCollection; import org.gcube.common.core.resources.GCUBEMCollection;
@ -32,17 +31,16 @@ public class MCollectionConsumer extends BaseNotificationConsumer{
//logger.trace("notification received"); //logger.trace("notification received");
ServiceContext.getContext().setScope(this.scope); ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){ if (operation.compareTo("create")==0){
logger.trace("adding a new MCollection in DB"); logger.trace("adding a new MCollection in DB");
ISClient client=GHNContext.getImplementation(ISClient.class); GCUBEMCollection mCollection= GHNContext.getImplementation(GCUBEMCollection.class);
GCUBEMCollectionQuery query= client.getQuery(GCUBEMCollectionQuery.class); mCollection.load(new StringReader(profile));
query.addAtomicConditions(new AtomicCondition("/ID",id)); new MCollectionHandler(mCollection.getRelCollection().getCollectionID()).add(mCollection);
GCUBEMCollection mColl= client.execute(query, this.scope).get(0); } else if (operation.compareTo("destroy")==0){
Thread.sleep(60000); logger.trace("removing a MCollection from DB");
new MCollectionHandler(mColl.getRelCollection().getCollectionID()).add(mColl); new MCollectionHandler(null).drop(id);
} else if (operation.compareTo("remove")==0){
logger.trace("removing a GHN from DB");
} }
}catch(Exception e){logger.error("error in notification received",e);} }catch(Exception e){logger.error("error in notification received",e);}

View File

@ -1,11 +1,8 @@
package org.gcube.vremanagement.vremodeler.consumers; package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
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.informationsystem.notifier.ISNotifier.BaseNotificationConsumer; import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent; import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBERunningInstance; import org.gcube.common.core.resources.GCUBERunningInstance;
@ -32,16 +29,12 @@ public class RunningInstanceConsumer extends BaseNotificationConsumer{
logger.trace("notification received for RI"); logger.trace("notification received for RI");
ServiceContext.getContext().setScope(this.scope); ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
if (operation.compareTo("create")==0){ if (operation.compareTo("create")==0){
logger.trace("adding a new RI in DB"); logger.trace("adding a new RI in DB");
ISClient client=GHNContext.getImplementation(ISClient.class); GCUBERunningInstance ri= GHNContext.getImplementation(GCUBERunningInstance.class);
GCUBERIQuery query= client.getQuery(GCUBERIQuery.class); ri.load(new StringReader(profile));
logger.trace("id: "+id);
query.addAtomicConditions(new AtomicCondition("/ID",id));
Thread.sleep(60000);
GCUBERunningInstance ri= client.execute(query, this.scope).get(0);
new RunningInstancesHandler(ri.getGHNID()).add(ri); new RunningInstancesHandler(ri.getGHNID()).add(ri);
} else if (operation.compareTo("destroy")==0){ } else if (operation.compareTo("destroy")==0){
logger.trace("removing a RI from DB"); logger.trace("removing a RI from DB");

View File

@ -9,8 +9,10 @@ import org.gcube.common.core.faults.GCUBEFault;
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.vremodeler.db.DBInterface; import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil; import org.gcube.vremanagement.vremodeler.impl.util.Util;
import org.gcube.vremanagement.vremodeler.stubs.GetExistingNamesResponseMessage; import org.gcube.vremanagement.vremodeler.stubs.GetExistingNamesResponseMessage;
import org.gcube.vremanagement.vremodeler.stubs.Report;
import org.gcube.vremanagement.vremodeler.stubs.ReportList;
@ -60,7 +62,7 @@ public class ModelFactoryService{
res= DBInterface.queryDB("select VRE.name from VRE;"); res= DBInterface.queryDB("select VRE.name from VRE;");
while (res.next()) while (res.next())
toReturn.add(res.getString(1)); toReturn.add(res.getString(1));
}catch(Exception e) {logger.error("error on DB"); throw new GCUBEFault(e);} }catch(Exception e) {logger.error("error on DB",e); throw new GCUBEFault(e);}
GetExistingNamesResponseMessage response = new GetExistingNamesResponseMessage(); GetExistingNamesResponseMessage response = new GetExistingNamesResponseMessage();
response.setNames(toReturn.toArray(new String[0])); response.setNames(toReturn.toArray(new String[0]));
@ -85,8 +87,7 @@ public class ModelFactoryService{
try{ try{
ServiceContext.getContext().intializeDB(); ServiceContext.getContext().intializeDB();
}catch(Exception e){ }catch(Exception e){
logger.error("DB inizialization failed"+e); logger.error("DB inizialization failed",e);
e.printStackTrace();
} }
} }
}; };
@ -101,20 +102,19 @@ public class ModelFactoryService{
* @return String * @return String
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getAllVREs(VOID arg) throws GCUBEFault{ public ReportList getAllVREs(VOID arg) throws GCUBEFault{
String toReturn = null;
ResultSet res=null; ResultSet res=null;
try{ try{
DBInterface.connect(); DBInterface.connect();
res= DBInterface.queryDB("select VRE.name, VRE.description, VRE.status, VRE.epr from VRE;"); res= DBInterface.queryDB("select VRE.name, VRE.description, VRE.status, VRE.id from VRE;");
}catch(Exception e) {logger.error("VREModel: error on DB"); throw new GCUBEFault(e);} }catch(Exception e) {logger.error("error on DB",e); throw new GCUBEFault(e);}
try { try {
toReturn=XMLUtil.PrepareAllVREsXML(res); return new ReportList(Util.prepareVREsList(res).toArray(new Report[0]));
} catch (Exception e) { } catch (Exception e) {
logger.error("VREModel parsing error in function getAllDLs "+e.getMessage()); logger.error("parsing error in function getAllVREs ",e);
throw new GCUBEFault(e); throw new GCUBEFault(e);
} }
return toReturn;
} }

View File

@ -85,4 +85,6 @@ public class ModelerResource extends GCUBEWSResource {
this.getResourcePropertySet().get(RP_FIRSTREPORT).add(reportFirstStep); this.getResourcePropertySet().get(RP_FIRSTREPORT).add(reportFirstStep);
} }
} }

View File

@ -2,12 +2,11 @@ package org.gcube.vremanagement.vremodeler.impl;
import java.net.URI; import java.net.URI;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import javax.xml.namespace.QName;
import org.gcube.common.core.faults.GCUBEFault; import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.faults.GCUBEUnrecoverableFault; import org.gcube.common.core.faults.GCUBEUnrecoverableFault;
import org.gcube.common.core.types.VOID; import org.gcube.common.core.types.VOID;
@ -15,27 +14,27 @@ 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.ModelerCollection; import org.gcube.vremanagement.vremodeler.impl.util.ModelerCollection;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil; import org.gcube.vremanagement.vremodeler.impl.util.Util;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat; import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
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.CollectionList;
import org.gcube.vremanagement.vremodeler.stubs.CollectionType;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray; import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityItem;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityList;
import org.gcube.vremanagement.vremodeler.stubs.GHNArray; import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
import org.gcube.vremanagement.vremodeler.stubs.GHNList;
import org.gcube.vremanagement.vremodeler.stubs.GHNType;
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatResponse;
import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs; import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs;
import org.gcube.vremanagement.vremodeler.stubs.VRERequest; import org.gcube.vremanagement.vremodeler.stubs.VREDescription;
import org.gcube.vremanagement.vremodeler.stubs.VREState;
import org.globus.wsrf.ResourceException; import org.globus.wsrf.ResourceException;
import org.globus.wsrf.encoding.ObjectSerializer;
import org.globus.wsrf.encoding.SerializationException;
public class ModelerService { public class ModelerService {
public static final String INPROGRESS="In Progress";
public static final String DEPLOYED="Deployed";
public static final String FAILED="Failed";
public static final String PENDING="Pending";
public static final String DEPLOYING="Deploying";
private static final GCUBELog logger = new GCUBELog(ModelerService.class); private static final GCUBELog logger = new GCUBELog(ModelerService.class);
@ -52,35 +51,23 @@ public class ModelerService {
* @throws RemoteException - * @throws RemoteException -
* *
*/ */
public void setVREModel(VRERequest request) throws GCUBEFault{ public void setDescription(VREDescription request) throws GCUBEFault{
Date dateFrom=null, dateTo=null; Calendar dateFrom=null, dateTo=null;
ResultSet res=null; ResultSet res=null;
try { try {
res=DBInterface.queryDB("select * from VRE where VRE.id='"+getResource().getId()+"'; "); res=DBInterface.queryDB("select * from VRE where VRE.id='"+getResource().getId()+"'; ");
if(res.next()) if(res.next())
{ {
dateFrom=new Date(request.getStartTime()); dateFrom=request.getStartTime();
dateTo=new Date(request.getEndTime()); dateTo=request.getEndTime();
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()+"'; "); DBInterface.queryDB("update VRE set name='"+request.getName()+"', description='"+request.getDescription()+"', vredesigner='"+request.getDesigner()+"', vremanager= '"+request.getManager()+"', intervalfrom='"+dateFrom.getTime()+"', intervalto='"+dateTo.getTime()+"' where VRE.id='"+getResource().getId()+"'; ");
}else{ }else{
dateFrom=new Date(request.getStartTime()); dateFrom=request.getStartTime();
dateTo=new Date(request.getEndTime()); dateTo=request.getEndTime();
String eprToString; DBInterface.ExecuteUpdate("insert into VRE values('"+getResource().getId()+"','"+request.getName()+"','"+request.getDescription()+"','"+request.getDesigner()+"','"+request.getManager()+"','"+dateFrom+"','"+dateTo+"','"+VREState.IN_PROGRESS+"'); ");
try {
eprToString = ObjectSerializer.toString(getResource().getEPR(), new QName(ModelerContext.getPortTypeContext().getNamespace(), "ModelResourceReference"));
//logger.debug("EPR: "+eprToString);
} catch (SerializationException e) {
//logger.error("VDL Model Service: error serializing EPR");
logger.error("VDL Model Service: error serializing EPR",e);
throw new GCUBEFault(e);
}
DBInterface.ExecuteUpdate("insert into VRE values('"+getResource().getId()+"','"+request.getVREName()+"','"+request.getVREDescription()+"','"+request.getVREDesigner()+"','"+request.getVREManager()+"','"+dateFrom+"','"+dateTo+"','"+eprToString+"','"+INPROGRESS+"'); ");
} }
} catch (Exception e) { } catch (Exception e) {
logger.error(e); logger.error(e);
throw new GCUBEFault(e); throw new GCUBEFault(e);
@ -97,35 +84,26 @@ public class ModelerService {
* @return VoidType * @return VoidType
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getVREModel(VOID var) throws GCUBEFault{ public VREDescription getDescription(VOID var) throws GCUBEFault{
String toReturn =null;
ResultSet res=null;
//logger.debug("Request DL with ID "+ID); //logger.debug("Request DL with ID "+ID);
try { try {
String ID=getResource().getId();
DBInterface.connect(); DBInterface.connect();
res=DBInterface.queryDB("select * from VRE where VRE.id='"+ID+"';"); return Util.prepareVREDescription(DBInterface.queryDB("select * from VRE where VRE.id='"+getResource().getId()+"';"));
toReturn=XMLUtil.PrepareVREModelXML(res);
} catch (Exception e) { } catch (Exception e) {
logger.error("VDLModel parsing error in function getDLModel ",e); logger.error("error getting VRE informations",e);
throw new GCUBEFault(e); throw new GCUBEFault(e);
} }
return toReturn;
} }
/** /**
* return an XML containing the DHN list * return an XML containing the GHN list
* *
* @param request void * @param request void
* @return a XML String * @return a XML String
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getGHNs(VOID var) throws GCUBEFault{ public GHNList getGHNs(VOID var) throws GCUBEFault{
logger.info("getGHNs method"); logger.trace("getGHNs method");
ResultSet res; ResultSet res;
ArrayList<String> relatedGHN=new ArrayList<String>(); ArrayList<String> relatedGHN=new ArrayList<String>();
try{ try{
@ -139,9 +117,10 @@ public class ModelerService {
relatedGHN.add(resRelated.getString(1)); relatedGHN.add(resRelated.getString(1));
if (resRelated.getBoolean(2)) candidatedGHN=resRelated.getString(1); if (resRelated.getBoolean(2)) candidatedGHN=resRelated.getString(1);
} }
return XMLUtil.PrepareGHNsXML(res, relatedGHN,candidatedGHN);
return new GHNList(Util.prepareGHNs(res, relatedGHN,candidatedGHN).toArray(new GHNType[0]));
}catch(Exception e) { }catch(Exception e) {
logger.error("VRE Modeler: error retreiving GHNs",e); logger.error("error retreiving GHNs",e);
throw new GCUBEFault(e);} throw new GCUBEFault(e);}
} }
@ -188,7 +167,7 @@ public class ModelerService {
* @return the collection retrieved from the database * @return the collection retrieved from the database
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getCollection(VOID var) throws GCUBEFault{ public CollectionList getCollection(VOID var) throws GCUBEFault{
ResultSet res; ResultSet res;
ArrayList<String> relatedCollection=new ArrayList<String>(); ArrayList<String> relatedCollection=new ArrayList<String>();
try{ try{
@ -206,7 +185,7 @@ public class ModelerService {
throw new GCUBEFault(e);} throw new GCUBEFault(e);}
return XMLUtil.PrepareCollectionXML(res, relatedCollection); return new CollectionList(Util.prepareCollections(res, relatedCollection).toArray(new CollectionType[0]));
} }
/** /**
@ -253,7 +232,7 @@ public class ModelerService {
* @return a XML format string * @return a XML format string
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getMetadataRelatedToCollection(VOID var) throws GCUBEFault { public MetadataFormatResponse getMetadataRelatedToCollection(VOID var) throws GCUBEFault {
Hashtable<ModelerCollection, List<MetadataFormat>> nativeMetadataFormat; Hashtable<ModelerCollection, List<MetadataFormat>> nativeMetadataFormat;
Hashtable<ModelerCollection, List<MetadataFormat>> selectedMetadataFormat; Hashtable<ModelerCollection, List<MetadataFormat>> selectedMetadataFormat;
@ -293,53 +272,14 @@ public class ModelerService {
} }
} }
/*
//recovering possible previous selection for metadataFormat
while (metadataSelected.next()){
if(selectedMetadataStructure.containsKey(metadataSelected.getString(1)))
selectedMetadataStructure.get(metadataSelected.getString(1)).add(metadataSelected.getString(2));
else {
ArrayList<String> temp= new ArrayList<String>();
temp.add(metadataSelected.getString(2));
selectedMetadataStructure.put(metadataSelected.getString(1), temp);
}
}
if(!enter) throw new GCUBEFault("no collection selected for this VRE");
else preparedWhere=preparedWhere.substring(0, preparedWhere.length()-4)+") ";
//retrieving all available MDFromat
totalMF = DBInterface.queryDB("select MDFORMAT.id, MDFORMAT.name, MDFORMAT.schemauri, MDFORMAT.language from MDFORMAT;");
totalMFList= new ArrayList<MetadataFormat>();
while (totalMF.next()){
MetadataFormat mf= new MetadataFormat(totalMF.getString(1),totalMF.getString(2), new URI(totalMF.getString(3)), totalMF.getString(4) );
totalMFList.add(mf);
}
/*
resDerivable= DBInterface.queryDB("select mdc.collid, mdc.collname, mdc.colldesc , collmdf.id as mdfid from (select * from DERIVABLEMDF INNER JOIN MDFORMAT on DERIVABLEMDF.mdfid= MDFORMAT.id) " +
"as COLLMDF,(select COLLECTION.id as collid, COLLECTION.name as collname, COLLECTION.description as colldesc, MDCOLLECTION.id as mdid from COLLECTION INNER JOIN MDCOLLECTION " +
"ON COLLECTION.id = MDCOLLECTION.relatedcollectionid) as MDC where COLLMDF.mdcollid= MDC.mdid "+preparedWhere+";");
resNative= DBInterface.queryDB("select mdc.collid, mdc.collname, mdc.colldesc , collmdf.id as mdfid from (select * from NATIVEMDF INNER JOIN MDFORMAT on NATIVEMDF.mdfid= MDFORMAT.id) " +
"as COLLMDF,(select COLLECTION.id as collid, COLLECTION.name as collname, COLLECTION.description as colldesc, MDCOLLECTION.id as mdid from COLLECTION INNER JOIN MDCOLLECTION " +
"ON COLLECTION.id = MDCOLLECTION.relatedcollectionid) as MDC where COLLMDF.mdcollid= MDC.mdid "+preparedWhere+";");
*/
}catch(Exception e) { }catch(Exception e) {
logger.error("ModelService: getMEtadataRelatedToCollection Error ",e); logger.error("getMEtadataRelatedToCollection Error ",e);
throw new GCUBEFault(e); throw new GCUBEFault(e);
} }
return XMLUtil.PrepareMCFormatXML( nativeMetadataFormat ,selectedMetadataFormat); return Util.prepareMCFormat( nativeMetadataFormat ,selectedMetadataFormat);
} }
@ -389,7 +329,7 @@ public class ModelerService {
* @return an xml String containing selectable functionalities * @return an xml String containing selectable functionalities
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getFunctionality(VOID var) throws GCUBEFault { public FunctionalityList getFunctionality(VOID var) throws GCUBEFault {
ResultSet resFunct=null; ResultSet resFunct=null;
ResultSet selectedFuncRes=null; ResultSet selectedFuncRes=null;
@ -411,7 +351,7 @@ public class ModelerService {
throw new GCUBEFault(e); throw new GCUBEFault(e);
} }
return XMLUtil.PrepareFunctionalityXML(resFunct, selectedFunctionality, selectedCS); return new FunctionalityList(Util.prepareFunctionalities(resFunct, selectedFunctionality, selectedCS).toArray(new FunctionalityItem[0]));
} }
@ -476,7 +416,7 @@ public class ModelerService {
* @throws RemoteException - * @throws RemoteException -
*/ */
public String getQuality(VOID var) throws GCUBEFault{ public String getQuality(VOID var) throws GCUBEFault{
return XMLUtil.PrepareQualityXML(); return Util.prepareQualityXML();
} }
@ -500,7 +440,7 @@ public class ModelerService {
*/ */
public void setVREtoPendingState(VOID var) throws GCUBEFault{ public void setVREtoPendingState(VOID var) throws GCUBEFault{
try{ try{
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+PENDING+"' WHERE VRE.id='"+getResource().getId()+"';"); DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+VREState.PENDING+"' WHERE VRE.id='"+getResource().getId()+"';");
}catch(Exception e){throw new GCUBEFault(e);} }catch(Exception e){throw new GCUBEFault(e);}
} }
@ -520,7 +460,7 @@ public class ModelerService {
} }
try{ try{
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+DEPLOYING+"' WHERE VRE.id='"+resourceID+"';"); DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+VREState.DEPLOYING+"' WHERE VRE.id='"+resourceID+"';");
} catch (Exception e) { } catch (Exception e) {
logger.error("DB Error ",e); logger.error("DB Error ",e);
throw new GCUBEUnrecoverableFault(e); throw new GCUBEUnrecoverableFault(e);

View File

@ -10,9 +10,6 @@ import org.gcube.common.core.contexts.GCUBEServiceContext;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.notifier.ISNotifier; import org.gcube.common.core.informationsystem.notifier.ISNotifier;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.vremanagement.vremodeler.consumers.CollectionConsumer; import org.gcube.vremanagement.vremodeler.consumers.CollectionConsumer;
import org.gcube.vremanagement.vremodeler.consumers.GHNConsumer; import org.gcube.vremanagement.vremodeler.consumers.GHNConsumer;
import org.gcube.vremanagement.vremodeler.consumers.GenericResourceConsumer; import org.gcube.vremanagement.vremodeler.consumers.GenericResourceConsumer;
@ -72,12 +69,6 @@ public class ServiceContext extends GCUBEServiceContext{
this.setSecondaryTypeGenericResourceRequired(genResList.toArray(new String[0])); this.setSecondaryTypeGenericResourceRequired(genResList.toArray(new String[0]));
GCUBESecurityManager secMan= new GCUBESecurityManagerImpl(){
@Override
public boolean isSecurityEnabled() {
return false;
}};
IStoDBUtil.initDB(scope); IStoDBUtil.initDB(scope);
new GHNHandler().initialize(); new GHNHandler().initialize();
new CollectionHandler().initialize(); new CollectionHandler().initialize();
@ -89,23 +80,23 @@ public class ServiceContext extends GCUBEServiceContext{
//GHNNotification //GHNNotification
ArrayList<QName> qnameList= new ArrayList<QName>(); ArrayList<QName> qnameList= new ArrayList<QName>();
qnameList.add(GHNConsumer.ghnQName); qnameList.add(GHNConsumer.ghnQName);
notifier.registerToISNotification(qnameList, new GHNConsumer(scope), secMan, scope); notifier.registerToISNotification(qnameList, new GHNConsumer(scope), this, scope);
//RINotification //RINotification
qnameList= new ArrayList<QName>(); qnameList= new ArrayList<QName>();
qnameList.add(RunningInstanceConsumer.riQName); qnameList.add(RunningInstanceConsumer.riQName);
notifier.registerToISNotification(qnameList, new RunningInstanceConsumer(scope), secMan, scope); notifier.registerToISNotification(qnameList, new RunningInstanceConsumer(scope), this, scope);
//CollectionNotification //CollectionNotification
qnameList= new ArrayList<QName>(); qnameList= new ArrayList<QName>();
qnameList.add(CollectionConsumer.collectionQName); qnameList.add(CollectionConsumer.collectionQName);
notifier.registerToISNotification(qnameList, new CollectionConsumer(scope), secMan, scope); notifier.registerToISNotification(qnameList, new CollectionConsumer(scope), this, scope);
//MCollectionNotification //MCollectionNotification
qnameList= new ArrayList<QName>(); qnameList= new ArrayList<QName>();
qnameList.add(MCollectionConsumer.mCollectionQName); qnameList.add(MCollectionConsumer.mCollectionQName);
notifier.registerToISNotification(qnameList, new MCollectionConsumer(scope), secMan, scope); notifier.registerToISNotification(qnameList, new MCollectionConsumer(scope), this, scope);
//FunctionalityResource //FunctionalityResource
qnameList= new ArrayList<QName>(); qnameList= new ArrayList<QName>();
qnameList.add(GenericResourceConsumer.functionalityQName); qnameList.add(GenericResourceConsumer.functionalityQName);
notifier.registerToISNotification(qnameList, new GenericResourceConsumer(scope,functionalityHandler.getFunctionalityResourceId()), secMan, scope); notifier.registerToISNotification(qnameList, new GenericResourceConsumer(scope,functionalityHandler.getFunctionalityResourceId()), this, scope);
logger.debug("consumers registered"); logger.debug("consumers registered");
} }

View File

@ -21,14 +21,15 @@ import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl; import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl;
import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.common.resources.kxml.KGCUBEResource; import org.gcube.common.resources.kxml.KGCUBEResource;
import org.gcube.vremanagement.vremanager.stubs.vremanager.AddResourcesParameters; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
import org.gcube.vremanagement.vremanager.stubs.vremanager.OptionsParameters; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.CreateScopeParameters;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ResourceItem; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.OptionsParameters;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ResourceList; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ScopeOption; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceItem; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceList; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ScopeOption;
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.vremodeler.db.DBInterface; import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerContext; import org.gcube.vremanagement.vremodeler.impl.ModelerContext;
import org.gcube.vremanagement.vremodeler.impl.ModelerResource; import org.gcube.vremanagement.vremodeler.impl.ModelerResource;
@ -38,6 +39,7 @@ import org.gcube.vremanagement.vremodeler.impl.util.VREManagerServiceHandler;
import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation; import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation;
import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet; import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet;
import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation; import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation;
import org.gcube.vremanagement.vremodeler.stubs.VREState;
import org.globus.wsrf.ResourceException; import org.globus.wsrf.ResourceException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@ -76,7 +78,7 @@ public class DeployVRE extends Thread{
} }
if (GHNList.size()<2){ if (GHNList.size()<2){
throw new Exception("No ghn Selected (at least 2 GHNs have to be selcted)"); throw new Exception("No ghn Selected (at least 2 GHNs have to be selected)");
} }
@ -86,7 +88,7 @@ public class DeployVRE extends Thread{
for (Couple<String, String> cpl: GHNList) ghnEpuredList.add(cpl.first); for (Couple<String, String> cpl: GHNList) ghnEpuredList.add(cpl.first);
if (!createVRE(ghnEpuredList)){ if (!createVRE(ghnEpuredList)){
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';"); DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+VREState.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';");
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED"); logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
} }
else{ else{
@ -94,7 +96,7 @@ public class DeployVRE extends Thread{
throw new Exception("Error Deployng the VRE failed on second step"); throw new Exception("Error Deployng the VRE failed on second step");
} }
}else{ }else{
getResource().setSecondReport("FAILED"); getResource().setSecondReport(VREState.FAILED.getValue());
getResource().store(); getResource().store();
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED on first step"); logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED on first step");
throw new Exception("Error Deployng the VRE filed on first step"); throw new Exception("Error Deployng the VRE filed on first step");
@ -102,7 +104,7 @@ public class DeployVRE extends Thread{
}catch(Exception e){ }catch(Exception e){
try { try {
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.FAILED+"' WHERE VRE.id='"+this.resourceId+"';"); DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+VREState.FAILED+"' WHERE VRE.id='"+this.resourceId+"';");
} catch (Exception e1) { } catch (Exception e1) {
logger.error("impossible to update the VRE Status"+e1); logger.error("impossible to update the VRE Status"+e1);
} }
@ -130,7 +132,7 @@ public class DeployVRE extends Thread{
@SuppressWarnings({ "static-access", "unchecked" }) @SuppressWarnings({ "static-access", "unchecked" })
@Override @Override
protected Boolean makeCall(VREManagerPortType vreManagerPT) protected Boolean makeCall(ResourceManagerPortType resourceManagerPT)
throws Exception { throws Exception {
String report; String report;
try{ try{
@ -165,12 +167,12 @@ public class DeployVRE extends Thread{
arp.setServices(services); arp.setServices(services);
arp.setTargetScope(this.scope+"/"+vreName); arp.setTargetScope(this.scope+"/"+vreName);
String reportId=vreManagerPT.addResources(arp); String reportId=resourceManagerPT.addResources(arp);
int attempt=0; int attempt=0;
do{ do{
Thread.currentThread().sleep(20000); Thread.currentThread().sleep(20000);
report=vreManagerPT.getReport(reportId); report=resourceManagerPT.getReport(reportId);
attempt++; attempt++;
getResource().setFirstReport(report); getResource().setFirstReport(report);
getResource().store(); getResource().store();
@ -210,15 +212,14 @@ public class DeployVRE extends Thread{
//the parameter is resourceID //the parameter is resourceID
@SuppressWarnings("static-access") @SuppressWarnings("static-access")
@Override @Override
protected Boolean makeCall(VREManagerPortType vreManPortType) protected Boolean makeCall(ResourceManagerPortType rmPortType)
throws Exception { throws Exception {
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().second+" cannot be retrieved"); if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+this.getParameter().second+" cannot be retrieved");
ops=new OptionsParameters(); CreateScopeParameters scopeParameter=new CreateScopeParameters();
OptionsParameters optPar= 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");
@ -249,9 +250,10 @@ public class DeployVRE extends Thread{
soDisplayname.setName("DISPLAYNAME"); soDisplayname.setName("DISPLAYNAME");
soDisplayname.setValue(resGenericInfo.getString("name")); soDisplayname.setValue(resGenericInfo.getString("name"));
scopeOptionList[5]= soDisplayname; scopeOptionList[5]= soDisplayname;
ops.setScopeOptionList(scopeOptionList); optPar.setScopeOptionList(scopeOptionList);
vreManPortType.setScopeOptions(ops);
scopeParameter.setOptionsParameters(optPar);
//creating the GenericResources for Portlets and Collection //creating the GenericResources for Portlets and Collection
GenericResourcePortlet.createResource(getResource().getId(), vreName); GenericResourcePortlet.createResource(getResource().getId(), vreName);
@ -348,17 +350,15 @@ public class DeployVRE extends Thread{
arp.setServices(serviceList); arp.setServices(serviceList);
scopeParameter.setAddResourcesParameters(arp);
for (String ghn: this.getParameter().first){ scopeParameter.setName(this.scope+"/"+vreName);
logger.debug(ghn);
}
String report= "ok"; String report= "ok";
String reportId=vreManPortType.addResources(arp); String reportId=rmPortType.createScope(scopeParameter);
int attempt=0; int attempt=0;
do{ do{
Thread.currentThread().sleep(20000); Thread.currentThread().sleep(20000);
report=vreManPortType.getReport(reportId); report=rmPortType.getReport(reportId);
attempt++; attempt++;
getResource().setSecondReport(report); getResource().setSecondReport(report);
getResource().store(); getResource().store();

View File

@ -1,68 +0,0 @@
package org.gcube.vremanagement.vremodeler.impl.util;
import java.util.ArrayList;
import java.util.List;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext;
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.GCUBERunningInstance;
import org.gcube.common.core.utils.handlers.GCUBEServiceClient;
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler;
//import org.gcube.metadatamanagement.metadatabroker.stubs.MetadataBrokerPortType;
//import org.gcube.metadatamanagement.metadatabroker.stubs.service.MetadataBrokerServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
public abstract class MBrokerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
private T returnValue;
private P parameter;
public T getReturnValue(){
return returnValue;
}
public void setParameter(P param){
this.parameter= param;
}
protected P getParameter(){
return this.parameter;
}
protected void setReturnValue(T returnValue){
this.returnValue= returnValue;
}
@Override
protected List<EndpointReferenceType> findInstances() throws Exception {
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//ServiceName","MetadataBroker"));
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, ServiceContext.getContext().getScope()))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/metadatamanagement/MetadataBroker"));
return eprs;
}
//protected abstract T makeCall(MetadataBrokerPortType mbportType) throws Exception;
protected void interact(EndpointReferenceType arg0) throws Exception{
/*MetadataBrokerPortType mbpt= null;
try{
MetadataBrokerServiceAddressingLocator mbsal= new MetadataBrokerServiceAddressingLocator();
mbpt= mbsal.getMetadataBrokerPortTypePort(arg0);
mbpt = GCUBERemotePortTypeContext.getProxy(mbpt,ServiceContext.getContext().getScope());
this.setReturnValue(this.makeCall(mbpt));
}catch(Exception e){throw e;}
*/
}
}

View File

@ -0,0 +1,349 @@
package org.gcube.vremanagement.vremodeler.impl.util;
import java.io.StringWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
import org.gcube.vremanagement.vremodeler.stubs.CollectionType;
import org.gcube.vremanagement.vremodeler.stubs.CollectionTypeInfo;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityItem;
import org.gcube.vremanagement.vremodeler.stubs.GHNType;
import org.gcube.vremanagement.vremodeler.stubs.GHNTypeMemory;
import org.gcube.vremanagement.vremodeler.stubs.GHNTypeSite;
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatCollectionRelation;
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatItem;
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatRelation;
import org.gcube.vremanagement.vremodeler.stubs.MetadataFormatResponse;
import org.gcube.vremanagement.vremodeler.stubs.Report;
import org.gcube.vremanagement.vremodeler.stubs.RunningInstance;
import org.gcube.vremanagement.vremodeler.stubs.VREDescription;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author Lucio Lelii
*
*/
public class Util {
private static final GCUBELog logger = new GCUBELog(ModelerService.class.getName());
/**
* it creates the XML output for VDLGenerator
*
* @param res the result set of the query on database
* @return String the XML
*/
public static List<CollectionType> prepareCollections(ResultSet res, ArrayList<String> relatedCollection){
List<CollectionType> collectionList= new ArrayList<CollectionType>();
try{
while (res.next()){
CollectionType collection= new CollectionType();
collection.setId(res.getString(1));
collection.setName(res.getString(2));
Calendar creationTime = Calendar.getInstance();
creationTime.setTimeInMillis(Long.parseLong(res.getString(5)));
Calendar lastUpdateTime = Calendar.getInstance();
lastUpdateTime.setTimeInMillis(Long.parseLong(res.getString(6)));
collection.setInfo(new CollectionTypeInfo(creationTime, res.getString(3),lastUpdateTime, Integer.parseInt(res.getString(4))));
collection.setSelected(relatedCollection.contains(res.getString(1)));
collectionList.add(collection);
}
}catch(SQLException e){
logger.error("database error "+e.getMessage());
e.printStackTrace();
}
return collectionList;
}
/**
*
* @param res
* @param relatedGHNs
* @param candidateGHN
* @return
*/
public static List<GHNType> prepareGHNs(ResultSet res, ArrayList<String> relatedGHNs, String candidateGHN){
List<GHNType> ghnTypeList= new ArrayList<GHNType>();
try{
ResultSet riRes;
while (res.next()){
riRes= DBInterface.queryDB("select RI.id, RI.name, RI.class from RUNNINGINSTANCE as RI, GHNRELATEDRI as REL where REL.GHNID='"+res.getString("ID")+"' and REL.RIID=RI.ID");
int risNum=0;
List<RunningInstance> riList= new ArrayList<RunningInstance>();
while (riRes.next()){
if (!ServiceContext.getContext().getBaseServiceForGhn().contains(new ServicePair(riRes.getString(2),riRes.getString(3))))
risNum++;
riList.add(new RunningInstance(riRes.getString(3),riRes.getString(2)));
}
GHNType ghn= new GHNType();
ghn.setId(res.getString(1));
ghn.setSelectable(!(risNum>0));
ghn.setVreManagerUse(candidateGHN.compareTo(res.getString("ID"))==0);
ghn.setHost(res.getString(2));
ghn.setSecurity(res.getString(3));
ghn.setUpTime(res.getString(4));
ghn.setMemory(new GHNTypeMemory(res.getString(7),res.getString(5),res.getString(6)));
ghn.setSite(new GHNTypeSite(res.getString(9),res.getString(10),res.getString(8)));
ghn.setRelatedRIs(riList.toArray(new RunningInstance[riList.size()]));
ghnTypeList.add(ghn);
}
}catch(SQLException e){
logger.error("exception reised getting data from database",e);
}
return ghnTypeList;
}
private static <T> List<T> getDistinctObjects(Collection<T> list){
List<T> tmpList= new ArrayList<T>();
for (T el: list)
if (!tmpList.contains(el)) tmpList.add(el);
return tmpList;
}
/**
*
* @param res
* @return
*/
public static MetadataFormatResponse prepareMCFormat(Hashtable<ModelerCollection, List<MetadataFormat>> nativeMetadataFormat, Hashtable<ModelerCollection, List<MetadataFormat>> selectedMetadataFormat){
List<MetadataFormat> mdflistMultiple= new ArrayList<MetadataFormat>();
for (List<MetadataFormat> mftmpList: nativeMetadataFormat.values())
mdflistMultiple.addAll(mftmpList);
List<MetadataFormat> totalMDF= getDistinctObjects(mdflistMultiple);
List<MetadataFormatItem> metadataFormatItemList= new ArrayList<MetadataFormatItem>();
List<MetadataFormatCollectionRelation> metadataFormatRelationList= new ArrayList<MetadataFormatCollectionRelation>();
try{
for (MetadataFormat mf: totalMDF)
metadataFormatItemList.add(new MetadataFormatItem( mf.getId(),mf.getLanguage(),mf.getName(),mf.getSchemaURI().toString()));
//setting the native MDF
for(ModelerCollection key: nativeMetadataFormat.keySet()){
MetadataFormatCollectionRelation mfCollectionRelation= new MetadataFormatCollectionRelation();
mfCollectionRelation.setCollId(key.getId());
mfCollectionRelation.setDescription(key.getDescription());
mfCollectionRelation.setName(key.getName());
List<MetadataFormatRelation> mfList= new ArrayList<MetadataFormatRelation>();
for(MetadataFormat mf: nativeMetadataFormat.get(key))
if(selectedMetadataFormat.isEmpty() || ((selectedMetadataFormat.get(key)!=null) && selectedMetadataFormat.get(key).contains(mf)))
mfList.add(new MetadataFormatRelation(mf.getId(),true, true));
else mfList.add(new MetadataFormatRelation(mf.getId(),true, false));
mfCollectionRelation.setMfList(mfList.toArray(new MetadataFormatRelation[mfList.size()]));
metadataFormatRelationList.add(mfCollectionRelation);
}
}catch(Exception e){
logger.warn("error getting metadataFormats",e);
}
return new MetadataFormatResponse(metadataFormatRelationList.toArray(new MetadataFormatCollectionRelation[metadataFormatRelationList.size()]),metadataFormatItemList.toArray(new MetadataFormatItem[metadataFormatItemList.size()]));
}
/**
*
* @return the XML representing the quality string
*/
public static String prepareQualityXML(){
StringBuilder qualityString=new StringBuilder();
qualityString.append("<ResultSet>");
qualityString.append("<Quality><DisplayName>Response Time</DisplayName><Description>This quality parameter indicates the importance of response time (i.e., the delay from a function request to the reception of the response) ");
qualityString.append("in selecting the resource (both in number and type) needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% response time will result in a maximization of the resources ");
qualityString.append("allocated as to minimise the response time. </Description><Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Robustness</DisplayName><Description>This quality parameter indicates the importance of robustness (i.e., the resilience to faults) in selecting the resource (both in number and type)");
qualityString.append(" needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% robustness will result in a maximisation of the resources allocated as to minimise service unavailability.</Description><Multiple ");
qualityString.append(" value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Scalability</DisplayName><Description>This quality parameter indicates the importance of scalability (i.e., the capability to increase Digital Library Capacity as much as needed) in selecting the resource ");
qualityString.append("(both in number and type) needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% scalability will result in a maximisztion of the resources allocated as to minimise the response time.</Description>");
qualityString.append("<Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Re-use</DisplayName><Description>This quality parameter indicates the willingness to re-use existing resources (running instances, indexes, etc.) across various Digital Libraries. The specified ");
qualityString.append("percentage represents the degree of re-use of existing assets in concretely implementing the Digital Library.</Description><Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Capacity</DisplayName><Description>This quality parameter indicates the importance of capacity (i.e., the amount of resources allocated to the Digital Library) in selecting the resource (both in number and type) ");
qualityString.append("needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% capacity will result in a maximization of the amount of resources allocated to the Digital Library.");
qualityString.append(" </Description><Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Security</DisplayName><Description>A true/false quality parameter indicates whether the operations have to be executed in a fully authorised and authenticated environment (true value) or ");
qualityString.append("not (false value)</Description><Multiple value=\"false\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">Yes</Value><Value default=\"false\" selected=\"false\">No</Value></AllowedValues></Quality>");
qualityString.append("</ResultSet>");
return qualityString.toString();
}
/**
*
* @param res
* @param selectedFunct
* @param selectedCS
* @return
*/
public static List<FunctionalityItem> prepareFunctionalities(ResultSet res, ArrayList<Integer> selectedFunct, ArrayList<String> selectedCS){
List<FunctionalityItem> functionalityItemList= new ArrayList<FunctionalityItem>();
try {
while(res.next()){
FunctionalityItem functionlityItem= new FunctionalityItem();
functionlityItem.setId(res.getInt(1));
functionlityItem.setName(res.getString(2));
functionlityItem.setSelected(selectedFunct.contains(res.getInt(1)));
functionlityItem.setDescription(res.getString(3));
List<FunctionalityItem> subFunctionalities= new ArrayList<FunctionalityItem>();
ResultSet subFunctRes=DBInterface.queryDB("select * from FUNCTIONALITY where father='"+res.getInt(1)+"';");
while(subFunctRes.next()){
FunctionalityItem subFunctionalityItem= new FunctionalityItem();
subFunctionalityItem.setId(subFunctRes.getInt(1));
subFunctionalityItem.setName(subFunctRes.getString(2));
subFunctionalityItem.setDescription(subFunctRes.getString(3));
subFunctionalityItem.setSelected(selectedFunct.contains(subFunctRes.getInt(1)));
subFunctionalities.add(subFunctionalityItem);
}
functionlityItem.setChilds(subFunctionalities.toArray(new FunctionalityItem[subFunctionalities.size()]));
functionalityItemList.add(functionlityItem);
}
} catch (SQLException e) {
logger.error("DB error preparing Functionalities",e);
}
return functionalityItemList;
}
/**
*
* @param res
* @return a String representing the message
* @throws Exception
*/
public static VREDescription prepareVREDescription(ResultSet res) throws Exception{
VREDescription vreDescription= new VREDescription();
if (res.next()){
vreDescription.setName(res.getString(2));
vreDescription.setDescription(res.getString(3));
vreDescription.setDesigner(res.getString(4));
vreDescription.setManager(res.getString(5));
Calendar calendarStart= Calendar.getInstance();
calendarStart.setTime(res.getDate(6));
vreDescription.setStartTime(calendarStart);
Calendar calendarEnd= Calendar.getInstance();
calendarEnd.setTime(res.getDate(7));
vreDescription.setEndTime(calendarEnd);
}else{
Calendar calendarStart= Calendar.getInstance();
Calendar calendarEnd= Calendar.getInstance();
calendarEnd.add(Calendar.YEAR, 1);
vreDescription.setName(null);
vreDescription.setDescription(null);
vreDescription.setDesigner(null);
vreDescription.setManager(null);
vreDescription.setStartTime(calendarStart);
vreDescription.setEndTime(calendarEnd);
}
return vreDescription;
}
/**
*
* @param res
* @return
* @throws Exception
*/
public static List<Report> prepareVREsList(ResultSet res) throws Exception{
List<Report> reportList= new ArrayList<Report>();
while (res.next()){
Report reportItem= new Report();
reportItem.setId(res.getString(4));
reportItem.setDescription(res.getString(2));
reportItem.setName(res.getString(1));
reportItem.setState(res.getString(3));
reportList.add(reportItem);
}
return reportList;
}
/**
* transform a Document into string
*
* @param doc Document
* @return a String
*/
public static String docToString(Document doc){
String temp= null;
try{
DOMSource domSource = new DOMSource(doc);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty("encoding", "UTF-8");
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes" );
StringWriter sw= new StringWriter();
StreamResult sr= new StreamResult(sw);
serializer.transform(domSource, sr);
temp=sr.getWriter().toString();
}catch(Exception e){
logger.error("transformation to String Error");
e.printStackTrace();
}
return temp;
}
/**
*
* @param doc the root Document
* @param root the element tag name
* @param elements elements to add
* @return the result element
*/
public static Element addElements(Document doc, String root, Element[] elements){
Element returnEl= doc.createElement(root);
for (Element el: elements){
returnEl.appendChild(el);
}
return returnEl;
}
/**
*
* @param doc the root Document
* @param Tag the element tag name
* @param text the text to add at the element
* @return the result element
*/
public static Element createTextElement(Document doc, String tag, String text, Couple<String, String> ... attributes ){
Element returnEl= doc.createElement(tag);
if (attributes!=null){
for (Couple<String, String> attribute : attributes){
returnEl.setAttribute(attribute.first, attribute.second);
}
}
if (text!=null) returnEl.appendChild(doc.createTextNode(text));
return returnEl;
}
}

View File

@ -12,8 +12,8 @@ import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.handlers.GCUBEServiceClient; import org.gcube.common.core.utils.handlers.GCUBEServiceClient;
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler; import org.gcube.common.core.utils.handlers.GCUBEServiceHandler;
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator; import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext; import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> { public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
@ -64,18 +64,18 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
}catch(Exception e){logger.error(e); throw e;} }catch(Exception e){logger.error(e); throw e;}
} }
protected abstract T makeCall(VREManagerPortType mbportType) throws Exception; protected abstract T makeCall(ResourceManagerPortType rmPortType) throws Exception;
protected void interact(EndpointReferenceType epr) throws Exception{ protected void interact(EndpointReferenceType epr) throws Exception{
VREManagerPortType vmpt= null; ResourceManagerPortType rmpt= null;
try{ try{
VREManagerServiceAddressingLocator vmsal= new VREManagerServiceAddressingLocator(); ResourceManagerServiceAddressingLocator vmsal= new ResourceManagerServiceAddressingLocator();
vmpt= vmsal.getVREManagerPortTypePort(epr); rmpt= vmsal.getResourceManagerPortTypePort(epr);
vmpt = GCUBERemotePortTypeContext.getProxy(vmpt,scope, Integer.parseInt((String)ServiceContext.getContext().getProperty("vremanagerTimeout", true))); rmpt = GCUBERemotePortTypeContext.getProxy(rmpt,scope, Integer.parseInt((String)ServiceContext.getContext().getProperty("resourceManagerTimeout", true)));
this.usedhost= epr.getAddress().getHost(); this.usedhost= epr.getAddress().getHost();
this.setReturnValue(this.makeCall(vmpt)); this.setReturnValue(this.makeCall(rmpt));
}catch(Exception e){e.printStackTrace();throw e; } }catch(Exception e){e.printStackTrace();throw e; }
} }

View File

@ -1,486 +0,0 @@
package org.gcube.vremanagement.vremodeler.impl.util;
import java.io.StringWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author Lucio Lelii
*
*/
public class XMLUtil {
private static final GCUBELog logger = new GCUBELog(ModelerService.class.getName());
/**
* it creates the XML output for VDLGenerator
*
* @param res the result set of the query on database
* @return String the XML
*/
public static String PrepareCollectionXML(ResultSet res, ArrayList<String> relatedCollection){
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root= doc.createElement("ResultSet");
SimpleDateFormat simpleDateFormat= new SimpleDateFormat("dd-MM-yyyy 'at' HH:mm z");
try{
while (res.next()){
Element collection = addElements(doc, "Collection",
new Element[]{createTextElement(doc, "ID", res.getString(1)),
createTextElement(doc, "Name", res.getString(2)),
addElements(doc, "Info",
new Element[]{
createTextElement(doc, "Description",res.getString(3)),
createTextElement(doc, "NumberOfMembers",res.getString(4)),
createTextElement(doc, "CreationTime",simpleDateFormat.format(new Date(Long.parseLong(res.getString(5))))),
createTextElement(doc, "LastUpdateTime",simpleDateFormat.format(new Date(Long.parseLong(res.getString(6)))))
}),
createTextElement(doc, "Selected",relatedCollection.contains(res.getString(1)) ? "true" : "false") });
root.appendChild(collection);
}
}catch(SQLException e){
logger.error("database error "+e.getMessage());
e.printStackTrace();
}
doc.appendChild(root);
//logger.debug("VDLMODEL: request collection XML: "+temp);
return docToString(doc);
}
@SuppressWarnings("unchecked")
public static String PrepareGHNsXML(ResultSet res, ArrayList<String> relatedGHNs, String candidateGHN){
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root= doc.createElement("ResultSet");
ResultSet riRes;
try{
while (res.next()){
riRes= DBInterface.queryDB("select RI.id, RI.name, RI.class from RUNNINGINSTANCE as RI, GHNRELATEDRI as REL where REL.GHNID='"+res.getString("ID")+"' and REL.RIID=RI.ID");
Element risElement=doc.createElement("RunningInstances");
int risNum=0;
while (riRes.next()){
if (!ServiceContext.getContext().getBaseServiceForGhn().contains(new ServicePair(riRes.getString(2),riRes.getString(3))))
risNum++;
Element riElement=addElements(doc, "RunningInstance", new Element[]{
createTextElement(doc, "Name",riRes.getString(2)),
createTextElement(doc, "Class",riRes.getString(3))
});
risElement.appendChild(riElement);
}
Element ghnEl = addElements(doc, "GHN", new Element[]{
createTextElement(doc, "ID",res.getString(1),new Couple<String, String>("selectable", risNum>0?"false":"true"),new Couple<String, String>("VREManagerUse",(candidateGHN.compareTo(res.getString("ID"))==0?"true":"false"))),
createTextElement(doc, "Host",res.getString(2)),
addElements(doc, "Info", new Element[]{
risElement,
createTextElement(doc, "Security", res.getString(3)),
createTextElement(doc, "UpTime", res.getString(4)),
addElements(doc, "Memory", new Element[]{
createTextElement(doc, "VirtualAvailable", res.getString(5)),
createTextElement(doc, "VirtualSize", res.getString(6)),
createTextElement(doc, "LocalAvailableSpace", res.getString(7))}),
addElements(doc, "Site", new Element[]{
createTextElement(doc, "Location", res.getString(8)),
createTextElement(doc, "Country", res.getString(9)),
createTextElement(doc, "Domain", res.getString(10))}),
createTextElement(doc, "Libraries", null)}),
createTextElement(doc, "Selected", relatedGHNs.contains(res.getString("ID")) ? "true" : "false")
});
root.appendChild(ghnEl);
}
}catch(SQLException e){
logger.error("database error "+e.getMessage());
}
doc.appendChild(root);
//logger.debug("VDLMODEL: request collection XML: "+temp);
return docToString(doc);
}
private static <T> List<T> getDistinctObjects(Collection<T> list){
List<T> tmpList= new ArrayList<T>();
for (T el: list)
if (!tmpList.contains(el)) tmpList.add(el);
return tmpList;
}
/**
*
* @param res
* @return
*/
public static String PrepareMCFormatXML(Hashtable<ModelerCollection, List<MetadataFormat>> nativeMetadataFormat, Hashtable<ModelerCollection, List<MetadataFormat>> selectedMetadataFormat){
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
//Hashtable<String, Couple<Element, ArrayList<Element>>> MDFHash= new Hashtable<String, Couple<Element, ArrayList<Element>>>();
List<MetadataFormat> mdflistMultiple= new ArrayList<MetadataFormat>();
for (List<MetadataFormat> mftmpList: nativeMetadataFormat.values())
mdflistMultiple.addAll(mftmpList);
List<MetadataFormat> totalMDF= getDistinctObjects(mdflistMultiple);
Element collectionListEl= doc.createElement("CollectionList");
Element mflEl= doc.createElement("MFL");
try{
for (MetadataFormat mf: totalMDF)
{
Element elementEl=addElements(doc, "Element", new Element[]{
createTextElement(doc, "MFID", mf.getId()),
createTextElement(doc, "MFName", mf.getName()),
createTextElement(doc, "URI", mf.getSchemaURI().toString()),
createTextElement(doc, "Language", mf.getLanguage())
});
mflEl.appendChild(elementEl);
}
//setting the native MDF
for(ModelerCollection key: nativeMetadataFormat.keySet()){
Element collectionEl= addElements(doc, "Collection", new Element[]{
createTextElement(doc,"CollectionID" , key.getId()),
createTextElement(doc,"Name" , key.getName()),
createTextElement(doc,"Description" , key.getDescription())
});
for(MetadataFormat mf: nativeMetadataFormat.get(key)){
Element tmpEl;
if(selectedMetadataFormat.isEmpty() || ((selectedMetadataFormat.get(key)!=null) && selectedMetadataFormat.get(key).contains(mf))){
tmpEl= addElements(doc, "MetadataFormat", new Element[]{
createTextElement(doc, "Id", mf.getId()),
createTextElement(doc, "Selectable", "True"),
createTextElement(doc, "Selected", "True"),
});
}else {
tmpEl= addElements(doc, "MetadataFormat", new Element[]{
createTextElement(doc, "Id", mf.getId()),
createTextElement(doc, "Selectable", "True"),
createTextElement(doc, "Selected", "False"),
});
}
collectionEl.appendChild(tmpEl);
}
collectionListEl.appendChild(collectionEl);
}
//setting the derivable MDF
/* TODO: when metadataBroker will be ready for transformations
* while(resDerivable.next()){
Element tmpKeyEl= addElements(doc, "Collection", new Element[]{
createTextElement(doc,"CollectionID" , resDerivable.getString(1)),
createTextElement(doc,"Name" , resDerivable.getString(2)),
createTextElement(doc,"Description" , resDerivable.getString(3))
});
Element tmpEl;
if(selectedMetadata.isEmpty() || !(selectedMetadata.containsKey(resDerivable.getString(1))) && (selectedMetadata.get(resDerivable.getString(1)).contains(resDerivable.getString(4))))
tmpEl= addElements(doc, "MetadataFormat", new Element[]{
createTextElement(doc, "Id", resDerivable.getString(4)),
createTextElement(doc, "Selectable", "True"),
createTextElement(doc, "Selected", "False"),
});
else{
tmpEl= addElements(doc, "MetadataFormat", new Element[]{
createTextElement(doc, "Id", resDerivable.getString(4)),
createTextElement(doc, "Selectable", "False"),
createTextElement(doc, "Selected", "False"),
});
}
//logger.debug("MDFProva: Derivable "+keyTemp+" "+temp);
if(MDFHash.contains(resDerivable.getString(1))) MDFHash.get(resDerivable.getString(1)).second.add(tmpEl);
else{
tempArray=new ArrayList<Element>();
tempArray.add(tmpEl);
MDFHash.put(resDerivable.getString(1), new Couple<Element, ArrayList<Element>>(tmpKeyEl, tempArray) );
}
}
*/
}catch(Exception e){
e.printStackTrace();
}
doc.appendChild(addElements(doc, "ResultSet", new Element[]{mflEl, collectionListEl}));
//logger.debug("VDLMODEL: request MCFormat XML "+resultString);
return docToString(doc);
}
/**
*
* @return the XML representing the quality string
*/
public static String PrepareQualityXML(){
StringBuilder qualityString=new StringBuilder();
qualityString.append("<ResultSet>");
qualityString.append("<Quality><DisplayName>Response Time</DisplayName><Description>This quality parameter indicates the importance of response time (i.e., the delay from a function request to the reception of the response) ");
qualityString.append("in selecting the resource (both in number and type) needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% response time will result in a maximization of the resources ");
qualityString.append("allocated as to minimise the response time. </Description><Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Robustness</DisplayName><Description>This quality parameter indicates the importance of robustness (i.e., the resilience to faults) in selecting the resource (both in number and type)");
qualityString.append(" needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% robustness will result in a maximisation of the resources allocated as to minimise service unavailability.</Description><Multiple ");
qualityString.append(" value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Scalability</DisplayName><Description>This quality parameter indicates the importance of scalability (i.e., the capability to increase Digital Library Capacity as much as needed) in selecting the resource ");
qualityString.append("(both in number and type) needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% scalability will result in a maximisztion of the resources allocated as to minimise the response time.</Description>");
qualityString.append("<Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Re-use</DisplayName><Description>This quality parameter indicates the willingness to re-use existing resources (running instances, indexes, etc.) across various Digital Libraries. The specified ");
qualityString.append("percentage represents the degree of re-use of existing assets in concretely implementing the Digital Library.</Description><Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Capacity</DisplayName><Description>This quality parameter indicates the importance of capacity (i.e., the amount of resources allocated to the Digital Library) in selecting the resource (both in number and type) ");
qualityString.append("needed to satisfy the Digital Library definition criteria. E.g., the specification of a 100% capacity will result in a maximization of the amount of resources allocated to the Digital Library.");
qualityString.append(" </Description><Multiple value=\"true\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">*</Value></AllowedValues></Quality>");
qualityString.append("<Quality><DisplayName>Security</DisplayName><Description>A true/false quality parameter indicates whether the operations have to be executed in a fully authorised and authenticated environment (true value) or ");
qualityString.append("not (false value)</Description><Multiple value=\"false\"/><CanBeEmpty value=\"false\"/><AllowedValues><Value default=\"true\" selected=\"false\">Yes</Value><Value default=\"false\" selected=\"false\">No</Value></AllowedValues></Quality>");
qualityString.append("</ResultSet>");
return qualityString.toString();
}
/**
*
* @param res
* @param selectedFunct
* @param selectedCS
* @return
*/
@SuppressWarnings("unchecked")
public static String PrepareFunctionalityXML(ResultSet res, ArrayList<Integer> selectedFunct, ArrayList<String> selectedCS){
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root= doc.createElement("Resultset");
try {
while(res.next()){
Element functionalityEl= createTextElement(doc, "Functionality", null, new Couple<String, String>("id", res.getInt(1)+""),
new Couple<String, String>("name", res.getString(2)),
new Couple<String, String>("enableCS", res.getInt(1)==10 ? "true": "false"),
new Couple<String, String>("selected", selectedFunct.contains(res.getInt(1)) ? "true" : "false")
);
functionalityEl.appendChild(createTextElement(doc, "FunctionalityDescription", res.getString(3)));
ResultSet subFunctRes=DBInterface.queryDB("select * from FUNCTIONALITY where father='"+res.getInt(1)+"';");
while(subFunctRes.next()){
Element subFunctEl=createTextElement(doc,"Functionality" , null, new Couple<String, String>("id", subFunctRes.getInt(1)+""),
new Couple<String, String>("name", subFunctRes.getString(2)),
new Couple<String, String>("selected", selectedFunct.contains(subFunctRes.getInt(1)) ? "true" : "false"));
subFunctEl.appendChild(createTextElement(doc, "FunctionalityDescription", subFunctRes.getString(3)));
functionalityEl.appendChild(addElements(doc, "child", new Element[]{subFunctEl}));
}
root.appendChild(functionalityEl);
}
} catch (SQLException e) {
logger.error("VDLModelService: DB error preparing XML for Functionality");
e.printStackTrace();
}
try {
ResultSet csRes=DBInterface.queryDB("select * from cs;");
if (csRes.next()){
Element csEl= createTextElement(doc, "CS", null, new Couple<String, String>("id", "-1"), new Couple<String, String>("name", "Workflows"), new Couple<String, String>("selected", "false"));
csEl.appendChild(createTextElement(doc,"CSDescription" , "This class of functions contains compound functions defined by aggregating existing functions in structured workflows as to deliver advanced features."));
do{
Element subCsEl= createTextElement(doc, "CS", null, new Couple<String, String>("id", csRes.getString(1)), new Couple<String, String>("name", csRes.getString(2)), new Couple<String, String>("selected", selectedCS.contains(csRes.getString(1)) ? "true" : "false"));
subCsEl.appendChild(createTextElement(doc,"CSDescription" , csRes.getString(3)));
csEl.appendChild(addElements(doc, "child", new Element[]{subCsEl}));
}while (csRes.next());
root.appendChild(csEl);
}
} catch (SQLException e) {
logger.error("VDLModelService: DB error retreiving CS");
e.printStackTrace();
}
doc.appendChild(root);
return docToString(doc);
}
/**
*
* @param res
* @return a String representing the message
* @throws Exception
*/
@SuppressWarnings("deprecation")
public static String PrepareVREModelXML(ResultSet res) throws Exception{
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root;
if (res.next()){
root= addElements(doc, "Resultset", new Element[]{
createTextElement(doc, "Name",res.getString(2)),
createTextElement(doc, "Description",res.getString(3)),
createTextElement(doc, "VREDesigner",res.getString(4)),
createTextElement(doc, "VREManager",res.getString(5)),
createTextElement(doc, "StartTime",res.getDate(6).getTime()+""),
createTextElement(doc, "EndTime",res.getDate(7).getTime()+""),
});
}else{
Date dateFrom=new Date();
Date dateTo=new Date();
dateTo.setYear(dateTo.getYear()+1);
root= addElements(doc, "Resultset", new Element[]{
createTextElement(doc, "Name",null),
createTextElement(doc, "Description",null),
createTextElement(doc, "VREDesigner",null),
createTextElement(doc, "VREManager",null),
createTextElement(doc, "StartTime",dateFrom.getTime()+""),
createTextElement(doc, "EndTime",dateTo.getTime()+"")
});
}
doc.appendChild(root);
return docToString(doc);
}
public static String PrepareAllVREsXML(ResultSet res) throws Exception{
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root= doc.createElement("ResultSet");
Element vreEl;
while (res.next()){
vreEl= addElements(doc, "VRE", new Element[]{
createTextElement(doc, "Name",res.getString(1)),
createTextElement(doc, "Description",res.getString(2)),
createTextElement(doc, "State",res.getString(3)),
createTextElement(doc, "EPR",res.getString(4))
});
root.appendChild(vreEl);
}
doc.appendChild(root);
return docToString(doc);
}
/**
* transform a Document into string
*
* @param doc Document
* @return a String
*/
public static String docToString(Document doc){
String temp= null;
try{
DOMSource domSource = new DOMSource(doc);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty("encoding", "UTF-8");
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes" );
StringWriter sw= new StringWriter();
StreamResult sr= new StreamResult(sw);
serializer.transform(domSource, sr);
temp=sr.getWriter().toString();
}catch(Exception e){
logger.error("transformation to String Error");
e.printStackTrace();
}
return temp;
}
/**
*
* @param doc the root Document
* @param root the element tag name
* @param elements elements to add
* @return the result element
*/
public static Element addElements(Document doc, String root, Element[] elements){
Element returnEl= doc.createElement(root);
for (Element el: elements){
returnEl.appendChild(el);
}
return returnEl;
}
/**
*
* @param doc the root Document
* @param Tag the element tag name
* @param text the text to add at the element
* @return the result element
*/
public static Element createTextElement(Document doc, String tag, String text, Couple<String, String> ... attributes ){
Element returnEl= doc.createElement(tag);
if (attributes!=null){
for (Couple<String, String> attribute : attributes){
returnEl.setAttribute(attribute.first, attribute.second);
}
}
if (text!=null) returnEl.appendChild(doc.createTextNode(text));
return returnEl;
}
}

View File

@ -10,7 +10,7 @@ import org.gcube.common.core.resources.GCUBEGenericResource;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.vremanagement.vremodeler.db.DBInterface; import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext; import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil; import org.gcube.vremanagement.vremodeler.impl.util.Util;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -25,10 +25,10 @@ public class GenericResourcePortlet {
ResultSet rs= DBInterface.queryDB("select DISTINCT pf.PORTLETCLASS from PORTLETRELTOFUNCT as pf, VRERELATEDFUNCT as vf where vf.vreid='"+vreId+"' and pf.FUNCID=vf.FUNCID"); ResultSet rs= DBInterface.queryDB("select DISTINCT pf.PORTLETCLASS from PORTLETRELTOFUNCT as pf, VRERELATEDFUNCT as vf where vf.vreid='"+vreId+"' and pf.FUNCID=vf.FUNCID");
Element root= doc.createElement("ListPortlets"); Element root= doc.createElement("ListPortlets");
while(rs.next()) while(rs.next())
root.appendChild(XMLUtil.createTextElement(doc, "Portlet", rs.getString(1))); root.appendChild(Util.createTextElement(doc, "Portlet", rs.getString(1)));
doc.appendChild(root); doc.appendChild(root);
resource.setBody(XMLUtil.docToString(doc)); resource.setBody(Util.docToString(doc));
resource.setDescription("List of selectable Portlet for the VRE "+vreName); resource.setDescription("List of selectable Portlet for the VRE "+vreName);
resource.setName("AvailablePortlets"); resource.setName("AvailablePortlets");

View File

@ -32,7 +32,7 @@ public class MCollectionHandler implements ResourceHandler<GCUBEMCollection> {
} }
public void drop(String resourceId) throws Exception { public void drop(String resourceId) throws Exception {
// TODO Auto-generated method stub DBInterface.deleteElement(tableName, "ID='"+resourceId+"'");
} }
public void initialize() throws Exception { public void initialize() throws Exception {

View File

@ -0,0 +1,20 @@
package org.gcube.vremanagement.vremodeler.stubs;
public enum VREState {
DEPLOYED("Deployed"),
IN_PROGRESS("In Progress"),
FAILED("Failed"),
PENDING("Pending"),
DEPLOYING("Deploying");
private String value;
VREState(String value){
this.value= value;
}
public String getValue(){
return this.value;
}
}

View File

@ -17,7 +17,6 @@ import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
import org.gcube.vremanagement.vremodeler.stubs.GHNArray; import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
import org.gcube.vremanagement.vremodeler.stubs.ModelerFactoryPortType; import org.gcube.vremanagement.vremodeler.stubs.ModelerFactoryPortType;
import org.gcube.vremanagement.vremodeler.stubs.ModelerServicePortType; import org.gcube.vremanagement.vremodeler.stubs.ModelerServicePortType;
import org.gcube.vremanagement.vremodeler.stubs.VRERequest;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerFactoryServiceAddressingLocator; import org.gcube.vremanagement.vremodeler.stubs.service.ModelerFactoryServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerServiceAddressingLocator; import org.gcube.vremanagement.vremodeler.stubs.service.ModelerServiceAddressingLocator;
@ -27,6 +26,7 @@ public class ModelerTest {
public static void main(String[] args) { public static void main(String[] args) {
try{ try{
/*
ISClient client = GHNContext.getImplementation(ISClient.class); ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery riquery= client.getQuery(GCUBERIQuery.class); GCUBERIQuery riquery= client.getQuery(GCUBERIQuery.class);
riquery.addAtomicConditions(new AtomicCondition("//ServiceName", "VREModeler")); riquery.addAtomicConditions(new AtomicCondition("//ServiceName", "VREModeler"));