Clean up and fixings

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@34683 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2011-02-04 23:43:41 +00:00
parent b4b00b2e08
commit fadacb249b
11 changed files with 136 additions and 10 deletions

View File

@ -207,7 +207,7 @@ public class XMLCollectionAccess extends GCUBEPortType {
}
//store/update the new resource
State.getDataManager().storeResource(xmlResource);
logger.info("Resouce " + resource.getResourceName() + " successfully stored");
logger.info("Resource " + resource.getResourceName() + " successfully stored");
if (exist)
responseWrappers[i].setResponse(AddDocumentResponseWrapperResponse.value5);
else

View File

@ -17,8 +17,6 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
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 java.io.StringWriter;

View File

@ -9,6 +9,7 @@ import java.util.TimeZone;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@ -20,7 +21,7 @@ import org.xml.sax.SAXException;
*
*/
public class MetadataRecord {
public final class MetadataRecord {
public static enum TYPE {INSTANCESTATE("InstanceState"),GCUBERESOURCE("Profile");
String name;
@ -145,7 +146,7 @@ public class MetadataRecord {
* @throws ParserConfigurationException
*/
public Document getAsDocument()
throws SAXException, IOException, ParserConfigurationException {
throws SAXException, IOException, ParserConfigurationException {
return DocumentBuilderFactory
.newInstance()
.newDocumentBuilder()

View File

@ -11,7 +11,7 @@ import org.gcube.informationsystem.collector.stubs.metadata.MetadataRecord;
* @author Manuele Simi (ISTI-CNR)
*
*/
public class MetadataWriter {
public final class MetadataWriter {
private MetadataRecord metadata;
@ -31,6 +31,7 @@ public class MetadataWriter {
this.metadata.setSource(source);
this.metadata.setEntryKey(entrykey);
this.metadata.setGroupKey(groupkey);
this.metadata.setKey(key);
this.metadata.setTimeToLive(timeToLive);
}

View File

@ -104,6 +104,7 @@ public class AddDocumentsTester {
logger.error("Unable to add document " + documentNames[i], e);
continue;
}
logger.info("Dump before set_any \n"+ msgElement);
wrapper.set_any(new MessageElement[] {msgElement, msgElement2} );
wrappers[i].setData(wrapper);
}

View File

@ -26,6 +26,7 @@ public class TestDocuments {
try {
File file = new File(filename);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
return db.parse(file);

View File

@ -1,5 +1,14 @@
package org.gcube.informationsystem.collector;
import ise.antelope.tasks.util.Base64.InputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import org.gcube.informationsystem.collector.impl.resources.GCUBEInstanceStateResource;
import org.gcube.informationsystem.collector.impl.resources.GCUBEProfileResource;
import org.gcube.informationsystem.collector.impl.resources.GCUBEXMLResource;
@ -63,7 +72,9 @@ public class XMLStorageManagerTest extends TestCase {
System.out.println("testStoreResource : profile "+ XMLpresource.getResourceName()+ " successfully stored");
GCUBEInstanceStateResource iresource = new GCUBEInstanceStateResource();
iresource.setResourceName(resourceInstanceStateName);
iresource.setContent("<"+ GCUBEInstanceStateResource.INSTANCESTATE_ROOT_ELEMENT + "><ns1:Task xmlns:ns1=\"http://gcube-system.org/namespaces/vremanagement/executor\"/> <ns9:Task xmlns:ns9=\"http://gcube-system.org/namespaces/vremanagement/executor\"/> </"+ GCUBEInstanceStateResource.INSTANCESTATE_ROOT_ELEMENT + ">");
//iresource.setContent("<"+ GCUBEInstanceStateResource.INSTANCESTATE_ROOT_ELEMENT + "><ns1:Task xmlns:ns1=\"http://gcube-system.org/namespaces/vremanagement/executor\"/> <ns9:Task xmlns:ns9=\"http://gcube-system.org/namespaces/vremanagement/executor\"/> </"+ GCUBEInstanceStateResource.INSTANCESTATE_ROOT_ELEMENT + ">");
iresource.setContent(convertStreamToString(this.getClass().getResourceAsStream("samplestate.xml")));
GCUBEXMLResource XMLiresource = new GCUBEXMLResource(iresource);
System.out.println("testStoreResource : storing \n"+ XMLiresource.toString()+ "\n in collection " + XMLiresource.getCollectionName());
storage.storeResource(XMLiresource);
@ -74,6 +85,8 @@ public class XMLStorageManagerTest extends TestCase {
Assert.fail("Storage not available " + e.getMessage());
} catch (MalformedXMLResourceException e) {
Assert.fail("Malformed XML resource");
} catch (IOException e) {
Assert.fail("Malformed XML resource");
}
}
@ -163,5 +176,27 @@ public class XMLStorageManagerTest extends TestCase {
public void testSetStatus() {
}
private String convertStreamToString(java.io.InputStream is)
throws IOException {
if (is != null) {
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(
new InputStreamReader(is, "UTF-8"));
int n;
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
} finally {
is.close();
}
return writer.toString();
} else {
return "";
}
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.collector;
package org.gcube.informationsystem.collector.resources;
import org.gcube.informationsystem.collector.impl.resources.GCUBEInstanceStateResource;
import org.gcube.informationsystem.collector.impl.resources.DAIXResource.MalformedResourceException;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.collector;
package org.gcube.informationsystem.collector.resources;
import java.io.StringReader;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.collector;
package org.gcube.informationsystem.collector.resources;
import junit.framework.TestCase;

View File

@ -0,0 +1,89 @@
<ResourceProperties>
<ns1:View xmlns:ns1="http://gcube-system.org/namespaces/contentmanagement/viewmanager" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:View">
<id xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">b9685210-3bd4-4eac-af39-fa9b010d4746</id>
<collectionID xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">29ff75c0-ee7b-11df-9759-9044180d0c96</collectionID>
<type xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">MetadataView</type>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">Metadata view for collection 29ff75c0-ee7b-11df-9759-9044180d0c96</description>
<predicate>
<ns2:t xmlns:ns2="http://gcube-system.org/namespaces/contentmanagement/contentmanager">
<ns2:atleast cond="false">
<!-- <ns2:l xmlns="" xmlns:ns3="http://gcube-system.org/namespaces/contentmanagement/viewmanager">isDescribedBy</ns2:l>
<ns2:t>
<ns2:one cond="false">
<ns2:l xmlns="" xmlns:ns3="http://gcube-system.org/namespaces/contentmanagement/viewmanager">metadataSchema</ns2:l>
<ns2:text>
<ns2:same>
<ns2:as xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://www.openarchives.org/OAI/2.0/oai_dc.xsd</ns2:as>
</ns2:same>
</ns2:text>
</ns2:one>
<ns2:one cond="false">
<ns2:l xmlns="" xmlns:ns3="http://gcube-system.org/namespaces/contentmanagement/viewmanager">metadataLanguage</ns2:l>
<ns2:text>
<ns2:same>
<ns2:as xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">unknown</ns2:as>
</ns2:same>
</ns2:text>
</ns2:one>
<ns2:one cond="false">
<ns2:l xmlns="" xmlns:ns3="http://gcube-system.org/namespaces/contentmanagement/viewmanager">metadataName</ns2:l>
<ns2:text>
<ns2:same>
<ns2:as xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">oai_dc</ns2:as>
</ns2:same>
</ns2:text>
</ns2:one>
<ns2:many cond="false">
<ns2:l xmlns="" xmlns:ns3="http://gcube-system.org/namespaces/contentmanagement/viewmanager">.*</ns2:l>
<ns2:anytype/>
</ns2:many>
</ns2:t> -->
</ns2:atleast>
</ns2:t>
</predicate>
<cardinality xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:long">0</cardinality>
<lastUpdate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:dateTime">2010-10-25T14:01:55.948Z</lastUpdate>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">name</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">MITmetadata</value>
</property>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">metadataName</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">oai_dc</value>
</property>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">metadataLanguage</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">unknown</value>
</property>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">metadataSchema</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">http://www.openarchives.org/OAI/2.0/oai_dc.xsd</value>
</property>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">isEditable</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">false</value>
</property>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">isIndexable</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">true</value>
</property>
<property xsi:type="ns1:ViewProperty">
<name xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:QName">isUserCollection</name>
<description xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string"/>
<value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">true</value>
</property>
</ns1:View>
<ns2:Plugin xmlns:ns2="http://gcube-system.org/namespaces/contentmanagement/viewmanager" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">MetadataPlugin</ns2:Plugin>
<ns3:GHN xmlns:ns3="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">c25b7d90-2ee1-11e0-917b-87d1c5c45db1</ns3:GHN>
<ns4:RI xmlns:ns4="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">3a556ba0-2ee5-11e0-bc88-d12fb9a65569</ns4:RI>
<ns5:ServiceClass xmlns:ns5="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">ContentManagement</ns5:ServiceClass>
<ns6:Scope xmlns:ns6="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">/gcube/devNext</ns6:Scope>
<ns7:ServiceID xmlns:ns7="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">3a0a7ff0-2ee5-11e0-bc88-d12fb9a65569</ns7:ServiceID>
<ns8:ServiceName xmlns:ns8="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">ViewManager</ns8:ServiceName>
</ResourceProperties>