You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2008/07/17 08:21:16 UTC

svn commit: r677508 [1/2] - in /tuscany/java/sca/modules: binding-gdata-gsoc/ binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/ binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/ binding-gdata-gsoc/src/main...

Author: lresende
Date: Wed Jul 16 23:21:15 2008
New Revision: 677508

URL: http://svn.apache.org/viewvc?rev=677508&view=rev
Log:
TUSCANY-2476 - Additional operations for the GData binding from Haibo Zao

Added:
    tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java   (with props)
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/StartLocalhostServlet.java   (with props)
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_GoogleBloggerService.java   (with props)
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Test_GdataBinding_LocalhostServlet.java   (with props)
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/ConsumerGoogleBlogger.composite   (with props)
Modified:
    tuscany/java/sca/modules/binding-gdata-gsoc/pom.xml
    tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java
    tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java
    tuscany/java/sca/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/pom.xml
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/Consumer.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClient.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerCollectionImpl.java
    tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/test/resources/org/apache/tuscany/sca/binding/gdata/Consumer.composite

Modified: tuscany/java/sca/modules/binding-gdata-gsoc/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-gsoc/pom.xml?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-gsoc/pom.xml (original)
+++ tuscany/java/sca/modules/binding-gdata-gsoc/pom.xml Wed Jul 16 23:21:15 2008
@@ -32,6 +32,18 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-assembly</artifactId>
             <version>1.4-SNAPSHOT</version>
         </dependency>

Modified: tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java (original)
+++ tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java Wed Jul 16 23:21:15 2008
@@ -40,4 +40,10 @@
      */
     void setTitle(String title);
     
+    String getUsername();    
+    String getPassword();  
+    String getServiceType();
+    void setUsername(String username);    
+    void setPassword(String password);   
+    void setServiceType(String serviceType);  
 }

Modified: tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java (original)
+++ tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java Wed Jul 16 23:21:15 2008
@@ -41,6 +41,9 @@
     private String name;
     private String uri;
     private String title;
+    private String username;
+    private String password;
+    private String serviceType;
     private List<Intent> requiredIntents = new ArrayList<Intent>();
     private List<PolicySet> policySets = new ArrayList<PolicySet>();
     private IntentAttachPointType intentAttachPointType;
@@ -57,6 +60,18 @@
     public String getURI() {
         return uri;
     }
+    
+    public String getUsername(){
+        return username;
+    }
+    
+    public String getPassword(){
+        return password;
+    }
+    
+    public String getServiceType(){
+        return serviceType;
+    }
 
     public void setName(String name) {
         this.name = name;
@@ -65,6 +80,19 @@
     public void setURI(String uri) {
         this.uri = uri;
     }
+    
+    public void setUsername(String username) {
+        this.username = username;
+    }
+    
+    public void setPassword(String password) {
+        this.password = password;
+    }
+    
+    public void setServiceType(String serviceType) {
+        this.serviceType = serviceType;
+    }
+
 
     public String getTitle() {
         return title;

Added: tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java?rev=677508&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java (added)
+++ tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java Wed Jul 16 23:21:15 2008
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.gdata.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+//import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
+
+import org.apache.tuscany.sca.binding.gdata.GdataBinding;
+import org.apache.tuscany.sca.binding.gdata.GdataBindingFactory;
+
+/**
+ * A processor for <binding.gdata> elements.
+ */
+public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding> {
+
+    private QName BINDING_GDATA = new QName("http://tuscany.apache.org/xmlns/sca/1.0", "binding.gdata");
+    
+    private final GdataBindingFactory factory;
+    
+    //private PolicyAttachPointProcessor policyProcessor;
+
+    public GdataBindingProcessor(ModelFactoryExtensionPoint modelFactories) {
+        this.factory = modelFactories.getFactory(GdataBindingFactory.class);
+        System.out.println("[Debug Info]GdataBindingProcessor reached");
+        //this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+    }
+
+    public QName getArtifactType() {
+        return BINDING_GDATA;
+    }
+
+    public Class<GdataBinding> getModelType() {
+        return GdataBinding.class;
+    }
+
+    public GdataBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        GdataBinding gdataBinding = factory.createGdataBinding();
+                IntentAttachPointType bindingType = new IntentAttachPointTypeFactoryImpl().createBindingType();
+        bindingType.setName(getArtifactType());
+        bindingType.setUnresolved(true);
+        ((PolicySetAttachPoint)gdataBinding).setType(bindingType);
+
+        String name = reader.getAttributeValue(null, "name");
+        if (name != null) {
+            gdataBinding.setName(name);
+        }
+
+        String uri = reader.getAttributeValue(null, "uri");
+        if (uri != null) {
+            gdataBinding.setURI(uri);
+        }
+        
+        String serviceType = reader.getAttributeValue(null, "serviceType");
+        if (serviceType != null) {
+            gdataBinding.setServiceType(serviceType);
+        }
+        
+        String username = reader.getAttributeValue(null, "username");
+        if (username != null) {
+            gdataBinding.setUsername(username);
+        }
+        
+        String password = reader.getAttributeValue(null, "password");
+        if (password != null) {
+            gdataBinding.setPassword(password);
+        }        
+                
+        //policyProcessor.readPolicies(echoBinding, reader);
+
+        return gdataBinding;
+    }
+    
+    public void write(GdataBinding gdataBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+        //policyProcessor.writePolicyPrefixes(gdataBinding, writer);
+        writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart());
+        //policyProcessor.writePolicyAttributes(gdataBinding, writer);
+        
+        if (gdataBinding.getName() != null) {
+            writer.writeAttribute("name", gdataBinding.getName());
+        }
+        
+        if (gdataBinding.getURI() != null) {
+            writer.writeAttribute("uri", gdataBinding.getURI());
+        }
+        
+        if (gdataBinding.getServiceType() != null) {
+            writer.writeAttribute("serviceType", gdataBinding.getServiceType());
+        }
+        
+        if (gdataBinding.getUsername() != null) {
+            writer.writeAttribute("username", gdataBinding.getUsername());
+        }
+        
+        if (gdataBinding.getPassword() != null) {
+            writer.writeAttribute("password", gdataBinding.getPassword());
+        }
+        
+        writer.writeEndElement();
+    }
+
+    
+    //FIXME: Resolve the attached policySet, might not needed (the echo binding implementation example)
+    public void resolve(GdataBinding gdataBinding, ModelResolver resolver) throws ContributionResolveException {
+        PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)gdataBinding;
+        List<Intent> requiredIntents = new ArrayList<Intent>();
+        Intent resolvedIntent = null;
+        for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
+            resolvedIntent = resolver.resolveModel(Intent.class, intent);
+            requiredIntents.add(resolvedIntent);
+        }
+        policySetAttachPoint.getRequiredIntents().clear();
+        policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
+        
+        List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
+        PolicySet resolvedPolicySet = null;
+        for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
+            resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
+            resolvedPolicySets.add(resolvedPolicySet);
+        }
+        policySetAttachPoint.getPolicySets().clear();
+        policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
+    }
+}

