From a94f108acb136072151a2d794aaeeb9f810159f2 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 6 Aug 2008 15:50:37 +0000 Subject: TUSCANY-2530 - Applying Dan's patch that provides atom feed id and last updated support for customer collection git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@683305 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/atom/CustomerCollectionImpl.java | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/java/sca/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java b/java/sca/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java index d994e0af73..db66b00a50 100644 --- a/java/sca/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java +++ b/java/sca/modules/binding-atom-abdera/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java @@ -36,16 +36,13 @@ import org.osoa.sca.annotations.Scope; public class CustomerCollectionImpl implements Collection { private final Abdera abdera = new Abdera(); private Map entries = new HashMap(); - + public Date lastModified = new Date(); + /** - * Default constructor that initializes collection with couple customer - * entries + * Default constructor */ public CustomerCollectionImpl() { - // Used for testing. - // for (int i = 0; i < 4; i++) { - // testPut( "Jane Doe_" + String.valueOf( i )); - // } + } public Entry post(Entry entry) { @@ -58,7 +55,9 @@ public class CustomerCollectionImpl implements Collection { entry.addLink("" + id, "edit"); entry.addLink("" + id, "alternate"); - entry.setUpdated(new Date()); + Date now = new Date(); + entry.setUpdated(now); + lastModified = now; entries.put(id, entry); System.out.println(">>> CustomerCollectionImpl.post return id=" + id); @@ -80,7 +79,9 @@ public class CustomerCollectionImpl implements Collection { public void put(String id, Entry entry) throws NotFoundException { System.out.println(">>> CustomerCollectionImpl.put id=" + id + " entry=" + entry.getTitle()); if(entries.containsKey(id)){ - entry.setUpdated(new Date()); + Date now = new Date(); + entry.setUpdated(now); + lastModified = now; entries.put(id, entry); } else { @@ -92,20 +93,21 @@ public class CustomerCollectionImpl implements Collection { System.out.println(">>> CustomerCollectionImpl.delete id=" + id); if(entries.containsKey(id)){ entries.remove(id); + lastModified = new Date(); } else { throw new NotFoundException(); } } - @SuppressWarnings("unchecked") public Feed getFeed() { System.out.println(">>> CustomerCollectionImpl.getFeed"); Feed feed = this.abdera.getFactory().newFeed(); + feed.setId("customers" + this.hashCode() ); // provide unique id for feed instance. feed.setTitle("customers"); feed.setSubtitle("This is a sample feed"); - feed.setUpdated(new Date()); + feed.setUpdated(lastModified); feed.addLink(""); feed.addLink("", "self"); -- cgit v1.2.3