diff --git a/.classpath b/.classpath index 38f2242..8649e18 100644 --- a/.classpath +++ b/.classpath @@ -8,7 +8,6 @@ - diff --git a/README b/README index f582257..40a46e0 100755 --- a/README +++ b/README @@ -16,7 +16,7 @@ Authors Version and Release Date ------------------------ -v. 3.0.0 (07-02-2011) +v. 3.0.1 (25-03-2011) Description ----------- diff --git a/changelog.xml b/changelog.xml index 1d93ad5..3c83d32 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,4 +1,7 @@ + + XMLDocuments passed as any objects and cleaned up + WSDAIX::XMLCollectionAccess interface internal refactoring of resources diff --git a/etc/profile.xml b/etc/profile.xml index dbc3cad..d43ba49 100644 --- a/etc/profile.xml +++ b/etc/profile.xml @@ -18,7 +18,7 @@
Information Collector service: aggregate and make available information published by gCube services IS-Collector-service - 3.0.0 + 3.0.1 @@ -91,7 +91,7 @@ Test-suite for IS-Collector: provide sample usages of interaction with a IS-Collector instance IS-Collector-test-suite - 3.0.0 + 3.0.1 application diff --git a/src/org/gcube/informationsystem/collector/impl/porttypes/wsdaix/XMLCollectionAccess.java b/src/org/gcube/informationsystem/collector/impl/porttypes/wsdaix/XMLCollectionAccess.java index a011d64..e116b49 100644 --- a/src/org/gcube/informationsystem/collector/impl/porttypes/wsdaix/XMLCollectionAccess.java +++ b/src/org/gcube/informationsystem/collector/impl/porttypes/wsdaix/XMLCollectionAccess.java @@ -1,9 +1,15 @@ package org.gcube.informationsystem.collector.impl.porttypes.wsdaix; import java.rmi.RemoteException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + import org.apache.axis.message.MessageElement; import org.apache.axis.types.URI; import org.w3c.dom.Document; +import org.w3c.dom.Node; import org.xmldb.api.base.XMLDBException; import org.gcube.common.core.contexts.GCUBEServiceContext; import org.gcube.common.core.porttypes.GCUBEPortType; @@ -146,6 +152,14 @@ public class XMLCollectionAccess extends GCUBEPortType { AddDocumentRequestWrapper[] docs = addDocumentsRequest.getAddDocumentRequestWrapper(); AddDocumentResponseWrapper[] responseWrappers = new AddDocumentResponseWrapper[docs.length]; String targetCollection = this.URItoCollection(addDocumentsRequest.getCollectionName()); + DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); + fact.setNamespaceAware(true); + DocumentBuilder bd; + try { + bd = fact.newDocumentBuilder(); + } catch (ParserConfigurationException e3) { + throw new RemoteException("Unable to create a Document Factory for the incoming documents"); + } logger.debug("Adding " +docs.length + " documents to collection " + targetCollection); //response wrapper values @@ -193,12 +207,20 @@ public class XMLCollectionAccess extends GCUBEPortType { try { resource.setResourceName(resourceName); - resource.setContent(doc); + if (doc.getDocumentElement().getLocalName().equals("ISPublisher")) { + //this removes the root element introduced by the ISPublisher in order to put an any obj + //in the SOAP MessageElement + Document newDoc = bd.newDocument(); + Node node = doc.getDocumentElement().removeChild(doc.getDocumentElement().getFirstChild()); + newDoc.appendChild(newDoc.importNode(node,true)); + resource.setContent(newDoc); + } else + resource.setContent(doc); } catch (MalformedResourceException e1) { logger.error("Invalid resource ", e1); responseWrappers[i].setResponse(AddDocumentResponseWrapperResponse.value2); continue; - } + } try { //logger.trace("resource to wrap " + resource.toString()); diff --git a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/sweep/ResourceFilter.java b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/sweep/ResourceFilter.java index b40a032..d7a2ae4 100644 --- a/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/sweep/ResourceFilter.java +++ b/src/org/gcube/informationsystem/collector/impl/xmlstorage/exist/sweep/ResourceFilter.java @@ -32,13 +32,13 @@ class ResourceFilter { if (resource.getPublicationMode().compareToIgnoreCase("pull") == 0) { return isPullExpired(resource); } else if (resource.getPublicationMode().compareToIgnoreCase("push") == 0) { - return isPushExpired(resource); + //return isPushExpired(resource); } // default return false; } - private static boolean isPushExpired(GCUBEXMLResource resource) { + /* private static boolean isPushExpired(GCUBEXMLResource resource) { logger.trace("Checking push resource..."); try { String status = getRIStatus(resource.getSourceRunningInstance()); @@ -50,7 +50,7 @@ class ResourceFilter { logger.warn("Unable to detect if the resource is expired",e); return false; } - } + }*/ static boolean isPullExpired(GCUBEXMLResource resource) { logger.trace("Checking pull resource..."); diff --git a/test/org/gcube/informationsystem/collector/resources/GCUBEInstanceStateResourceTest.java b/test/org/gcube/informationsystem/collector/resources/GCUBEInstanceStateResourceTest.java index 759b88d..73e7906 100644 --- a/test/org/gcube/informationsystem/collector/resources/GCUBEInstanceStateResourceTest.java +++ b/test/org/gcube/informationsystem/collector/resources/GCUBEInstanceStateResourceTest.java @@ -22,7 +22,7 @@ public class GCUBEInstanceStateResourceTest extends TestCase { public void testSetContentString() { try { - resource.setContent(" "); + resource.setContent(" "); } catch (MalformedResourceException e) { e.printStackTrace(); } diff --git a/test/org/gcube/informationsystem/collector/resources/GCUBEProfileResourceTest.java b/test/org/gcube/informationsystem/collector/resources/GCUBEProfileResourceTest.java index fced61a..d04e380 100644 --- a/test/org/gcube/informationsystem/collector/resources/GCUBEProfileResourceTest.java +++ b/test/org/gcube/informationsystem/collector/resources/GCUBEProfileResourceTest.java @@ -85,8 +85,11 @@ public class GCUBEProfileResourceTest extends TestCase { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); - StringReader reader = new StringReader("GHN"); + StringReader reader = new StringReader("GHN"+ + ""); InputSource source = new InputSource(reader); + //Document doc = builder.parse(source); resource.setContent(builder.parse(source)); } catch (Exception e) { e.printStackTrace(); diff --git a/test/org/gcube/informationsystem/collector/resources/GCUBEXMLResourceTest.java b/test/org/gcube/informationsystem/collector/resources/GCUBEXMLResourceTest.java index 6aa3089..20e4a8a 100644 --- a/test/org/gcube/informationsystem/collector/resources/GCUBEXMLResourceTest.java +++ b/test/org/gcube/informationsystem/collector/resources/GCUBEXMLResourceTest.java @@ -1,5 +1,10 @@ package org.gcube.informationsystem.collector.resources; +import java.io.File; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + import junit.framework.TestCase; import org.gcube.informationsystem.collector.impl.resources.BaseDAIXResource; @@ -11,24 +16,32 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.w3c.dom.Document; public class GCUBEXMLResourceTest extends TestCase { private GCUBEXMLResource XMLiresource; + private GCUBEXMLResource XMLiresourceDOM; private GCUBEXMLResource XMLpresource; - private GCUBEInstanceStateResource iresource; + private GCUBEInstanceStateResource iresourceString; + private GCUBEInstanceStateResource iresourceDOM; private GCUBEProfileResource presource; @Before public void setUp() throws Exception { - iresource = new GCUBEInstanceStateResource(); - iresource.setResourceName("Instance"); - iresource.setContent("<"+ GCUBEInstanceStateResource.INSTANCESTATE_ROOT_ELEMENT + "> "); + iresourceString = new GCUBEInstanceStateResource(); + iresourceString.setResourceName("Instance"); + iresourceString.setContent("<"+ GCUBEInstanceStateResource.INSTANCESTATE_ROOT_ELEMENT + "> "); + XMLiresource = new GCUBEXMLResource(iresourceString); + + iresourceDOM = new GCUBEInstanceStateResource(); + iresourceDOM.setResourceName("InstanceDOM"); + iresourceDOM.setContent(this.getAsDocument("/Users/manuele/work/workspace/IS/Branches/InformationCollector.3.0/test/org/gcube/informationsystem/collector/resources/samplestate.xml")); + presource = new GCUBEProfileResource(); presource.setResourceName("Profile"); - presource.setContent("GHN"); - XMLiresource = new GCUBEXMLResource(iresource); + presource.setContent("GHN"); XMLpresource = new GCUBEXMLResource(presource); } @@ -39,8 +52,13 @@ public class GCUBEXMLResourceTest extends TestCase { @Test public void testGCUBEXMLResourceBaseDAIXResource() { try { - XMLiresource = new GCUBEXMLResource(iresource); + XMLiresource = new GCUBEXMLResource(iresourceString); XMLpresource = new GCUBEXMLResource(presource); + //XMLiresourceDOM = new GCUBEXMLResource(iresourceDOM); + System.out.println("Resource to wrap " + iresourceDOM.toString()); + XMLiresourceDOM = new GCUBEXMLResource(iresourceDOM); + System.out.println("Wrapped Resource" + XMLiresourceDOM.toString()); + } catch (MalformedXMLResourceException e) { Assert.fail("failed to create GCUBEXMLResources"); } @@ -69,8 +87,7 @@ public class GCUBEXMLResourceTest extends TestCase { System.out.println("Profile Content with envelop " + content); GCUBEXMLResource temp = new GCUBEXMLResource(new BaseDAIXResource("name")); temp.deserializeFromIndexing(content, true); - System.out.println("New Profile Content with envelop " + temp.toString()); - + System.out.println("New Profile Content with envelop " + temp.toString()); String content2 = XMLiresource.toString(); System.out.println("Instance State Content with envelop " + content2); GCUBEXMLResource temp2 = new GCUBEXMLResource(new BaseDAIXResource("name")); @@ -153,8 +170,25 @@ public class GCUBEXMLResourceTest extends TestCase { @Test public void testToString() { - System.out.println("Instance to string " + XMLiresource.toString() ); - System.out.println("Profile to string " + XMLpresource.toString() ); + //System.out.println("Instance to string " + XMLiresource.toString() ); + //System.out.println("Instance from DOM to string " + XMLiresourceDOM.toString() ); + //System.out.println("Profile to string " + XMLpresource.toString() ); + } + + + private Document getAsDocument(String filename) throws Exception { + try { + File file = new File(filename); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + DocumentBuilder db = dbf.newDocumentBuilder(); + return db.parse(file); + + } catch ( Exception e ) { + System.out.println("Unable to load document: " + filename); + } + return null; } + } diff --git a/test/org/gcube/informationsystem/collector/resources/samplestate.xml b/test/org/gcube/informationsystem/collector/resources/samplestate.xml index a133eb0..aa42504 100644 --- a/test/org/gcube/informationsystem/collector/resources/samplestate.xml +++ b/test/org/gcube/informationsystem/collector/resources/samplestate.xml @@ -1,89 +1,60 @@ - - - b9685210-3bd4-4eac-af39-fa9b010d4746 - 29ff75c0-ee7b-11df-9759-9044180d0c96 - MetadataView - Metadata view for collection 29ff75c0-ee7b-11df-9759-9044180d0c96 - - - - - - - - 0 - 2010-10-25T14:01:55.948Z - - name - - MITmetadata - - - metadataName - - oai_dc - - - metadataLanguage - - unknown - - - metadataSchema - - http://www.openarchives.org/OAI/2.0/oai_dc.xsd - - - isEditable - - false - - - isIndexable - - true - - - isUserCollection - - true - - - MetadataPlugin - c25b7d90-2ee1-11e0-917b-87d1c5c45db1 - 3a556ba0-2ee5-11e0-bc88-d12fb9a65569 - ContentManagement - /gcube/devNext - 3a0a7ff0-2ee5-11e0-bc88-d12fb9a65569 - ViewManager + + + 98f54690-fed3-11df-88a7-93625fddeb27 + + 9b11d2d0-dad5-11df-90dc-c704f281f2f7 + http://88.197.20.212:8280/web/openSearchDescriptor + + http://88.197.20.212:8280/web/showResults.action?referer=showResults&query={http%3A%2F%2Fa9.com%2F-%2Fspec%2Fopensearch%2F1.1%2F:searchTerms}&page={http%3A%2F%2Fa9.com%2F-%2Fspec%2Fopensearch%2F1.1%2F:startPage}&size={http%3A%2F%2Fa9.com%2F-%2Fspec%2Fopensearch%2F1.1%2F:count}&view=comm&format=rss + + 5f8a0680-dad3-11df-b94e-b5f66b8b8a02 + + 9cf3d690-fbc1-11df-b541-a45b627e2d64 + 89ecbd90-feba-11df-887f-93625fddeb27 + OpenSearch + /d4science.research-infrastructures.eu/Ecosystem/DRIVER + + 89dcdf10-feba-11df-887f-93625fddeb27 + OpenSearchService +