Propchange: tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/binding-gdata-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/java/sca/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original)
+++ tuscany/java/sca/modules/binding-gdata-gsoc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Wed Jul 16 23:21:15 2008
@@ -16,4 +16,4 @@
 # under the License. 
 
 # Implementation class for the artifact processor extension
-org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.gdata,model=org.apache.tuscany.sca.binding.gdata.GdataBinding,factory=org.apache.tuscany.sca.binding.gdata.GdataBindingFactory
\ No newline at end of file
+org.apache.tuscany.sca.binding.gdata.impl.GdataBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.gdata,model=org.apache.tuscany.sca.binding.gdata.GdataBinding,factory=org.apache.tuscany.sca.binding.gdata.GdataBindingFactory
\ No newline at end of file

Modified: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/pom.xml?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/pom.xml (original)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/pom.xml Wed Jul 16 23:21:15 2008
@@ -1,177 +1,212 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.    
+	* Licensed to the Apache Software Foundation (ASF) under one
+	* or more contributor license agreements.  See the NOTICE file
+	* distributed with this work for additional information
+	* regarding copyright ownership.  The ASF licenses this file
+	* to you under the Apache License, Version 2.0 (the
+	* "License"); you may not use this file except in compliance
+	* with the License.  You may obtain a copy of the License at
+	* 
+	*   http://www.apache.org/licenses/LICENSE-2.0
+	* 
+	* Unless required by applicable law or agreed to in writing,
+	* software distributed under the License is distributed on an
+	* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	* KIND, either express or implied.  See the License for the
+	* specific language governing permissions and limitations
+	* under the License.    
 -->
 <project>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.tuscany.sca</groupId>
-        <artifactId>tuscany-modules</artifactId>
-        <version>1.4-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    <artifactId>tuscany-binding-gdata-runtime-gsoc</artifactId>
-    <name>Apache Tuscany SCA Gdata Binding Extension</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-binding-gdata-gsoc</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-assembly</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-interface-java</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-data-api</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-core-spi</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-databinding</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-http</artifactId>
-            <version>1.4-SNAPSHOT</version>
-        </dependency>
-        
-        <dependency>
-           <groupId>commons-httpclient</groupId>
-           <artifactId>commons-httpclient</artifactId>
-           <version>3.0.1</version>
-        </dependency>
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.tuscany.sca</groupId>
+		<artifactId>tuscany-modules</artifactId>
+		<version>1.4-SNAPSHOT</version>
+		<relativePath>../pom.xml</relativePath>
+	</parent>
+
+	<artifactId>tuscany-binding-gdata-extension-gsoc</artifactId>
+	<name>Apache Tuscany SCA Gdata Binding Extension</name>
+
+	<repositories>
+		<repository>
+			<id>com.google.gdata</id>
+			<url>
+				http://people.apache.org/~lresende/google-gdata/maven/
+			</url>
+		</repository>
+	</repositories>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-binding-gdata-gsoc</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-assembly</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-interface-java</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-data-api</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-core-spi</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-databinding</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-host-http</artifactId>
+			<version>1.4-SNAPSHOT</version>
+		</dependency>
 
         <dependency>
             <groupId>org.apache.abdera</groupId>
             <artifactId>abdera-core</artifactId>
             <version>0.3.0-incubating</version> 
         </dependency>    
-        
-        <dependency>
-        	<groupId>org.apache.abdera</groupId>
-      		<artifactId>abdera-parser</artifactId>
-      		<version>0.3.0-incubating</version>
-	    </dependency>           
-                
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.4</version> 
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-jetty</artifactId>
-            <version>1.4-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-java-runtime</artifactId>
-            <version>1.4-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-host-embedded</artifactId>
-            <version>1.4-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
 
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.2</version>
-            <scope>test</scope>
-        </dependency>
-        
-        <dependency>
-           <groupId>commons-codec</groupId>
-           <artifactId>commons-codec</artifactId>
-           <version>1.3</version>
-           <exclusions>
-               <exclusion>
-                   <groupId>commons-codec</groupId>
-                   <artifactId>commons-codec</artifactId>
-               </exclusion>
-           </exclusions>
-        </dependency>
-
-        <dependency>
-           <groupId>commons-logging</groupId>
-           <artifactId>commons-logging</artifactId>
-           <version>1.1</version>
-           <exclusions>
-               <exclusion>
-                   <groupId>javax.servlet</groupId>
-                   <artifactId>servlet-api</artifactId>
-               </exclusion>
-               <exclusion>
-                   <groupId>avalon-framework</groupId>
-                   <artifactId>avalon-framework</artifactId>
-               </exclusion>
-           </exclusions>
-        </dependency>          
-                
-    </dependencies>
-
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-
-                <configuration>
-                    <instructions>
-                        <Bundle-Version>${tuscany.version}</Bundle-Version>
-                        <Bundle-SymbolicName>org.apache.tuscany.sca.binding.gdata.extension</Bundle-SymbolicName>
-                        <Bundle-Description>${pom.name}</Bundle-Description>
-                        <Export-Package>org.apache.tuscany.sca.binding.gdata*</Export-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+		<dependency>
+			<groupId>commons-httpclient</groupId>
+			<artifactId>commons-httpclient</artifactId>
+			<version>3.0.1</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.google.gdata</groupId>
+			<artifactId>gdata-client</artifactId>
+			<version>1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.google.gdata</groupId>
+			<artifactId>gdata-client-meta</artifactId>
+			<version>1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.google.gdata</groupId>
+			<artifactId>gdata-core</artifactId>
+			<version>1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.google.gdata</groupId>
+			<artifactId>gdata-media</artifactId>
+			<version>1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.4</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-host-jetty</artifactId>
+			<version>1.4-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-implementation-java-runtime</artifactId>
+			<version>1.4-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-host-embedded</artifactId>
+			<version>1.4-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.2</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-codec</groupId>
+			<artifactId>commons-codec</artifactId>
+			<version>1.3</version>
+			<exclusions>
+				<exclusion>
+					<groupId>commons-codec</groupId>
+					<artifactId>commons-codec</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.1</version>
+			<exclusions>
+				<exclusion>
+					<groupId>javax.servlet</groupId>
+					<artifactId>servlet-api</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>avalon-framework</groupId>
+					<artifactId>avalon-framework</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+
+	</dependencies>
+
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+
+				<configuration>
+					<instructions>
+						<Bundle-Version>
+							${tuscany.version}
+						</Bundle-Version>
+						<Bundle-SymbolicName>
+							org.apache.tuscany.sca.binding.gdata.extension
+						</Bundle-SymbolicName>
+						<Bundle-Description>
+							${pom.name}
+						</Bundle-Description>
+						<Export-Package>
+							org.apache.tuscany.sca.binding.gdata*
+						</Export-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
 
 </project>

