git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@15969 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
11ca4a5f4d
commit
1938782e83
2
.project
2
.project
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>InformationCollector_previous</name>
|
<name>InformationCollector_branched</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
sink by collecting and exposing the information published by the
|
sink by collecting and exposing the information published by the
|
||||||
registered gCube services</Description>
|
registered gCube services</Description>
|
||||||
<Name>IS-Collector-service</Name>
|
<Name>IS-Collector-service</Name>
|
||||||
<Version>2.0.0</Version>
|
<Version>2.1.0</Version>
|
||||||
<Dependencies>
|
<Dependencies>
|
||||||
<Dependency>
|
<Dependency>
|
||||||
<Service>
|
<Service>
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
</Service>
|
</Service>
|
||||||
<Package>IS-Collector-stubs</Package>
|
<Package>IS-Collector-stubs</Package>
|
||||||
<Version>[2.0.0]</Version>
|
<Version>[2.1.0]</Version>
|
||||||
<Scope level="GHN" />
|
<Scope level="GHN" />
|
||||||
<Optional>false</Optional>
|
<Optional>false</Optional>
|
||||||
</Dependency>
|
</Dependency>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
<Software deployable="true">
|
<Software deployable="true">
|
||||||
<Description>InformationCollector Stubs</Description>
|
<Description>InformationCollector Stubs</Description>
|
||||||
<Name>IS-Collector-stubs</Name>
|
<Name>IS-Collector-stubs</Name>
|
||||||
<Version>2.0.0</Version>
|
<Version>2.1.0</Version>
|
||||||
<MultiVersion value="true" />
|
<MultiVersion value="true" />
|
||||||
<Mandatory level="VO" />
|
<Mandatory level="VO" />
|
||||||
<Shareable level="VO" />
|
<Shareable level="VO" />
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
<Software>
|
<Software>
|
||||||
<Description>Test-suite for IS-Collector: provide sample usages of interaction with a IS-Collector instance</Description>
|
<Description>Test-suite for IS-Collector: provide sample usages of interaction with a IS-Collector instance</Description>
|
||||||
<Name>IS-Collector-test-suite</Name>
|
<Name>IS-Collector-test-suite</Name>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.1.0</Version>
|
||||||
<MultiVersion value="true"/>
|
<MultiVersion value="true"/>
|
||||||
<Shareable level="VO"/>
|
<Shareable level="VO"/>
|
||||||
<Type>application</Type>
|
<Type>application</Type>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||||
xmlns:asgt="http://mds.globus.org/aggregator/types"
|
xmlns:asgt="http://mds.globus.org/aggregator/types"
|
||||||
|
xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults"
|
||||||
xmlns:wsrlw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl"
|
xmlns:wsrlw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl"
|
||||||
xmlns:wsdlpp="http://www.globus.org/namespaces/2004/10/WSDLPreprocessor"
|
xmlns:wsdlpp="http://www.globus.org/namespaces/2004/10/WSDLPreprocessor"
|
||||||
xmlns:gtwsdl1="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.wsdl"
|
xmlns:gtwsdl1="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.wsdl"
|
||||||
|
@ -16,7 +17,7 @@
|
||||||
<wsdl:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.wsdl" location="../wsrf/faults/WS-BaseFaults.wsdl"/>
|
<wsdl:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.wsdl" location="../wsrf/faults/WS-BaseFaults.wsdl"/>
|
||||||
<wsdl:import namespace="http://mds.globus.org/aggregator" location="../mds/aggregator/aggregator_service_group_port_type.wsdl"/>
|
<wsdl:import namespace="http://mds.globus.org/aggregator" location="../mds/aggregator/aggregator_service_group_port_type.wsdl"/>
|
||||||
<wsdl:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.wsdl" location="../wsrf/servicegroup/WS-ServiceGroup.wsdl"/>
|
<wsdl:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.wsdl" location="../wsrf/servicegroup/WS-ServiceGroup.wsdl"/>
|
||||||
|
<wsdl:import namespace="http://gcube-system.org/namespaces/common/core/faults" location="../gcube/common/core/faults/GCUBEFaults.wsdl"/>
|
||||||
|
|
||||||
<!--============================================================
|
<!--============================================================
|
||||||
|
|
||||||
|
@ -44,6 +45,10 @@
|
||||||
|
|
||||||
<xsd:element name="deleteResponse" type="xsd:boolean"/>
|
<xsd:element name="deleteResponse" type="xsd:boolean"/>
|
||||||
|
|
||||||
|
<xsd:element name="getProfileResponse" type="xsd:string"/>
|
||||||
|
|
||||||
|
<xsd:element name="getResourceResponse" type="xsd:string"/>
|
||||||
|
|
||||||
<xsd:element name="deleteProfileParams">
|
<xsd:element name="deleteProfileParams">
|
||||||
<xsd:complexType >
|
<xsd:complexType >
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
|
@ -53,8 +58,37 @@
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
|
|
||||||
|
<xsd:element name="GetProfileCriteria">
|
||||||
|
<xsd:complexType >
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="ID" type="xsd:string"/>
|
||||||
|
<xsd:element name="profileType" type="xsd:string"/>
|
||||||
|
</xsd:sequence>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
|
<xsd:element name="GetResourceCriteria">
|
||||||
|
<xsd:complexType >
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="ID" type="xsd:string"/>
|
||||||
|
</xsd:sequence>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
<xsd:complexType name="voidType"/>
|
<xsd:complexType name="voidType"/>
|
||||||
|
|
||||||
<xsd:element name="voidElement" type="tns:voidType"/>
|
<xsd:element name="voidElement" type="tns:voidType"/>
|
||||||
|
|
||||||
|
<xsd:element name="DocumentNotFoundFaultType">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:complexContent>
|
||||||
|
<xsd:extension base="corefaults:GCUBEUnrecoverableFault">
|
||||||
|
<xsd:sequence/>
|
||||||
|
</xsd:extension>
|
||||||
|
</xsd:complexContent>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
</xsd:schema>
|
</xsd:schema>
|
||||||
</wsdl:types>
|
</wsdl:types>
|
||||||
|
|
||||||
|
@ -73,6 +107,14 @@
|
||||||
<part name="parameters" element="tns:deleteResponse"/>
|
<part name="parameters" element="tns:deleteResponse"/>
|
||||||
</wsdl:message>
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="GetResourceInputMessage">
|
||||||
|
<part name="parameters" element="tns:GetResourceCriteria"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="GetResourceOutputMessage">
|
||||||
|
<part name="parameters" element="tns:getResourceResponse"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
<wsdl:message name="DeleteProfileInputMessage">
|
<wsdl:message name="DeleteProfileInputMessage">
|
||||||
<part name="parameters" element="tns:deleteProfileParams"/>
|
<part name="parameters" element="tns:deleteProfileParams"/>
|
||||||
</wsdl:message>
|
</wsdl:message>
|
||||||
|
@ -81,10 +123,22 @@
|
||||||
<part name="parameters" element="tns:deleteResponse"/>
|
<part name="parameters" element="tns:deleteResponse"/>
|
||||||
</wsdl:message>
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="GetProfileInputMessage">
|
||||||
|
<part name="parameters" element="tns:GetProfileCriteria"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="GetProfileOutputMessage">
|
||||||
|
<part name="parameters" element="tns:getProfileResponse"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
<wsdl:message name="VoidMessage">
|
<wsdl:message name="VoidMessage">
|
||||||
<part name="parameters" element="tns:voidElement"/>
|
<part name="parameters" element="tns:voidElement"/>
|
||||||
</wsdl:message>
|
</wsdl:message>
|
||||||
|
|
||||||
|
<wsdl:message name="DocumentNotFoundFaultTypeMessage">
|
||||||
|
<part name="fault" element="tns:DocumentNotFoundFaultType"/>
|
||||||
|
</wsdl:message>
|
||||||
|
|
||||||
<!--============================================================
|
<!--============================================================
|
||||||
|
|
||||||
P O R T T Y P E
|
P O R T T Y P E
|
||||||
|
@ -93,6 +147,16 @@
|
||||||
|
|
||||||
<wsdl:portType name="XMLCollectionAccessPortType">
|
<wsdl:portType name="XMLCollectionAccessPortType">
|
||||||
|
|
||||||
|
<wsdl:operation name="GetProfile">
|
||||||
|
<wsdl:input message="tns:GetProfileInputMessage"/>
|
||||||
|
<wsdl:output message="tns:GetProfileOutputMessage"/>
|
||||||
|
<wsdl:fault name="fault" message="tns:DocumentNotFoundFaultTypeMessage"/>
|
||||||
|
</wsdl:operation>
|
||||||
|
<wsdl:operation name="GetResource">
|
||||||
|
<wsdl:input message="tns:GetResourceInputMessage"/>
|
||||||
|
<wsdl:output message="tns:GetResourceOutputMessage"/>
|
||||||
|
<wsdl:fault name="fault" message="tns:DocumentNotFoundFaultTypeMessage"/>
|
||||||
|
</wsdl:operation>
|
||||||
<wsdl:operation name="DeleteResource">
|
<wsdl:operation name="DeleteResource">
|
||||||
<wsdl:input message="tns:DeleteResourceInputMessage"/>
|
<wsdl:input message="tns:DeleteResourceInputMessage"/>
|
||||||
<wsdl:output message="tns:DeleteResourceOutputMessage"/>
|
<wsdl:output message="tns:DeleteResourceOutputMessage"/>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
@ -21,6 +22,13 @@ import org.w3c.dom.*;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
import javax.xml.parsers.*;
|
import javax.xml.parsers.*;
|
||||||
|
import javax.xml.transform.OutputKeys;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
import javax.xml.xpath.*;
|
import javax.xml.xpath.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,8 +54,7 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
private String profile_type = null;
|
private String profile_type = null;
|
||||||
|
|
||||||
// the various parts of the resource
|
// the various parts of the resource
|
||||||
private String data, /* service_class, service_id, ri_id, ghn_id, scope, */
|
private String data = null, entryKey, groupKey, source, sourceKey = "", completeSourceKey = "";
|
||||||
entryKey, groupKey, source, sourceKey = "", completeSourceKey = "";
|
|
||||||
|
|
||||||
private Calendar terminationTime = null, lastUpdateTime = null;
|
private Calendar terminationTime = null, lastUpdateTime = null;
|
||||||
|
|
||||||
|
@ -95,6 +102,8 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
* if the resource is invalid
|
* if the resource is invalid
|
||||||
*/
|
*/
|
||||||
public AggregatorPersistentResource(XMLResource resource) throws Exception {
|
public AggregatorPersistentResource(XMLResource resource) throws Exception {
|
||||||
|
if (resource == null)
|
||||||
|
throw new Exception("invalid resource");
|
||||||
try {
|
try {
|
||||||
this.resourceID = resource.getId();
|
this.resourceID = resource.getId();
|
||||||
this.originalSource = resource;
|
this.originalSource = resource;
|
||||||
|
@ -161,11 +170,35 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
* Accesses the resource content
|
* Accesses the resource content
|
||||||
*
|
*
|
||||||
* @return the content
|
* @return the content
|
||||||
|
* @throws MalformedResourceException
|
||||||
*/
|
*/
|
||||||
public String getData() {
|
public String getData() throws MalformedResourceException {
|
||||||
|
if (this.data == null)
|
||||||
|
this.data = this.extractData();
|
||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* @throws MalformedResourceException
|
||||||
|
*/
|
||||||
|
private String extractData() throws MalformedResourceException {
|
||||||
|
|
||||||
|
if (this.internalDOM != null) {
|
||||||
|
try {
|
||||||
|
if (this.getType() == RESOURCETYPE.Profile)
|
||||||
|
return nodeToString(internalDOM.getElementsByTagName("Resource").item(0)); //Data/Profile/Resource
|
||||||
|
else
|
||||||
|
return nodeToString(internalDOM.getElementsByTagName("Data").item(0)); //Data/*
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
throw new MalformedResourceException("unable to retrieve data for resource " + this.getID());
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
throw new MalformedResourceException("unable to retrieve data for resource " + this.getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the original XMLResource from which the resource has been
|
* @return the original XMLResource from which the resource has been
|
||||||
|
@ -299,9 +332,27 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
* @return the type
|
* @return the type
|
||||||
*/
|
*/
|
||||||
public RESOURCETYPE getType() {
|
public RESOURCETYPE getType() {
|
||||||
|
if (this.type == null)
|
||||||
|
this.type = this.extractType();
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private RESOURCETYPE extractType() {
|
||||||
|
if (internalDOM.getElementsByTagName("Resource").getLength() > 0) {
|
||||||
|
logger.trace("The resource is a profile");
|
||||||
|
return RESOURCETYPE.Profile;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.trace("The resource is a RP");
|
||||||
|
return RESOURCETYPE.Properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the resource body
|
* Updates the resource body
|
||||||
*
|
*
|
||||||
|
@ -321,27 +372,24 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
*/
|
*/
|
||||||
private String toXML() {
|
private String toXML() {
|
||||||
|
|
||||||
String rep = "<Document>\n";
|
StringBuilder resource = new StringBuilder("<Document>\n");
|
||||||
rep += "<ID>" + this.getID() + "</ID>\n";
|
resource.append("<ID>" + this.getID() + "</ID>\n");
|
||||||
rep += "<Source>" + this.getSource() + "</Source>\n";
|
resource.append("<Source>" + this.getSource() + "</Source>\n");
|
||||||
rep += "<SourceKey>" + this.getSourceKey() + "</SourceKey>\n";
|
resource.append("<SourceKey>" + this.getSourceKey() + "</SourceKey>\n");
|
||||||
rep += "<CompleteSourceKey>" + this.getCompleteSourceKey()
|
resource.append("<CompleteSourceKey>" + this.getCompleteSourceKey() + "</CompleteSourceKey>\n");
|
||||||
+ "</CompleteSourceKey>\n";
|
resource.append("<EntryKey>" + this.getEntryKey() + "</EntryKey>\n");
|
||||||
rep += "<EntryKey>" + this.getEntryKey() + "</EntryKey>\n";
|
resource.append("<GroupKey>" + this.getGroupKey() + "</GroupKey>\n");
|
||||||
rep += "<GroupKey>" + this.getGroupKey() + "</GroupKey>\n";
|
resource.append("<TerminationTime>"+ this.getTerminationTime().getTimeInMillis()+ "</TerminationTime>\n");
|
||||||
rep += "<TerminationTime>"
|
resource.append("<TerminationTimeHuman>" + this.getTerminationTime().getTime().toString()+ "</TerminationTimeHuman>\n");
|
||||||
+ this.getTerminationTime().getTimeInMillis()
|
resource.append("<LastUpdateMs>" + this.lastUpdateTime.getTimeInMillis()+ "</LastUpdateMs>\n");
|
||||||
+ "</TerminationTime>\n";
|
resource.append("<LastUpdateHuman>" + this.lastUpdateTime.getTime().toString() + "</LastUpdateHuman>\n");
|
||||||
rep += "<TerminationTimeHuman>"
|
try {
|
||||||
+ this.getTerminationTime().getTime().toString()
|
resource.append(this.getData() + "\n");
|
||||||
+ "</TerminationTimeHuman>\n";
|
} catch (MalformedResourceException e) {
|
||||||
rep += "<LastUpdateMs>" + this.lastUpdateTime.getTimeInMillis()
|
logger.warn("Unable to read the resource data",e);
|
||||||
+ "</LastUpdateMs>\n";
|
}
|
||||||
rep += "<LastUpdateHuman>" + this.lastUpdateTime.getTime().toString()
|
resource.append( "</Document>\n");
|
||||||
+ "</LastUpdateHuman>\n";
|
return resource.toString();
|
||||||
rep += this.getData() + "\n";
|
|
||||||
rep += "</Document>\n";
|
|
||||||
return rep;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -495,4 +543,29 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
public void setPublisher(String publisher) {
|
public void setPublisher(String publisher) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Node to String helper
|
||||||
|
* @param node the source node
|
||||||
|
* @return the node content serialized as string
|
||||||
|
* @throws Exception if the serialization fails
|
||||||
|
*/
|
||||||
|
private String nodeToString(Node node) throws Exception{
|
||||||
|
try {
|
||||||
|
TransformerFactory transFactory = TransformerFactory.newInstance();
|
||||||
|
Transformer transformer = transFactory.newTransformer();
|
||||||
|
StringWriter buffer = new StringWriter();
|
||||||
|
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
|
transformer.transform(new DOMSource(node), new StreamResult(buffer));
|
||||||
|
return buffer.toString();
|
||||||
|
|
||||||
|
} catch (TransformerConfigurationException e) {
|
||||||
|
logger.error("Unable to deserialise content data", e);
|
||||||
|
throw new Exception("Unable to deserialise content data");
|
||||||
|
} catch (TransformerException e) {
|
||||||
|
logger.error("Unable to deserialise content data", e);
|
||||||
|
throw new Exception("Unable to deserialise content data");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,13 @@ import org.gcube.common.core.contexts.GCUBEServiceContext;
|
||||||
import org.gcube.common.core.porttypes.GCUBEPortType;
|
import org.gcube.common.core.porttypes.GCUBEPortType;
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext;
|
import org.gcube.informationsystem.collector.impl.contexts.ICServiceContext;
|
||||||
|
import org.gcube.informationsystem.collector.impl.persistence.AggregatorPersistentResource;
|
||||||
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.State;
|
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.State;
|
||||||
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.Sweeper;
|
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.Sweeper;
|
||||||
import org.gcube.informationsystem.collector.stubs.DeleteProfileParams;
|
import org.gcube.informationsystem.collector.stubs.DeleteProfileParams;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.DocumentNotFoundFaultType;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.GetProfileCriteria;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.GetResourceCriteria;
|
||||||
|
|
||||||
import org.globus.wsrf.utils.FaultHelper;
|
import org.globus.wsrf.utils.FaultHelper;
|
||||||
|
|
||||||
|
@ -145,38 +149,28 @@ public class XMLCollectionAccess extends GCUBEPortType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getResource(GetResourceCriteria criteria) throws DocumentNotFoundFaultType {
|
||||||
* Disposes the State service
|
|
||||||
*
|
|
||||||
* @throws BaseFaultType
|
|
||||||
* if the shutdown fails
|
|
||||||
*/
|
|
||||||
public void dispose() throws BaseFaultType {
|
|
||||||
/*try {
|
|
||||||
logger.info("Dispose operation invoked");
|
|
||||||
logger.info("trying to shutdown the storage instances...");
|
|
||||||
try {
|
try {
|
||||||
State.storage_manager.shutdown();
|
AggregatorPersistentResource aresource = State.getDataManager().retrievePropertyResourceFromID(criteria.getID());
|
||||||
State.query_manager.shutdown();
|
logger.debug("Returning resource:" + aresource.getData());
|
||||||
} catch (NullPointerException se) {
|
return aresource.getData();
|
||||||
}
|
|
||||||
State.storage_manager = null;
|
|
||||||
State.query_manager = null;
|
|
||||||
// request the interruption of the sweeper thread
|
|
||||||
State.sweeperT.interrupt();
|
|
||||||
logger.info("done");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("unable to pose the IC with success ", e);
|
logger.warn("Unable to find Resource with ID=" + criteria.getID(), e);
|
||||||
BaseFaultType fault = new BaseFaultType();
|
throw new DocumentNotFoundFaultType();
|
||||||
FaultHelper faultHelper = new FaultHelper(fault);
|
|
||||||
faultHelper.addFaultCause(e);
|
|
||||||
faultHelper
|
|
||||||
.addDescription("-IC service: Unable to pose the service");
|
|
||||||
throw fault;
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfile(GetProfileCriteria criteria) throws DocumentNotFoundFaultType {
|
||||||
|
try {
|
||||||
|
AggregatorPersistentResource aresource = State.getDataManager().retrieveProfile(criteria.getID(), criteria.getProfileType());
|
||||||
|
logger.debug("Returning profile:" + aresource.getData());
|
||||||
|
return aresource.getData();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Unable to find Profile with ID=" + criteria.getID(), e);
|
||||||
|
throw new DocumentNotFoundFaultType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -391,7 +391,7 @@ public class XMLStorageManager {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public AggregatorPersistentResource retrievePropertyResourceFromID(String resourceID) throws Exception {
|
synchronized public AggregatorPersistentResource retrievePropertyResourceFromID(String resourceID) throws Exception {
|
||||||
XMLResource res = null;
|
XMLResource res = null;
|
||||||
Collection currentCollection = this.loadPropertiesCollection();
|
Collection currentCollection = this.loadPropertiesCollection();
|
||||||
try {
|
try {
|
||||||
|
@ -402,16 +402,36 @@ public class XMLStorageManager {
|
||||||
logger.error("Failed to retrieve document " + resourceID);
|
logger.error("Failed to retrieve document " + resourceID);
|
||||||
logger.error("" + edb.errorCode + " " + edb.getMessage(), edb);
|
logger.error("" + edb.errorCode + " " + edb.getMessage(), edb);
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
} finally {
|
||||||
|
this.resetCollection(currentCollection);
|
||||||
}
|
}
|
||||||
return new AggregatorPersistentResource(res);
|
return new AggregatorPersistentResource(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
synchronized public AggregatorPersistentResource retrieveProfile(String profileID, String profileType) throws Exception {
|
||||||
|
|
||||||
|
XMLResource res = null;
|
||||||
|
Collection currentCollection = this.loadProfileCollection(profileType);
|
||||||
|
try {
|
||||||
|
res = (XMLResource) currentCollection.getResource(profileID);
|
||||||
|
if (res == null)
|
||||||
|
logger.warn("Profile " + profileID + " not found!");
|
||||||
|
} catch (XMLDBException edb) {
|
||||||
|
logger.error("Failed to retrieve document " + profileID);
|
||||||
|
logger.error("" + edb.errorCode + " " + edb.getMessage(), edb);
|
||||||
|
throw new Exception();
|
||||||
|
} finally {
|
||||||
|
this.resetCollection(currentCollection);
|
||||||
|
}
|
||||||
|
return new AggregatorPersistentResource(res);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param xpathquery
|
* @param xpathquery
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public AggregatorPersistentResource executeXPathQuery(String xpathquery) {
|
synchronized public AggregatorPersistentResource executeXPathQuery(String xpathquery) {
|
||||||
|
|
||||||
AggregatorPersistentResource res = null;
|
AggregatorPersistentResource res = null;
|
||||||
// ArrayList<AggregatorPersistentResource> results = new
|
// ArrayList<AggregatorPersistentResource> results = new
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.gcube.informationsystem.collector.stubs.testsuite.xmlcollectionaccess;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
|
||||||
|
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
|
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.DocumentNotFoundFaultType;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.GetProfileCriteria;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.XMLCollectionAccessPortType;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.service.XMLCollectionAccessServiceLocator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tester for <em>GetProfile</em> operation of the
|
||||||
|
* <em>gcube/informationsystem/collector/XMLCollectionAccess</em> portType
|
||||||
|
*
|
||||||
|
* @author Manuele Simi (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GetProfileTester {
|
||||||
|
|
||||||
|
private static GCUBEClientLog logger = new GCUBEClientLog(GetProfileTester.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (args.length != 5) {
|
||||||
|
logger.fatal("Usage: GetProfileTester <host> <port> <Scope> <ID> <profileType>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String portTypeURI = "http://" + args[0] + ":" + args[1] + "/wsrf/services/gcube/informationsystem/collector/XMLCollectionAccess";
|
||||||
|
|
||||||
|
|
||||||
|
XMLCollectionAccessPortType port = null;
|
||||||
|
try {
|
||||||
|
port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(portTypeURI));
|
||||||
|
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope(args[2]));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Submitting the request...");
|
||||||
|
|
||||||
|
String profile;
|
||||||
|
try {
|
||||||
|
GetProfileCriteria criteria = new GetProfileCriteria();
|
||||||
|
criteria.setID(args[3]);
|
||||||
|
criteria.setProfileType(args[4]);
|
||||||
|
profile = port.getProfile(criteria);
|
||||||
|
logger.info("Retrieved profile: \n" + profile);
|
||||||
|
} catch (DocumentNotFoundFaultType e) {
|
||||||
|
logger.error("",e);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package org.gcube.informationsystem.collector.stubs.testsuite.xmlcollectionaccess;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
|
||||||
|
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||||||
|
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.DocumentNotFoundFaultType;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.GetResourceCriteria;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.XMLCollectionAccessPortType;
|
||||||
|
import org.gcube.informationsystem.collector.stubs.service.XMLCollectionAccessServiceLocator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tester for <em>GetResource</em> operation of the
|
||||||
|
* <em>gcube/informationsystem/collector/XMLCollectionAccess</em> portType
|
||||||
|
*
|
||||||
|
* @author Manuele Simi (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GetResourceTester {
|
||||||
|
|
||||||
|
private static GCUBEClientLog logger = new GCUBEClientLog(GetResourceTester.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (args.length != 4) {
|
||||||
|
logger.fatal("Usage: GetResourceTester <host> <port> <Scope> <ID>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String portTypeURI = "http://" + args[0] + ":" + args[1] + "/wsrf/services/gcube/informationsystem/collector/XMLCollectionAccess";
|
||||||
|
|
||||||
|
|
||||||
|
XMLCollectionAccessPortType port = null;
|
||||||
|
try {
|
||||||
|
port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(portTypeURI));
|
||||||
|
port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope(args[2]));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Submitting the request...");
|
||||||
|
|
||||||
|
String resource;
|
||||||
|
try {
|
||||||
|
GetResourceCriteria criteria = new GetResourceCriteria();
|
||||||
|
criteria.setID(args[3]);
|
||||||
|
resource = port.getResource(criteria);
|
||||||
|
logger.info("Retrieved resource: \n" + resource);
|
||||||
|
} catch (DocumentNotFoundFaultType e) {
|
||||||
|
logger.error("",e);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
logger.error("",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue