diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-28 06:34:31 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-28 06:34:31 +0000 |
commit | d7da0b211d2f025cdb2fe4ac46d015b73ca10a6e (patch) | |
tree | eb56a5ab8696903ce350ba2c76dde7f4ec663bd7 /branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java | |
parent | 74f1b78443a084043576e194ab077c7424efeae7 (diff) |
Cleaning up GData binding implementation and fixing issue with retrieving Picassa feed
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@708460 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java')
-rw-r--r-- | branches/sca-equinox/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java | 61 |
1 files changed, 29 insertions, 32 deletions
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() { |