Modified: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java (original)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java Wed Jul 16 23:21:15 2008
@@ -21,24 +21,15 @@
 import static org.apache.tuscany.sca.binding.gdata.provider.GdataBindingUtil.entry;
 import static org.apache.tuscany.sca.binding.gdata.provider.GdataBindingUtil.feedEntry;
 
-import java.io.InputStreamReader;
-import java.io.StringWriter;
+import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.Parser;
 import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.URIException;
 import org.apache.commons.httpclient.methods.DeleteMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.tuscany.sca.binding.gdata.collection.NotFoundException;
 import org.apache.tuscany.sca.data.collection.Entry;
 import org.apache.tuscany.sca.interfacedef.Operation;
@@ -47,43 +38,36 @@
 import org.apache.tuscany.sca.invocation.Message;
 import org.osoa.sca.ServiceRuntimeException;
 
-import com.google.gdata.data.ExtensionProfile;
-import com.google.gdata.data.ParseSource;
-import com.google.gdata.data.TextContent;
+import com.google.gdata.client.GoogleService;
+import com.google.gdata.data.Feed;
+import com.google.gdata.util.ResourceNotFoundException;
+import com.google.gdata.util.ServiceException;
 
 /**
  * Invoker for the GData binding.
- * 
  */
 class GdataBindingInvoker implements Invoker, DataExchangeSemantics {
 
-    private static final Factory abderaFactory = Abdera.getNewFactory();
-    private static final Parser abderaParser = Abdera.getNewParser();
-
     Operation operation;
     String uri;
     HttpClient httpClient;
     String authorizationHeader;
     GdataReferenceBindingProvider provider;
-
-    private static final com.google.gdata.client.GoogleService googleService =
-        new com.google.gdata.client.GoogleService("cl", "exampleCo-exampleApp-1");
+    GoogleService googleService;
 
     GdataBindingInvoker(Operation operation,
                         String uri,
+                        GoogleService googleService,
                         HttpClient httpClient,
                         String authorizationHeader,
                         GdataReferenceBindingProvider bindingProvider) {
         this.operation = operation;
         this.uri = uri;
+        this.googleService = googleService;
         this.httpClient = httpClient;
         this.authorizationHeader = authorizationHeader;
         this.provider = bindingProvider;
-        // this.googleService = new com.google.gdata.client.GoogleService("cl",
-        // "exampleCo-exampleApp-1");
 
-        // //System.out.println("GdataBindingInvoker constuctor reached!: " +
-        // operation);
     }
 
     public Message invoke(Message msg) {
@@ -93,113 +77,43 @@
         throw new UnsupportedOperationException(operation.getName());
     }
 
+   
     /**
      * Get operation invoker
      */
     public static class GetInvoker extends GdataBindingInvoker {
         public GetInvoker(Operation operation,
                           String uri,
+                          GoogleService googleService,
                           HttpClient httpClient,
                           String authorizationHeader,
                           GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
+        @SuppressWarnings("finally")
         @Override
         public Message invoke(Message msg) {
 
-            System.out.println("GdataBindingInvoker.GetInvoker.invoke is reached!");
-
-            // Get an entry
+            // Get the entry id from the message body
             String id = (String)((Object[])msg.getBody())[0];
 
-            System.out.println("GdataBindingInvoker.GetInvoker.invoke---id: " + id);
-
             // Send an HTTP GET
             GetMethod getMethod = new GetMethod(uri + "/" + id);
             getMethod.setRequestHeader("Authorization", authorizationHeader);
 
             try {
-                System.out.println("GdataBindingInvoker.GetInvoker.invoke---feedURL: " + getMethod.getURI().toString());
-            } catch (URIException e1) {
-                // TODO Auto-generated catch block
-                e1.printStackTrace();
-            }
-
-            boolean parsing = false;
-            try {
-                httpClient.executeMethod(getMethod);
-                int status = getMethod.getStatusCode();
-
-                System.out.println("GdataBindingInvoker.GetInvoker.invoke---I am good here00");
-                System.out.println("GdataBindingInvoker.GetInvoker.invoke---status: " + status);
-
-                // Read the Atom entry
-                if (status == 200) {
-
-                    URL feedURL = new URL(getMethod.getURI().toString());
-
-                    System.out.println("GdataBindingInvoker.GetInvoker.invoke---feedURL: " + feedURL);
-
-                    com.google.gdata.data.Entry entry =
-                        googleService.getEntry(feedURL, com.google.gdata.data.Entry.class);
-
-                    System.out.println("GetInvoker class:   I am good here 04");
-
-                    System.out.println("entry title: " + entry.getTitle().getPlainText());
-
-                    System.out.println("GdataBindingInvoker.GetInvoker.invoke---entry");
-
-                    // Document<Feed> doc = abderaParser.parse(new
-                    // InputStreamReader(getMethod.getResponseBodyAsStream()));
-                    // parsing = true;
-                    // Feed feed = doc.getRoot();
-
-                    // System.out.println("getMethod.getResponseBodyAsString()"
-                    // + getMethod.getResponseBodyAsString());
-
-                    // feed = (com.google.gdata.data.Feed)
-                    // responseMessage.getBody();
-
-                    System.out.println("provider.supportsFeedEntries()" + provider.supportsFeedEntries());
-
-                    if (provider.supportsFeedEntries()) {
-
-                        // Return the Atom entry
-                        msg.setBody(entry);
-
-                    } else {
-
-                        // Convert the feed entry to a data entry and return the
-                        // data item
-                        // Entry<Object, Object> entry = entry(feedEntry,
-                        // provider.getItemClassType(),
-                        // provider.getItemXMLType(), provider.getMediator());
-                        // msg.setBody(entry.getData());
-                    }
-
-                    // To-change
-                    // This is read the entries from the response body
-                    // Change it into the corresponding Gdata parse and populate
-                    // the message with entries.
-
-                } else if (status == 404) {
-                    msg.setFaultBody(new NotFoundException());
-                } else {
-                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
-                }
-
-            } catch (Exception e) {
-                msg.setFaultBody(new ServiceRuntimeException(e));
+                URL entryURL = new URL(uri + "/" + id);
+                com.google.gdata.data.Entry feedEntry = googleService.getEntry(entryURL, com.google.gdata.data.Entry.class);
+                msg.setBody(feedEntry);
+            } catch (IOException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
+            } catch (ServiceException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
             } finally {
-                if (!parsing) {
-                    // Release the connection unless the Abdera parser is
-                    // parsing the response, in this case it will release it
-                    getMethod.releaseConnection();
-                }
+                return msg;
             }
 
-            return msg;
         }
     }
 
@@ -210,14 +124,14 @@
 
         public PostInvoker(Operation operation,
                            String uri,
+                           GoogleService googleService,
                            HttpClient httpClient,
                            String authorizationHeader,
                            GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
-
-            System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- Constructor method reached");
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
+        @SuppressWarnings("finally")
         @Override
         public Message invoke(Message msg) {
 
@@ -230,10 +144,6 @@
 
                 // Expect an Atom entry
 
-                // To-change
-                // Expect a Gdata entry
-                // change it into com.google.gdata.data.Entry
-
                 System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider
                     .supportsFeedEntries());
                 feedEntry = (com.google.gdata.data.Entry)args[0];
@@ -244,108 +154,31 @@
             } else {
                 // Expect a key and data item
                 Entry<Object, Object> entry = new Entry<Object, Object>(args[0], args[1]);
-                // FIXME: this needs to be fixed
-                // feedEntry = feedEntry(entry, provider.getItemClassType(),
-                // provider.getItemXMLType(), provider.getMediator(),
-                // abderaFactory);
-            }
 
-            // Send an HTTP POST
-            PostMethod postMethod = new PostMethod(uri);
+                // FIXME: this needs to be examinated more....
+                feedEntry =
+                    feedEntry(entry, provider.getItemClassType(), provider.getItemXMLType(), provider.getMediator());
+            }
 
-            System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- uri: " + uri);
 
-            postMethod.setRequestHeader("Authorization", authorizationHeader);
-            boolean parsing = false;
             try {
-                // Write the Atom entry
-                // StringWriter writer = new StringWriter();
-                // feedEntry.writeTo(writer);
-
-                StringWriter writer = new StringWriter();
-                com.google.gdata.util.common.xml.XmlWriter w = new com.google.gdata.util.common.xml.XmlWriter(writer);
-                feedEntry.generateAtom(w, new ExtensionProfile());
-                w.flush();
-
-                postMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
-                postMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
-
-                httpClient.executeMethod(postMethod);
-                int status = postMethod.getStatusCode();
-
-                System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- status code: " + status);
-
-                // Read the Atom entry
-                if (status == 200 || status == 201) {
-
-                    /*
-                     * Document<org.apache.abdera.model.Entry> doc =
-                     * abderaParser.parse(new
-                     * InputStreamReader(postMethod.getResponseBodyAsStream()));
-                     * parsing = true; org.apache.abdera.model.Entry
-                     * createdEntry = doc.getRoot();
-                     */
-
-                    ParseSource source = new ParseSource(new InputStreamReader(postMethod.getResponseBodyAsStream()));
-                    com.google.gdata.data.Entry createdEntry =
-                        com.google.gdata.data.Entry.readEntry(source, com.google.gdata.data.Entry.class, null);
-
-                    System.out.println("parsed createdentry title: " + createdEntry.getTitle().getPlainText());
-                    System.out.println("parsed createdentry content: " + ((TextContent)createdEntry.getContent())
-                        .getContent().getPlainText());
-                    System.out.println("parsed createdentry updated: " + createdEntry.getUpdated().toString());
-
-                    /*
-                     * Document<org.apache.abdera.model.Entry> doc =
-                     * abderaParser.parse(new
-                     * InputStreamReader(postMethod.getResponseBodyAsStream()));
-                     * parsing = true; org.apache.abdera.model.Entry
-                     * createdEntry = doc.getRoot();
-                     */
-
-                    // Returns the created Atom entry ID
-                    if (provider.supportsFeedEntries()) {
-                        // Returns the created entry
-                        msg.setBody(createdEntry);
-                    } else {
-                        // Returns the id of the created entry
-                        msg.setBody(createdEntry.getId().toString());
-                    }
+               
+                com.google.gdata.data.Entry createdEntry = googleService.insert(new URL(uri), feedEntry);
 
-                    // To-change
-                    // Get the status back and parse the updated entry
-                    // Need to change it into the corresponding Gdata Entry
-                    // class
-
-                } else if (status == 404) {
-                    msg.setFaultBody(new NotFoundException());
-                } else {
-                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
-                }
+                msg.setBody(createdEntry);
 
-            } catch (Exception e) {
-                msg.setFaultBody(new ServiceRuntimeException(e));
+            } catch (IOException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
+            } catch (ServiceException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
             } finally {
-                if (!parsing) {
-                    // Release the connection unless the Abdera parser is
-                    // parsing the response, in this case it will release it
-                    postMethod.releaseConnection();
-                }
+                return msg;
             }
-
-            return msg;
         }
     }
 
