diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-25 02:09:38 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-25 02:09:38 +0000 |
commit | 4f9c27618b619916842c1fa14f9fe96bd993321e (patch) | |
tree | e22de800175d7fec8d344567377db2b6c548423f /java | |
parent | 9a1cae989c97875322ab4b7b9c9ef6348cbf01e4 (diff) |
TUSCANY-2435 - Applying Douglas Path that adds support for query operation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@671397 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
2 files changed, 43 insertions, 17 deletions
diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java index ebf0595c9d..e115c80a49 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GDataBindingInvoker.java @@ -25,10 +25,10 @@ import org.apache.tuscany.sca.invocation.Message; import org.osoa.sca.ServiceRuntimeException; import com.google.gdata.client.GoogleService; +import com.google.gdata.client.Query; import com.google.gdata.data.BaseEntry; import com.google.gdata.data.Entry; import com.google.gdata.data.Feed; -import com.google.gdata.data.extensions.EventEntry; import java.net.URL; import com.google.gdata.util.ServiceException; import com.google.gdata.util.ResourceNotFoundException; @@ -39,7 +39,7 @@ import org.apache.tuscany.sca.invocation.DataExchangeSemantics; * * @version $Rev$ $Date$ */ -class GDataBindingInvoker implements Invoker { +class GDataBindingInvoker implements Invoker, DataExchangeSemantics { Operation operation; String uri; @@ -73,8 +73,7 @@ class GDataBindingInvoker implements Invoker { try { String id = (String) ((Object[]) msg.getBody())[0]; - //FIXME - Adapt the class to each kind of entry - BaseEntry searchedEntry = service.getEntry(new URL(id), EventEntry.class); + BaseEntry searchedEntry = service.getEntry(new URL(id), Entry.class); msg.setBody(searchedEntry); @@ -82,8 +81,9 @@ class GDataBindingInvoker implements Invoker { msg.setFaultBody(new ServiceRuntimeException(ex)); } catch (ServiceException ex) { msg.setFaultBody(new ServiceRuntimeException(ex)); + } finally { + return msg; } - return msg; } } @@ -110,9 +110,9 @@ class GDataBindingInvoker implements Invoker { msg.setFaultBody(new ServiceRuntimeException(ex)); } catch (ServiceException ex) { msg.setFaultBody(new ServiceRuntimeException(ex)); + } finally { + return msg; } - - return msg; } } @@ -141,9 +141,9 @@ class GDataBindingInvoker implements Invoker { msg.setFaultBody(new ServiceRuntimeException(ex)); } catch (ServiceException ex) { msg.setFaultBody(new ServiceRuntimeException(ex)); + } finally { + return msg; } - - return msg; } } @@ -161,14 +161,14 @@ class GDataBindingInvoker implements Invoker { try { String id = (String) ((Object[]) msg.getBody())[0]; service.delete(new URL(id)); - + } catch (IOException ex) { msg.setFaultBody(new ServiceRuntimeException(ex)); } catch (ServiceException ex) { msg.setFaultBody(new ServiceRuntimeException(ex)); + } finally { + return msg; } - - return msg; } } @@ -196,9 +196,9 @@ class GDataBindingInvoker implements Invoker { msg.setFaultBody(new ServiceRuntimeException(ex)); } catch (Exception ex) { msg.setFaultBody(new ServiceRuntimeException(ex)); + } finally { + return msg; } - - return msg; } } @@ -213,8 +213,22 @@ class GDataBindingInvoker implements Invoker { @Override public Message invoke(Message msg) { - // TODO implement - return super.invoke(msg); + try { + + String strQuery = (String) ((Object[]) msg.getBody())[0]; + + Query query = new Query(new URL(uri)); + query.setFullTextQuery(strQuery); + Feed feed = service.query(query, Feed.class); + msg.setBody(feed); + + } catch (IOException ex) { + msg.setFaultBody(new ServiceRuntimeException(ex)); + } catch (ServiceException ex) { + msg.setFaultBody(new ServiceRuntimeException(ex)); + } finally { + return msg; + } } } diff --git a/java/sca/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java b/java/sca/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java index 4948a6508f..f60fb61dc2 100644 --- a/java/sca/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java +++ b/java/sca/modules/binding-gdata-runtime/src/test/java/org/apache/tuscany/sca/binding/gdata/CustomerClientImpl.java @@ -96,8 +96,20 @@ public class CustomerClientImpl implements CustomerClient { "\n//--------------------------" + "\n// Delete an Entry" + "\n//--------------------------\n"); - + resourceCollection.delete(updatedEntry.getEditLink().getHref()); + System.out.println( + "\n//--------------------------" + + "\n// Execute a query" + + "\n//--------------------------\n"); + + feed = resourceCollection.query("Students"); + + System.out.println("Feed content - " + feed.getUpdated().toString() + ":\n"); + for (Entry e : feed.getEntries()) { + System.out.println("# " + e.getTitle().getPlainText()); + } + } } |