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/02/27 17:12:47 UTC
svn commit: r631627 - in /incubator/tuscany/java/sca/samples/store: pom.xml
src/main/java/services/ShoppingCartImpl.java
Author: lresende
Date: Wed Feb 27 08:12:44 2008
New Revision: 631627
URL: http://svn.apache.org/viewvc?rev=631627&view=rev
Log:
Porting store sample to use new binding-feed-atom (using Abdera)
Modified:
incubator/tuscany/java/sca/samples/store/pom.xml
incubator/tuscany/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java
Modified: incubator/tuscany/java/sca/samples/store/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/store/pom.xml?rev=631627&r1=631626&r2=631627&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/store/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/store/pom.xml Wed Feb 27 08:12:44 2008
@@ -58,7 +58,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-feed-atom</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
</dependency>
Modified: incubator/tuscany/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java?rev=631627&r1=631626&r2=631627&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java (original)
+++ incubator/tuscany/java/sca/samples/store/src/main/java/services/ShoppingCartImpl.java Wed Feb 27 08:12:44 2008
@@ -24,25 +24,28 @@
import java.util.Map;
import java.util.UUID;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
import org.apache.tuscany.sca.binding.feed.collection.Collection;
import org.apache.tuscany.sca.binding.feed.collection.NotFoundException;
-import com.sun.syndication.feed.atom.Content;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.feed.atom.Link;
public class ShoppingCartImpl implements Collection {
private static Map<String, Entry> cart = new HashMap<String, Entry>();
public Feed getFeed() {
- Feed feed = new Feed();
+ Feed feed = Abdera.getNewFactory().newFeed();
feed.setTitle("shopping cart");
- Content subtitle = new Content();
- subtitle.setValue("Total : " + getTotal());
- feed.setSubtitle(subtitle);
- feed.getEntries().addAll(cart.values());
+ feed.setSubtitle("Total : " + getTotal());
+
+ for (Entry entry : cart.values()) {
+ feed.addEntry(entry);
+ }
+
return feed;
}
@@ -55,16 +58,10 @@
String id = "cart-" + UUID.randomUUID().toString();
entry.setId(id);
- Link link = new Link();
- link.setRel("edit");
- link.setHref(id);
- entry.getOtherLinks().add(link);
- link = new Link();
- link.setRel("alternate");
- link.setHref(id);
- entry.getAlternateLinks().add(link);
-
- entry.setCreated(new Date());
+ entry.addLink(id, "edit");
+ entry.addLink(id, "alternate");
+
+ entry.setEdited(new Date());
cart.put(id, entry);
return entry;
@@ -86,11 +83,11 @@
float total = 0;
String currencySymbol = "";
if (!cart.isEmpty()) {
- String item = ((Content)cart.values().iterator().next().getContents().get(0)).getValue();
+ String item = ((Entry)cart.values().iterator().next()).getContent();
currencySymbol = item.substring(item.indexOf("-") + 2, item.indexOf("-") + 3);
}
for (Entry entry : cart.values()) {
- String item = ((Content)entry.getContents().get(0)).getValue();
+ String item = entry.getContent();
int index = item.length()-1;
char digit;
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org