-    // To-change
-    // For the following classes: PutInvoker, DeleteInvoker, GetAllInvoker,
-    // PostMediaInvoker and PutMediaInvoker
-    // We just need to modify the corresponding parser and entry methods for
-    // Gdata
-    // The key point is the data conversion from item and gdata entry
-    // and parsing and writing entries in message
-    //
-
+    
+    
     /**
      * Put operation invoker
      */
@@ -353,68 +186,56 @@
 
         public PutInvoker(Operation operation,
                           String uri,
+                          GoogleService googleService,
                           HttpClient httpClient,
                           String authorizationHeader,
                           GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
+        @SuppressWarnings("finally")
         @Override
         public Message invoke(Message msg) {
 
             // Put an entry
             Object[] args = (Object[])msg.getBody();
             String id;
-            org.apache.abdera.model.Entry feedEntry;
+            com.google.gdata.data.Entry feedEntry = null;
             if (provider.supportsFeedEntries()) {
-
-                // Expect a key and Atom entry
+                // Expect a key and GData entry
                 id = (String)args[0];
-                feedEntry = (org.apache.abdera.model.Entry)args[1];
+                feedEntry = (com.google.gdata.data.Entry)args[1];
             } else {
 
                 // Expect a key and data item
                 id = (String)args[0];
                 Entry<Object, Object> entry = new Entry<Object, Object>(id, args[1]);
-                feedEntry =
-                    feedEntry(entry,
-                              provider.getItemClassType(),
-                              provider.getItemXMLType(),
-                              provider.getMediator(),
-                              abderaFactory);
+
+                // FIXME: The following statement needs to be modified
+                // accordingly
+                /*
+                 * feedEntry = feedEntry(entry, provider.getItemClassType(),
+                 * provider.getItemXMLType(), provider.getMediator(),
+                 * abderaFactory);
+                 */
             }
 
-            // Send an HTTP PUT
+            // Send an HTTP PUT <Localhost>
             PutMethod putMethod = new PutMethod(uri + "/" + id);
             putMethod.setRequestHeader("Authorization", authorizationHeader);
             try {
+                URL entryURL = new URL(uri + "/" + id);
+                com.google.gdata.data.Entry updatedEntry = googleService.update(entryURL, feedEntry);
 
-                // Write the Atom entry
-                StringWriter writer = new StringWriter();
-                feedEntry.writeTo(writer);
-                putMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
-                putMethod.setRequestEntity(new StringRequestEntity(writer.toString()));
-
-                httpClient.executeMethod(putMethod);
-                int status = putMethod.getStatusCode();
-                if (status == 200 || status == 201) {
-
-                    msg.setBody(null);
-
-                } else if (status == 404) {
-                    msg.setFaultBody(new NotFoundException());
-                } else {
-                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
-                }
+                msg.setBody(updatedEntry);
 
-            } catch (Exception e) {
-                msg.setFaultBody(new ServiceRuntimeException(e));
+            } catch (IOException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
+            } catch (ServiceException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
             } finally {
-                putMethod.releaseConnection();
-            }
-
-            return msg;
-        }
+                return msg;
+            }    }
     }
 
     /**
@@ -424,43 +245,40 @@
 
         public DeleteInvoker(Operation operation,
                              String uri,
+                             GoogleService googleService,
                              HttpClient httpClient,
                              String authorizationHeader,
                              GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
+        @SuppressWarnings("finally")
         @Override
         public Message invoke(Message msg) {
 
             // Delete an entry
             String id = (String)((Object[])msg.getBody())[0];
 
-            // Send an HTTP DELETE
+            // Send an HTTP DELETE(Localhost)
             DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
             deleteMethod.setRequestHeader("Authorization", authorizationHeader);
+
             try {
-                httpClient.executeMethod(deleteMethod);
-                int status = deleteMethod.getStatusCode();
-                if (status == 200) {
-                    msg.setBody(null);
+                    URL entryURL = new URL(uri + "/" + id);
+                    googleService.delete(entryURL);
 
-                } else if (status == 404) {
-                    msg.setFaultBody(new NotFoundException());
-                } else {
-                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
+                } catch (IOException ex) {
+                    msg.setFaultBody(new ServiceRuntimeException(ex));
+                } catch (ServiceException ex) {
+                    msg.setFaultBody(new ServiceRuntimeException(ex));
+                } finally {
+                    return msg;
                 }
-
-            } catch (Exception e) {
-                msg.setFaultBody(new ServiceRuntimeException(e));
-            } finally {
-                deleteMethod.releaseConnection();
             }
 
-            return msg;
-        }
     }
 
+   
     /**
      * GetAll operation invoker
      */
