diff options
Diffstat (limited to 'branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca')
7 files changed, 54 insertions, 60 deletions
diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java index 31e16e5f56..774dc59269 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java @@ -20,13 +20,14 @@ package org.apache.tuscany.sca.binding.gdata.collection; import java.io.InputStream; -import org.osoa.sca.annotations.Remotable; // import - // org.apache.abdera.model.Entry; +import org.osoa.sca.annotations.Remotable; import com.google.gdata.data.Entry; /** * Provides access to a collection of resources using Atom. + * + * @version $Rev$ $Date$ */ @Remotable public interface MediaCollection extends Collection { diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/NotFoundException.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/NotFoundException.java index 4fc32d4d37..91e3616ad9 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/NotFoundException.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/NotFoundException.java @@ -24,6 +24,7 @@ package org.apache.tuscany.sca.binding.gdata.collection; * * @version $Rev$ $Date$ */ + public class NotFoundException extends Exception { private static final long serialVersionUID = -5046027674128627383L; @@ -41,5 +42,4 @@ public class NotFoundException extends Exception { public NotFoundException(String message, Throwable cause) { super(message, cause); } - } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java index 859318a306..460aa81378 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java @@ -46,6 +46,8 @@ import com.google.gdata.util.ServiceException; /** * Invoker for the GData binding. + * + * @version $Rev$ $Date$ */ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { @@ -71,6 +73,11 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { } + + public boolean allowsPassByReference() { + return true; + } + public Message invoke(Message msg) { // Shouldn't get here, as the only supported methods are // defined in the ResourceCollection interface, and implemented @@ -83,6 +90,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { * Get operation invoker */ public static class GetInvoker extends GdataBindingInvoker { + public GetInvoker(Operation operation, String uri, GoogleService googleService, @@ -145,23 +153,19 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { // Expect an GData entry - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider - .supportsFeedEntries()); + System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider.supportsFeedEntries()); feedEntry = (com.google.gdata.data.Entry)args[0]; - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- feedEntry title: " + feedEntry - .getTitle().getPlainText()); + System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- feedEntry title: " + feedEntry.getTitle().getPlainText()); } else { // Expect a key and data item Entry<Object, Object> entry = new Entry<Object, Object>(args[0], args[1]); // FIXME: this needs to be examinated more.... - feedEntry = - feedEntry(entry, provider.getItemClassType(), provider.getItemXMLType(), provider.getMediator()); + feedEntry = feedEntry(entry, provider.getItemClassType(), provider.getItemXMLType(), provider.getMediator()); } - try { com.google.gdata.data.Entry createdEntry = googleService.insert(new URL(uri), feedEntry); @@ -212,13 +216,6 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { id = (String)args[0]; Entry<Object, Object> entry = new Entry<Object, Object>(id, args[1]); - // FIXME: The following statement needs to be modified - // accordingly - /* - * feedEntry = feedEntry(entry, provider.getItemClassType(), - * provider.getItemXMLType(), provider.getMediator(), - * abderaFactory); - */ } // Send an HTTP PUT <Localhost> @@ -309,7 +306,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { } @SuppressWarnings("finally") - @Override + @Override public Message invoke(Message msg) { // Send an HTTP GET @@ -351,7 +348,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { } @SuppressWarnings("finally") - @Override + @Override public Message invoke(Message msg) { // Send an HTTP GET @@ -365,7 +362,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { try { - Feed resultFeed = googleService.query(myQuery, Feed.class); + Feed resultFeed = googleService.query(myQuery, Feed.class); msg.setBody(resultFeed); } catch (ResourceNotFoundException ex) { @@ -425,10 +422,4 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { return super.invoke(msg); } } - - public boolean allowsPassByReference() { - // TODO Auto-generated method stub - return true; - } - -} +}
\ No newline at end of file diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java index c09c1f7788..5259df15b8 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java @@ -58,9 +58,12 @@ import com.google.gdata.data.ParseSource; import com.google.gdata.data.PlainTextConstruct; import com.google.gdata.util.ServiceException; + /** * A resource collection binding listener, implemented as a Servlet and * registered in a Servlet host provided by the SCA hosting runtime. + * + * @version $Rev$ $Date$ */ class GdataBindingListenerServlet extends HttpServlet { private static final Logger logger = Logger.getLogger(GdataBindingListenerServlet.class.getName()); diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java index 695813a847..9de4772a70 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java @@ -40,6 +40,8 @@ import com.google.gdata.util.AuthenticationException; /** * Implementation of a Binding provider factory for the Atom binding. + * + * @version $Rev$ $Date$ */ public class GdataBindingProviderFactory implements BindingProviderFactory<GdataBinding> { @@ -63,7 +65,6 @@ public class GdataBindingProviderFactory implements BindingProviderFactory<Gdata 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 } diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java index 86fc8fd43f..3d476df764 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java @@ -33,6 +33,7 @@ import com.google.gdata.data.TextContent; /** * Utility methods used in this package. * + * @version $Rev$ $Date$ */ class GdataBindingUtil { diff --git a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java index 70bf58a161..c20e44f7da 100644 --- a/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java +++ b/branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java @@ -83,7 +83,6 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { String authorization = "admin" + ":" + "admin"; authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes())); - // Prepare gdata header String serviceType = binding.getServiceType(); String usernane = binding.getUsername(); @@ -97,8 +96,6 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { if(binding.getUsername().equals("admin") == false && binding.getPassword().equals("admin")==false){ googleService.setUserCredentials(binding.getUsername(),binding.getPassword()); } - - // Create an HTTP client HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); @@ -111,9 +108,6 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { String operationName = operation.getName(); - // //System.out.println("GdataReferenceBindingProvider.createInvoker---operationName:" - // + operationName); - if (operationName.equals("get")) { // Determine the collection item type @@ -128,7 +122,12 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { supportsFeedEntries = true; } - return new GdataBindingInvoker.GetInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); + String entryURI = this.binding.getURI(); + if(entryURI.contains("picasaweb.google.com/data/feed/api/")){ + entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/"); + } + + return new GdataBindingInvoker.GetInvoker(operation, entryURI, googleService, httpClient, authorizationHeader, this); } else if (operationName.equals("post")) { @@ -136,53 +135,51 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { } else if (operationName.equals("put")) { - return new GdataBindingInvoker.PutInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + String entryURI = this.binding.getURI(); + if(entryURI.contains("picasaweb.google.com/data/feed/api/")){ + entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/"); + } + + return new GdataBindingInvoker.PutInvoker(operation, entryURI, googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("delete")) { - return new GdataBindingInvoker.DeleteInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); - } else if (operationName.equals("getFeed") || operationName.equals("getAll")) { - // //System.out.println("GdataReferenceBindingProvider - // CreateInvoker: getFeed or getAll"); + String entryURI = this.binding.getURI(); + if(entryURI.contains("picasaweb.google.com/data/feed/api/")){ + entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/"); + } + return new GdataBindingInvoker.DeleteInvoker(operation, entryURI, googleService, httpClient, authorizationHeader, this); + + } else if (operationName.equals("getFeed") || operationName.equals("getAll")) { - return new GdataBindingInvoker.GetAllInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + return new GdataBindingInvoker.GetAllInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); } else if (operationName.equals("postMedia")) { - return new GdataBindingInvoker.PostMediaInvoker(operation, binding.getURI(), googleService, httpClient, - authorizationHeader, this); + + return new GdataBindingInvoker.PostMediaInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("putMedia")) { - return new GdataBindingInvoker.PutMediaInvoker(operation, binding.getURI(), googleService, httpClient, - authorizationHeader, this); + + return new GdataBindingInvoker.PutMediaInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("query")) { - return new GdataBindingInvoker.QueryInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + + return new GdataBindingInvoker.QueryInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); } return new GdataBindingInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); } - - public InterfaceContract getBindingInterfaceContract() { return reference.getInterfaceContract(); } - - public void start() { - // Configure the HTTP client credentials Credentials credentials = new UsernamePasswordCredentials("admin", "admin"); httpClient.getParams().setAuthenticationPreemptive(true); URI uri = URI.create(binding.getURI()); httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials); - - // Find the get operation on the reference interface - if (true) { - return; - } } public void stop() { |