@@ -468,122 +286,40 @@
 
         public GetAllInvoker(Operation operation,
                              String uri,
+                             GoogleService googleService,
                              HttpClient httpClient,
                              String authorizationHeader,
                              GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
         @Override
         public Message invoke(Message msg) {
 
-            // Get a feed
-            System.out.println("GetAllInvoker class:   I am good here 00");
-
             // Send an HTTP GET
             GetMethod getMethod = new GetMethod(uri);
             getMethod.setRequestHeader("Authorization", authorizationHeader);
 
-            System.out.println("GetAllInvoker class:   I am good here 01");
-
-            try {
-                System.out.println("GdataBindingInvoker.GetAllInvoker.invoke---feedURL: " + getMethod.getURI()
-                    .toString());
-            } catch (URIException e1) {
-                // TODO Auto-generated catch block
-                e1.printStackTrace();
-            }
+            System.out.println("[Debug Info] GdataBindingInvoker.GetAllInvoker.invoke---feedURL: " + uri);
 
             boolean parsing = false;
-            try {
-
-                System.out.println("GetAllInvoker class:   I am good here 02");
-
-                httpClient.executeMethod(getMethod);
-                int status = getMethod.getStatusCode();
-
-                System.out.println("GetAllInvoker class:   I am good here 03");
-
-                // Read the Atom feed
-                if (status == 200) {
-
-                    URL feedURL = new URL(getMethod.getURI().toString());
-
-                    System.out.println("GdataBindingInvoker.GetInvoker.invoke---feedURL: " + feedURL);
-
-                    /*
-                     * //Changed by Haibo System.out.println("feedURL.toString: " +
-                     * feedURL.toString()); InputStreamReader stringReader= new
-                     * InputStreamReader(getMethod.getResponseBodyAsStream());
-                     * StringBuffer buffer = new StringBuffer(); Reader in = new
-                     * BufferedReader(stringReader); XhtmlTextConstruct
-                     * construct = new XhtmlTextConstruct();
-                     * com.google.gdata.data.XhtmlTextConstruct.AtomHandler
-                     * rootHandler = construct.new AtomHandler(); XmlParser
-                     * parser = new XmlParser();
-                     * parser.parse(in,rootHandler,"http://www.w3.org/2005/Atom","feed");
-                     * System.out.println(construct.getXhtml().getBlob());
-                     */
-
-                    com.google.gdata.data.Feed feed = googleService.getFeed(feedURL, com.google.gdata.data.Feed.class);
-
-                    System.out.println("GetAllInvoker class:   I am good here 04");
-
-                    System.out.println("feed title: " + feed.getTitle().getPlainText());
 
-                    // Document<Feed> doc = abderaParser.parse(new
-                    // InputStreamReader(getMethod.getResponseBodyAsStream()));
-                    // parsing = true;
-                    // Feed feed = doc.getRoot();
-
-                    // System.out.println("getMethod.getResponseBodyAsString()"
-                    // + getMethod.getResponseBodyAsString());
-
-                    // feed = (com.google.gdata.data.Feed)
-                    // responseMessage.getBody();
-
-                    System.out.println("provider.supportsFeedEntries()" + provider.supportsFeedEntries());
-
-                    if (provider.supportsFeedEntries()) {
-
-                        System.out.println("GetAllInvoker class:   I am good here 05");
-
-                        // Returns the Atom feed
-                        msg.setBody(feed);
-
-                        System.out.println("msg: " + msg.toString());
+            try {
 
-                    } else {
+                Feed feed = googleService.getFeed(new URL(uri), Feed.class);
 
-                        /*
-                         * // Returns an array of data entries List<Entry<Object,
-                         * Object>> entries = new ArrayList<Entry<Object,Object>>();
-                         * for (org.apache.abdera.model.Entry feedEntry:
-                         * feed.getEntries()) { Entry<Object, Object> entry =
-                         * entry(feedEntry, provider.getItemClassType(),
-                         * provider.getItemXMLType(), provider.getMediator());
-                         * entries.add(entry); } msg.setBody(entries.toArray(new
-                         * Entry[entries.size()]));
-                         */
-                    }
-
-                } else if (status == 404) {
-                    msg.setFaultBody(new NotFoundException());
-                } else {
-                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
-                }
+                msg.setBody(feed);
 
-            } catch (Exception e) {
-                msg.setFaultBody(new ServiceRuntimeException(e));
+            } catch (ResourceNotFoundException ex) {
+                msg.setFaultBody(new ResourceNotFoundException("Invalid Resource at " + uri));
+            } catch (ServiceException ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
+            } catch (Exception ex) {
+                msg.setFaultBody(new ServiceRuntimeException(ex));
             } finally {
-                if (!parsing) {
-                    // Release the connection unless the Abdera parser is
-                    // parsing the response, in this case it will release it
-                    getMethod.releaseConnection();
-                }
+                return msg;
             }
 
-            return msg;
         }
     }
 
@@ -594,10 +330,11 @@
 
         public QueryInvoker(Operation operation,
                             String uri,
+                            GoogleService googleService,
                             HttpClient httpClient,
                             String authorizationHeader,
                             GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
         @Override
@@ -617,9 +354,18 @@
 
                 // Read the Atom feed
                 if (status == 200) {
-                    Document<Feed> doc = abderaParser.parse(new InputStreamReader(getMethod.getResponseBodyAsStream()));
-                    parsing = true;
-                    Feed feed = doc.getRoot();
+
+                    URL feedURL = new URL(getMethod.getURI().toString());
+
+                    System.out.println("GdataBindingInvoker.GetInvoker.invoke---feedURL: " + feedURL);
+
+                    com.google.gdata.data.Feed feed = googleService.getFeed(feedURL, com.google.gdata.data.Feed.class);
+
+                    System.out.println("GetAllInvoker class:   I am good here 04");
+
+                    System.out.println("feed title: " + feed.getTitle().getPlainText());
+
+                    System.out.println("provider.supportsFeedEntries()" + provider.supportsFeedEntries());
 
                     if (provider.supportsFeedEntries()) {
 
@@ -629,13 +375,17 @@
                     } else {
 
                         // Returns an array of data entries
+
+                        // FIXME: This part needs to be fixed while working on
+                        // the query operation
                         List<Entry<Object, Object>> entries = new ArrayList<Entry<Object, Object>>();
-                        for (org.apache.abdera.model.Entry feedEntry : feed.getEntries()) {
+                        for (com.google.gdata.data.Entry feedEntry : feed.getEntries()) {
                             Entry<Object, Object> entry =
                                 entry(feedEntry, provider.getItemClassType(), provider.getItemXMLType(), provider
                                     .getMediator());
                             entries.add(entry);
                         }
+
                         msg.setBody(entries.toArray(new Entry[entries.size()]));
                     }
 
@@ -659,6 +409,8 @@
         }
     }
 
+    
+    
     /**
      * PostMedia operation invoker
      */
@@ -666,10 +418,11 @@
 
         public PostMediaInvoker(Operation operation,
                                 String uri,
+                                GoogleService googleService,
                                 HttpClient httpClient,
                                 String authorizationHeader,
                                 GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
         @Override
@@ -686,10 +439,11 @@
 
         public PutMediaInvoker(Operation operation,
                                String uri,
+                               GoogleService googleService,
                                HttpClient httpClient,
                                String authorizationHeader,
                                GdataReferenceBindingProvider bindingProvider) {
-            super(operation, uri, httpClient, authorizationHeader, bindingProvider);
+            super(operation, uri, googleService, httpClient, authorizationHeader, bindingProvider);
         }
 
         @Override

Modified: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java (original)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java Wed Jul 16 23:21:15 2008
@@ -38,16 +38,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
 
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Collection;
-import org.apache.abdera.model.Document; // import
-                                            // org.apache.abdera.model.Feed;
-// import org.apache.abdera.model.Link;
-import org.apache.abdera.model.Service;
-import org.apache.abdera.model.Workspace;
 import org.apache.abdera.parser.ParseException;
-import org.apache.abdera.parser.Parser;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.tuscany.sca.data.collection.Entry;
@@ -74,10 +65,7 @@
 class GdataBindingListenerServlet extends HttpServlet {
     private static final Logger logger = Logger.getLogger(GdataBindingListenerServlet.class.getName());
     private static final long serialVersionUID = 1L;
-
-    private static final Factory abderaFactory = Abdera.getNewFactory();
-    private static final Parser abderaParser = Abdera.getNewParser();
-
+     
     private RuntimeWire wire;
     private Invoker getFeedInvoker;
     private Invoker getAllInvoker;
@@ -114,10 +102,10 @@
             invocationChain.setAllowsPassByReference(true);
             Operation operation = invocationChain.getTargetOperation();
             String operationName = operation.getName();
+           
             if (operationName.equals("getFeed")) {
 
-                System.out.println("[Debug Info]GdataBindingListenerServlet constructor --- operation: getFeed");
-
+                //System.out.println("[Debug Info]GdataBindingListenerServlet constructor --- operation: getFeed");
                 getFeedInvoker = invocationChain.getHeadInvoker();
 
             } else if (operationName.equals("getAll")) {
@@ -125,18 +113,26 @@
                 getAllInvoker = invocationChain.getHeadInvoker();
 
             } else if (operationName.equals("query")) {
+                
                 queryInvoker = invocationChain.getHeadInvoker();
+                
             } else if (operationName.equals("get")) {
-                System.out.println("[Debug Info]GdataBindingListenerServlet Constructor --- opeartion: get");
+                
+                //System.out.println("[Debug Info]GdataBindingListenerServlet Constructor --- opeartion: get");
                 getInvoker = invocationChain.getHeadInvoker();
                 getOperation = operation;
+                
             } else if (operationName.equals("put")) {
+                
                 putInvoker = invocationChain.getHeadInvoker();
+                
             } else if (operationName.equals("putMedia")) {
+                
                 putMediaInvoker = invocationChain.getHeadInvoker();
+                
             } else if (operationName.equals("post")) {
 
-                System.out.println("[Debug Info]GdataBindingListenerServlet Constructor --- opeartion: post");
+                //System.out.println("[Debug Info]GdataBindingListenerServlet Constructor --- opeartion: post");
                 postInvoker = invocationChain.getHeadInvoker();
 
             } else if (operationName.equals("postMedia")) {
@@ -146,13 +142,12 @@
             }
         }
 
-        System.out.println("[Debug Info]GdataBindingListenerServlet constructor --- I am good here 00");
+        //System.out.println("[Debug Info]GdataBindingListenerServlet constructor --- I am good here 00");
 
         // Determine the collection item type
         itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
         Class<?> itemClass = getOperation.getOutputType().getPhysical();
-
-        // if (itemClass == org.apache.abdera.model.Entry.class) {
+       
         if (itemClass == com.google.gdata.data.Entry.class) {
             supportsFeedEntries = true;
         }
@@ -161,9 +156,10 @@
         qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName());
         itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null));
 
-        System.out.println("[Debug Info]GdataBindingListenerServlet constructor --- initilized!");
+        System.out.println("[Debug Info]GdataBindingListenerServlet --- initilized!");
     }
 
+    
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 
@@ -182,21 +178,13 @@
 
         // Handle an Atom request
         if (path != null && path.equals("/atomsvc")) {
-            /*
-             * <?xml version='1.0' encoding='UTF-8'?> <service
-             * xmlns="http://www.w3.org/2007/app"
-             * xmlns:atom="http://www.w3.org/2005/Atom"> <workspace> <atom:title
-             * type="text">resource</atom:title> <collection
-             * href="http://luck.ibm.com:8084/customer"> <atom:title
-             * type="text">entries</atom:title>
-             * <accept>application/atom+xml;type=entry</accept> <categories />
-             * </collection> </workspace> </service>
-             */
 
+            //FIXME: This needs to be fixed, for /atomsvc
+            
+            /*            
             System.out.println("GdataBindingListenerServlet doGet(): I am good here brach 01");
             // Return the Atom service document
             response.setContentType("application/atomsvc+xml; charset=utf-8");
-
             Service service = abderaFactory.newService();
             // service.setText("service");
 
@@ -222,6 +210,7 @@
             } catch (IOException ioe) {
                 throw new ServletException(ioe);
             }
+            */
 
         } else if (path == null || path.length() == 0 || path.equals("/")) {
 
@@ -234,8 +223,7 @@
 
             if (supportsFeedEntries) {
 
-                System.out
-                    .println("[Debug Info]GdataBindingListenerServlet doGet() --- supportsFeedEntries: " + supportsFeedEntries);
+                System.out.println("[Debug Info]GdataBindingListenerServlet doGet() --- supportsFeedEntries: " + supportsFeedEntries);
 
                 // The service implementation supports feed entries, invoke its
                 // getFeed operation
@@ -253,7 +241,7 @@
                     throw new ServletException((Throwable)responseMessage.getBody());
                 }
 
-                System.out.println("response msg class:" + responseMessage.getBody().getClass());
+                //System.out.println("response msg class:" + responseMessage.getBody().getClass());
 
                 feed = (com.google.gdata.data.Feed)responseMessage.getBody();
 
@@ -275,9 +263,9 @@
                 } else {
                     responseMessage = getAllInvoker.invoke(requestMessage);
 
-                    System.out
-                        .println("GdataBindingListner.doGet(): get msg from getAllInvoker.invoke()" + responseMessage
-                            .getBody().toString());
+                    //System.out
+                    //    .println("GdataBindingListner.doGet(): get msg from getAllInvoker.invoke()" + responseMessage
+                    //        .getBody().toString());
 
                 }
                 if (responseMessage.isFault()) {
@@ -364,7 +352,7 @@
                 // mediator, abderaFactory);
             }
 
-            // Write the Atom entry
+            // Write the Gdata entry
             if (feedEntry != null) {
 
                 // Write a GData entry using Atom representation
@@ -423,15 +411,8 @@
                 try {
                     ParseSource source = new ParseSource(request.getReader());
                     feedEntry = com.google.gdata.data.Entry.readEntry(source, com.google.gdata.data.Entry.class, null);
-
-                    /*
-                     * Document<org.apache.abdera.model.Entry> doc =
-                     * abderaParser.parse(request.getReader()); feedEntry =
-                     * doc.getRoot();
-                     */
                 } catch (ParseException pe) {
                     throw new ServletException(pe);
-
                 } catch (com.google.gdata.util.ParseException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
@@ -537,6 +518,7 @@
         return writer;
     }
 
+    
     @Override
     protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 
@@ -550,6 +532,8 @@
         // Get the request path
         String path = request.getRequestURI().substring(request.getServletPath().length());
 
+        System.out.println("[Debug Info] localServlet doPut --- path: " + path);
+        
         if (path != null && path.startsWith("/")) {
             String id = path.substring(1);
 
@@ -558,17 +542,29 @@
             if (contentType != null && contentType.startsWith("application/atom+xml")) {
 
                 // Read the entry from the request
-                org.apache.abdera.model.Entry feedEntry;
+                com.google.gdata.data.Entry feedEntry = null;
                 try {
-                    Document<org.apache.abdera.model.Entry> doc = abderaParser.parse(request.getReader());
-                    feedEntry = doc.getRoot();
+                    ParseSource source = new ParseSource(request.getReader());
+                    feedEntry = com.google.gdata.data.Entry.readEntry(source, com.google.gdata.data.Entry.class, null);
+                
+                    System.out.println("[Debug Info] localServlet doPut --- feedEntry title: " + feedEntry.getTitle().getPlainText());
                 } catch (ParseException pe) {
                     throw new ServletException(pe);
+                } catch (com.google.gdata.util.ParseException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } catch (ServiceException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
                 }
+                
+                
 
                 // Let the component implementation create it
                 if (supportsFeedEntries) {
 
+                    System.out.println("[Debug Info] localServlet doPut --- supportsFeedEntries: " + supportsFeedEntries);
+                    
                     // The service implementation supports feed entries, pass
                     // the entry to it
                     Message requestMessage = messageFactory.createMessage();
@@ -599,6 +595,27 @@
                         }
                     }
                 }
+                
+                // Write the Gdata entry
+                if (feedEntry != null) {
+
+                    // Write a GData entry using Atom representation
+                    response.setContentType("application/atom+xml; charset=utf-8");
+
+                    // Generate the corresponding Atom representation of the feed
+                    StringWriter stringWriter = new StringWriter();
+                    com.google.gdata.util.common.xml.XmlWriter w =
+                        new com.google.gdata.util.common.xml.XmlWriter(stringWriter);
+                    feedEntry.generateAtom(w, new ExtensionProfile());
+                    w.flush();
+
+                    // Write the Atom representation(XML) into Http response content
+                    OutputStreamWriter osw = new OutputStreamWriter(response.getOutputStream());
+                    PrintWriter out = new PrintWriter(response.getOutputStream());
+                    out.println(stringWriter.toString());
+                    out.close();
+
+                }
 
             } else if (contentType != null) {
 
@@ -623,6 +640,9 @@
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
         }
     }
+    
+    
+    
 
     @Override
     protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException,
@@ -659,6 +679,8 @@
         }
     }
 
+    
+    
     /**
      * Process the authorization header
      * 

Modified: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java (original)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java Wed Jul 16 23:21:15 2008
@@ -36,6 +36,8 @@
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 
+import com.google.gdata.util.AuthenticationException;
+
 /**
  * Implementation of a Binding provider factory for the Atom binding.
  */
@@ -58,7 +60,14 @@
     public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
                                                                    RuntimeComponentReference reference,
                                                                    GdataBinding binding) {
-        return new GdataReferenceBindingProvider(component, reference, binding, mediator);
+        try {
+            return new GdataReferenceBindingProvider(component, reference, binding, mediator);
+        } catch (AuthenticationException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            return null; //Google authentication error! : This exception needs to be handled into a better way
+        }
+        
     }
 
     public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,

Modified: tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java?rev=677508&r1=677507&r2=677508&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java (original)
+++ tuscany/java/sca/modules/binding-gdata-runtime-gsoc/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java Wed Jul 16 23:21:15 2008
@@ -21,15 +21,6 @@
 
 import java.util.Date;
 
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Content;
-import org.apache.abdera.model.Link;
-
-// To-Change
-// import com.google.gdata.data.Entry;
-// import com.google.gdata.data.Feed;
-// import com.google.gdata.data.Link;
-
 import org.apache.tuscany.sca.data.collection.Entry;
 import org.apache.tuscany.sca.data.collection.Item;
 import org.apache.tuscany.sca.databinding.Mediator;
@@ -46,174 +37,7 @@
 class GdataBindingUtil {
 
     /**
-     * Create a data item from an Atom entry.
-     * 
-     * @param feedEntry
-     * @param itemClassType
-     * @param itemXMLType
-     * @param mediator
-     * @return
-     */
-    // To-Change: org.apache.abdera.model.Entry --> com.google.gdata.data.Entry
-    static Entry<Object, Object> entry(org.apache.abdera.model.Entry feedEntry,
-                                       DataType<?> itemClassType,
-                                       DataType<?> itemXMLType,
-                                       Mediator mediator) {
-        if (feedEntry != null) {
-            if (itemClassType.getPhysical() == Item.class) {
-                String key = feedEntry.getId().toString();
-
-                Item item = new Item();
-                item.setTitle(feedEntry.getTitle());
-                item.setContents(feedEntry.getContent());
-
-                for (Link link : feedEntry.getLinks()) {
-                    if (link.getRel() == null || "self".equals(link.getRel())) {
-                        if (item.getLink() == null) {
-                            item.setLink(link.getHref().toString());
-                        }
-                    } else if ("related".equals(link.getRel())) {
-                        item.setRelated(link.getHref().toString());
-                    } else if ("alternate".equals(link.getRel())) {
-                        item.setAlternate(link.getHref().toString());
-                    }
-                }
-
-                item.setDate(feedEntry.getUpdated());
-                return new Entry<Object, Object>(key, item);
-
-                // To-change
-                // Get feed information from feedEntry and create a new Entry
-                // For GDtata, the corresponding methods are different such as
-                // getTitle(), getContent(), getUpdated() and getLinks()
-                // I am going to use Gdata Entry(com.google.gdata.data.Entry)
-                // and modify accordingly
-
-            } else {
-                String key = null;
-                if (feedEntry.getId() != null) {
-                    key = feedEntry.getId().toString();
-                }
-
-                // Create the item from XML
-                if (feedEntry.getContentElement().getElements().size() == 0) {
-                    return null;
-                }
-
-                String value = feedEntry.getContent();
-                Object data = mediator.mediate(value, itemXMLType, itemClassType, null);
-
-                return new Entry<Object, Object>(key, data);
-
-                // To-change
-                // For GDtata, feedEntry.getContent() will return a
-                // content(com.google.gdata.data.Content)
-                // mediator.mediate needs to be changed accordingly
-            }
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Create an Atom entry for a key and item from a collection.
-     * 
-     * @param entry
-     * @param itemClassType
-     * @param itemXMLType
-     * @param mediator
-     * @param factory
-     * @return
-     */
-
-    // To-Change: org.apache.abdera.model.Entry --> com.google.gdata.data.Entry
-    static org.apache.abdera.model.Entry feedEntry(Entry<Object, Object> entry,
-                                                   DataType<?> itemClassType,
-                                                   DataType<?> itemXMLType,
-                                                   Mediator mediator,
-                                                   Factory factory) {
-        Object key = entry.getKey();
-        Object data = entry.getData();
-        if (data instanceof Item) {
-            Item item = (Item)data;
-
-            org.apache.abdera.model.Entry feedEntry = factory.newEntry();
-            if (key != null) {
-                feedEntry.setId(key.toString());
-            }
-            feedEntry.setTitle(item.getTitle());
-            feedEntry.setContentAsHtml(item.getContents());
-
-            String href = item.getLink();
-            if (href == null && key != null) {
-                href = key.toString();
-            }
-
-            if (href != null) {
-                feedEntry.addLink(href);
-            }
-            String related = item.getRelated();
-            if (related != null) {
-                feedEntry.addLink(related, "related");
-            }
-            String alternate = item.getAlternate();
-            if (alternate != null) {
-                feedEntry.addLink(alternate, "alternate");
-            }
-
-            Date date = item.getDate();
-            if (date != null) {
-                feedEntry.setUpdated(date);
-            }
-            return feedEntry;
-
-            // To-change
-            // Get feed information from collection.item and create a new Gdata
-            // Entry
-            // For GDtata, the corresponding methods are quite different such as
-            // setTitle(), setContent(), setUpdated(), addLink()
-            //
-            // For example:
-            // entry.setTitle(new PlainTextConstruct("title_"));
-            // entry.setContent(new PlainTextConstruct("content_"));
-            // entry.setUpdated(DateTime.now());
-            // entry.addHtmlLink("http://www.google.com", "languageType",
-            // "title");
-            //
-            // I am going to use Gdata Entry(com.google.gdata.data.Entry) and
-            // modify accordingly
-
-        } else if (data != null) {
-            org.apache.abdera.model.Entry feedEntry = factory.newEntry();
-            feedEntry.setId(key.toString());
-            feedEntry.setTitle("item");
-
-            // Convert the item to XML
-            String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
-
-            Content content = factory.newContent();
-            content.setContentType(Content.Type.XML);
-            content.setValue(value);
-
-            feedEntry.setContentElement(content);
-
-            feedEntry.addLink(key.toString());
-
-            return feedEntry;
-
-            // To-change
-            // Get feed information from XML data(item to XML first via
-            // mediator)
-            // and create a new Gdata Entry
-            // Modify GData Entry set methods accordingly
-
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Create a data item from an Gdata entry.
+     * Create a data item from an GData entry.
      * 
      * @param feedEntry
      * @param itemClassType