abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173284 - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/client/ activities/src/main/java/org/apache/abdera2/activities/extra/ activities/src/main/java/org/apache/abdera2/activities/io/gson/ activities/src/main/...
Date Tue, 20 Sep 2011 18:12:01 GMT
Author: jmsnell
Date: Tue Sep 20 18:12:00 2011
New Revision: 1173284

URL: http://svn.apache.org/viewvc?rev=1173284&view=rev
Log:
Additional examples and misc extras + some javadoc

Added:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
  (with props)
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
  (with props)
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/CollectionWriter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/IO.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Verb.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java
Tue Sep 20 18:12:00 2011
@@ -9,6 +9,11 @@ import org.apache.abdera2.protocol.clien
 import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.abdera2.protocol.client.Session;
 
+/**
+ * Extension of the base Abdera Client that provides utility methods
+ * for working with Activity Stream objects. The ActivityClient acts 
+ * as a decorator for the base Abdera Client. 
+ */
 public class ActivitiesClient 
   extends ClientWrapper {
 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java
Tue Sep 20 18:12:00 2011
@@ -16,6 +16,10 @@ import org.apache.abdera2.protocol.clien
 import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.abdera2.protocol.client.Session;
 
+/**
+ * Extension of the base Abdera Client Session that provides utility 
+ * methods for working with Activity Streams objects.
+ */
 public class ActivitiesSession 
   extends Session {
 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java
Tue Sep 20 18:12:00 2011
@@ -8,7 +8,14 @@ import org.apache.abdera2.common.templat
 /**
  * URI Templates Context implementation based on an Activity Streams
  * object. Makes it easier to construct new URLs based on the properties
- * of an Activity Streams object
+ * of an Activity Streams object. For example:
+ * 
+ * Template template = new Template("{?nextPageToken}"};
+ * ASObject obj = new ASObject();
+ * obj.setProperty("nextPageToken");
+ * ASContext ctx = new ASContext(obj);
+ * String the_new_iri = template.expand(ctx);
+ * 
  */
 public final class ASContext 
   extends AbstractContext {

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
Tue Sep 20 18:12:00 2011
@@ -3,10 +3,58 @@ package org.apache.abdera2.activities.ex
 
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.Verb;
 
+/**
+ * Miscellaneous extensions
+ */
+@SuppressWarnings("unchecked")
 public class Extra {
 
-  @SuppressWarnings("unchecked")
+  // As in "Sally purchased the app"
+  public static final Verb PURCHASE = new Verb("purchase") {};
+  
+  // As in: "Joe is hosting a meeting"
+  public static final Verb HOST = new Verb("host") {};
+  
+  // As in: "Mark read the book" ... this is related to "play", but saying that
+  // someone "played" a book just doesn't make much sense. A user can 
+  // "play" and audio book, but they must "read" the physical or ebook,
+  // also works for "Mark read the note", "Sally read the question", etc
+  public static final Verb READ = new Verb("read") {};
+  
+  // As in "Sally approved the line item"
+  public static final Verb APPROVE = new Verb("approve") {};
+  
+  // As in "Sally rejected the line item"
+  public static final Verb REJECT = new Verb("reject") {};
+  
+  // As in "Sally archived the document"
+  public static final Verb ARCHIVE = new Verb("archive") {};
+  
+  // As in "Mark installed the app"
+  public static final Verb INSTALL = new Verb("install") {};
+  
+  // As in "Mark closed the issue"
+  public static final Verb CLOSE = new Verb("close") {};
+  
+  // As in "Mark opened the issue" .. careful not to confuse this with
+  // creating an issue, for instance. For example, in source code 
+  // management, creating a new issue and "opening" it are two separate
+  // tasks. An item can be opened automatically when it is created,
+  // closed, and then opened again if it is determined to not have been
+  // resolved, etc.
+  public static final Verb OPEN = new Verb("open") {};
+  
+  // As in "Mark resolved the issue" .. careful not to confuse this with
+  // updating the issue or closing it. 
+  public static final Verb RESOLVE = new Verb("resolve") {};
+  
+  
+  /**
+   * Registers the "extra" object types with the IO instance
+   * for serialization/deserialization.
+   */
   public static void initExtras(IO io) {
 
     io.addObjectMapping(
@@ -15,7 +63,8 @@ public class Extra {
       OfferObject.class,
       TvEpisodeObject.class,
       TvSeasonObject.class,
-      TvSeriesObject.class);
+      TvSeriesObject.class,
+      VersionObject.class);
   }
   
   /**
@@ -73,6 +122,9 @@ public class Extra {
     return new ASObject("@public");
   }
   
+  /**
+   * Create an anonymous AS Object (no objectType property)
+   */
   public static ASObject anonymousObject(String id) {
     ASObject obj = new ASObject();
     obj.setObjectType(null);

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java?rev=1173284&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
(added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
Tue Sep 20 18:12:00 2011
@@ -0,0 +1,95 @@
+package org.apache.abdera2.activities.extra;
+
+import org.apache.abdera2.activities.io.gson.Properties;
+import org.apache.abdera2.activities.io.gson.Property;
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.common.anno.Name;
+
+/**
+ * Activity Stream object that represents a description of a Version 
+ * of a referenced object.
+ */
+@Name("version")
+@Properties({
+  @Property(name="previousVersion", to=VersionObject.class),
+  @Property(name="nextVersion",to=VersionObject.class)
+})
+public class VersionObject 
+  extends ASObject {
+
+  private static final long serialVersionUID = -7473463819890471971L;
+
+  public VersionObject() {}
+  
+  public VersionObject(String displayName) {
+    super();
+    setDisplayName(displayName);
+  }
+  
+  /** The object this object describes a version of **/
+  public <T extends ASObject>T getOf() {
+    return getProperty("of");
+  }
+  
+  /** The object this object describes a version of **/
+  public void setOf(ASObject object) {
+    setProperty("of", object);
+  }
+  
+  public VersionObject getPreviousVersion() {
+    return getProperty("previousVersion");
+  }
+  
+  public void setPreviousVersion(VersionObject version) {
+    setProperty("previousVersion", version);
+  }
+  
+  public VersionObject getNextVersion() {
+    return getProperty("nextVersion");
+  }
+  
+  public void setNextVersion(VersionObject version) {
+    setProperty("nextVersion", version);
+  }
+  
+  public VersionObject getStableVersion() {
+    return getProperty("stableVersion");
+  }
+  
+  public void setStableVersion(VersionObject version) {
+    setProperty("stableVersion", version);
+  }
+  
+  public VersionObject getActiveVersion() {
+    return getProperty("activeVersion");
+  }
+  
+  public void setActiveVersion(VersionObject version) {
+    setProperty("activeVersion", version);
+  }
+  
+  public String getMajor() {
+    return getProperty("major");
+  }
+  
+  public void setMajor(String val) {
+    setProperty("major", val);
+  }
+  
+  public String getMinor() {
+    return getProperty("minor");
+  }
+  
+  public void setMinor(String minor) {
+    setProperty("minor", minor);
+  }
+  
+  public String getRevision() {
+    return getProperty("revision");
+  }
+  
+  public void setRevision(String val) {
+    setProperty("revision", val);
+  }
+  
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java
Tue Sep 20 18:12:00 2011
@@ -259,6 +259,14 @@ public class GsonIO extends IO {
         throw new RuntimeException(e);
       }
     }
+    public void writeObjects(ASObject... objects) {
+      for (ASObject object : objects)
+        writeObject(object);
+    }
+    public void writeObjects(Iterable<ASObject> objects) {
+      for (ASObject object : objects)
+        writeObject(object);
+    }
     public void complete() {
       try {
         if (_items) writer.endArray();

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java
Tue Sep 20 18:12:00 2011
@@ -34,6 +34,10 @@ import org.apache.abdera2.common.iri.IRI
 import org.apache.abdera2.common.lang.Lang;
 import org.apache.abdera2.common.mediatype.MimeTypeParseException;
 
+/**
+ * Root of the Activity Streams object hierarchy, provides the core property
+ * management and can be used to represent simple, untyped objects.
+ */
 public class ASBase 
   implements Iterable<String>, Cloneable, Serializable, Copyable {
 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
Tue Sep 20 18:12:00 2011
@@ -27,7 +27,6 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.common.anno.AnnoUtil;
 import org.apache.abdera2.common.iri.IRI;
 
-
 @SuppressWarnings("unchecked")
 public class ASObject extends ASBase {
 
@@ -53,6 +52,8 @@ public class ASObject extends ASBase {
   public static final String TAGS = "tags";
   public static final String RATING = "rating";
   
+  public static final String EMBED = "embed";
+  
   public ASObject() {
     setObjectType(AnnoUtil.getName(this));
   }
@@ -69,14 +70,14 @@ public class ASObject extends ASBase {
     setProperty(ATTACHMENTS, attachments);
   }
   
-  public void addAttachment(ASObject attachment) {
-    Set<ASObject> attachments = getProperty(ATTACHMENTS);
-    if (attachments == null) {
-      attachments = new HashSet<ASObject>();
-      setProperty(ATTACHMENTS, attachments);
+  public void addAttachment(ASObject... attachments) {
+    Set<ASObject> list = getProperty(ATTACHMENTS);
+    if (list == null) {
+      list = new HashSet<ASObject>();
+      setProperty(ATTACHMENTS, list);
     }
-    attachments.add(attachment);
-    
+    for (ASObject attachment : attachments)
+      list.add(attachment); 
   }
   
   public <E extends ASObject>E getAuthor() {
@@ -129,14 +130,14 @@ public class ASObject extends ASBase {
     
   }
   
-  public void addDownstreamDuplicate(String downstreamDuplicate) {
+  public void addDownstreamDuplicate(String... duplicates) {
     Set<String> downstreamDuplicates = getProperty(DOWNSTREAMDUPLICATES);
     if (downstreamDuplicates == null) {
       downstreamDuplicates = new HashSet<String>();
       setProperty(DOWNSTREAMDUPLICATES, downstreamDuplicates);
     }
-    downstreamDuplicates.add(downstreamDuplicate);
-    
+    for (String downstreamDuplicate : duplicates)
+      downstreamDuplicates.add(downstreamDuplicate);  
   }
   
   public String getId() {
@@ -204,13 +205,14 @@ public class ASObject extends ASBase {
     
   }
   
-  public void addUpstreamDuplicate(String upstreamDuplicate) {
+  public void addUpstreamDuplicate(String... duplicates) {
     Set<String> upstreamDuplicates = getProperty(UPSTREAMDUPLICATES);
     if (upstreamDuplicates == null) {
       upstreamDuplicates = new HashSet<String>();
       setProperty(UPSTREAMDUPLICATES, upstreamDuplicates);
     }
-    upstreamDuplicates.add(upstreamDuplicate);
+    for (String upstreamDuplicate : duplicates)
+      upstreamDuplicates.add(upstreamDuplicate);
   }
   
   
@@ -230,13 +232,14 @@ public class ASObject extends ASBase {
     setProperty(INREPLYTO, inReplyTo);
   }
   
-  public void addInReplyTo(ASObject inReplyTo) {
+  public void addInReplyTo(ASObject... inReplyTos) {
     Set<ASObject> list = getProperty(INREPLYTO);
     if (list == null) {
       list = new HashSet<ASObject>();
       setProperty(INREPLYTO, list);
     }
-    list.add(inReplyTo);
+    for (ASObject inReplyTo : inReplyTos)
+      list.add(inReplyTo);
   }
   
   public PlaceObject getLocation() {
@@ -272,13 +275,30 @@ public class ASObject extends ASBase {
     setProperty(TAGS, tags);
   }
   
-  public void addTag(ASObject tag) {
+  public void addTag(ASObject... tags) {
     Set<ASObject> list = getProperty(TAGS);
     if (list == null) {
       list = new HashSet<ASObject>();
       setProperty(TAGS, list);
     }
-    list.add(tag); 
+    for (ASObject tag : tags)
+      list.add(tag); 
+  }
+  
+  /**
+   * @see org.apache.abdera2.activities.model.ASObject.getEmbeddedExperience()
+   * {"embed":{...}}
+   */
+  public <T extends ASObject>T getEmbed() {
+    return getProperty(EMBED);
+  }
+  
+  /**
+   * @see org.apache.abdera2.activities.model.ASObject.setEmbeddedExperience()
+   * {"embed":{...}}
+   */
+  public void setEmbed(ASObject embed) {
+    setProperty(EMBED,embed);
   }
   
   public double getRating() {
@@ -292,7 +312,10 @@ public class ASObject extends ASBase {
   public String toString() {
     StringBuilder sb = new StringBuilder();
     String objectType = getObjectType();
-    if (objectType != null) {
+    String displayName = getDisplayName();
+    if (displayName != null)
+      sb.append(displayName);
+    else if (objectType != null) {
       char s = objectType.charAt(0);
       if ("aeiou".indexOf(s) > -1) 
         sb.append("an ");
@@ -304,6 +327,24 @@ public class ASObject extends ASBase {
     return sb.toString();
   }
 
+  /**
+   * "Embedded Experiences" were introduced to Activity Streams 
+   * by the OpenSocial 2.0 specification, while functionally not 
+   * specific to OpenSocial, the spec defines that the "Embedded 
+   * Experience" document has to be wrapped within an "openSocial"
+   * extension property. Other applications, such as Google+, however,
+   * use the "embed" property directly within an object without the
+   * "openSocial" wrapper. To use the "embed" property without 
+   * the "openSocial" wrapper, use the setEmbed/getEmbed properties
+   * on ASObject. To use OpenSocial style Embedded Experiences, 
+   * use the setEmbeddedExperience/getEmbeddedExperience/hasEmbeddedExperience
+   * methods. The OpenSocial style Embedded Experience should be used
+   * primarily to associate OpenSocial Gadgets with an activity 
+   * object while the alternative "embed" can be used to reference
+   * any kind of embedded content.
+   * 
+   * {"openSocial":{"embed":{...}}}
+   */
   public void setEmbeddedExperience(EmbeddedExperience embed) {
     ASBase os = getProperty("openSocial");
     if (os == null) {
@@ -313,6 +354,24 @@ public class ASObject extends ASBase {
     os.setProperty("embed", embed);
   }
   
+  /**
+   * "Embedded Experiences" were introduced to Activity Streams 
+   * by the OpenSocial 2.0 specification, while functionally not 
+   * specific to OpenSocial, the spec defines that the "Embedded 
+   * Experience" document has to be wrapped within an "openSocial"
+   * extension property. Other applications, such as Google+, however,
+   * use the "embed" property directly within an object without the
+   * "openSocial" wrapper. To use the "embed" property without 
+   * the "openSocial" wrapper, use the setEmbed/getEmbed properties
+   * on ASObject. To use OpenSocial style Embedded Experiences, 
+   * use the setEmbeddedExperience/getEmbeddedExperience/hasEmbeddedExperience
+   * methods. The OpenSocial style Embedded Experience should be used
+   * primarily to associate OpenSocial Gadgets with an activity 
+   * object while the alternative "embed" can be used to reference
+   * any kind of embedded content.
+   * 
+   * {"openSocial":{"embed":{...}}}
+   */
   public EmbeddedExperience getEmbeddedExperience() {
     if (!has("openSocial")) return null;
     ASBase os = getProperty("openSocial");
@@ -325,6 +384,9 @@ public class ASObject extends ASBase {
     return (EmbeddedExperience) e;
   }
   
+  /**
+   * Checks to see if the "openSocial":{"embed":{...}} property exists
+   */
   public boolean hasEmbeddedExperience() {
     if (!has("openSocial")) return false;
     ASBase os = getProperty("openSocial");

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
Tue Sep 20 18:12:00 2011
@@ -76,13 +76,14 @@ public class Collection<T extends ASObje
     setTotalItems(items.size());
   }
   
-  public void addItem(T item) {
+  public void addItem(T... items) {
     Set<T> list = getProperty(ITEMS);
     if (list == null) {
       list = new LinkedHashSet<T>();
       setProperty(ITEMS, list);
     }
-    list.add(item);
+    for (T item : items)
+      list.add(item);
     setTotalItems(list.size());
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/CollectionWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/CollectionWriter.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/CollectionWriter.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/CollectionWriter.java
Tue Sep 20 18:12:00 2011
@@ -6,6 +6,10 @@ public interface CollectionWriter {
   
   void writeObject(ASObject object);
   
+  void writeObjects(ASObject... objects);
+  
+  void writeObjects(Iterable<ASObject> objects);
+  
   void complete();
   
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
Tue Sep 20 18:12:00 2011
@@ -4,6 +4,14 @@ import java.util.Map;
 
 import org.apache.abdera2.common.iri.IRI;
 
+/**
+ * Represents an Embedded Experience data structure. Embedded Experiences
+ * were introduced to Activity Streams through the OpenSocial 2.0 specification.
+ * While EE structures can be used outside the scope of OpenSocial, they are
+ * primarily intended to be used as a means of associating an OpenSocial
+ * Gadget specification with an Activity Stream object that can be rendered 
+ * in-line when the activity data is displayed within an OpenSocial container.
+ */
 public class EmbeddedExperience 
   extends ASBase {
 

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/IO.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/IO.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/IO.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/IO.java Tue
Sep 20 18:12:00 2011
@@ -31,7 +31,20 @@ import org.apache.abdera2.common.anno.De
 
 /**
  * Primary interface for serializing/deserializing Activity objects. 
- * Instances of IO are threadsafe. 
+ * The write/parse operations on IO should be considered threadsafe, 
+ * however, all initiatization of the IO should be completed prior 
+ * to using the class to read or produce Activity Stream documents.
+ * This means that all calls to addPropertyMapping and addObjectMapping
+ * MUST be performed as part of the initialization code of the IO 
+ * instance. Note that when using property mappings, conflicts may
+ * occur when working with different objects that use different 
+ * value types for similarly named properties, e.g. if you have 
+ * mapped the property named "location" to a PlaceObject, but one
+ * of the properties in your objects uses a string value for location, 
+ * you will receive parse errors because the deserializer will
+ * be unable to deserialize the property properly. The solution 
+ * is to use two separate IO instances each configured with the 
+ * appropriate property and object type mappings.
  */
 @DefaultImplementation("org.apache.abdera2.activities.io.gson.GsonIO")
 public abstract class IO {
@@ -47,6 +60,10 @@ public abstract class IO {
     this.autoclose = true;
   }
   
+  /**
+   * True if streams and writers should be automatically closed when
+   * the IO instance is done with them. Applies to both reads and writes
+   */
   public boolean getAutoClose() {
     return autoclose;
   }
@@ -65,6 +82,9 @@ public abstract class IO {
    */
   public abstract void addObjectMapping(Class<? extends ASObject>... _class);
   
+  /**
+   * Set the default character set used when parsing InputStreams
+   */
   public void setDefaultCharset(String charset) {
     this.defcharset = charset!=null?charset:"UTF-8";
   }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
Tue Sep 20 18:12:00 2011
@@ -19,6 +19,9 @@ package org.apache.abdera2.activities.mo
 
 import org.apache.abdera2.common.iri.IRI;
 
+/**
+ * Represents the Activity Streams Media Link construct.
+ */
 public class MediaLink extends ASBase {
 
   private static final long serialVersionUID = -2003166656259290419L;

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Verb.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Verb.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Verb.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Verb.java
Tue Sep 20 18:12:00 2011
@@ -20,6 +20,10 @@ package org.apache.abdera2.activities.mo
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+/**
+ * Activity Verbs... contains the core set of verbs and allows the creation
+ * of new verbs on the fly.
+ */
 public abstract class Verb {
 
  private static final Map<String,Verb> VERBS = 
@@ -31,6 +35,8 @@ public abstract class Verb {
        new Verb(name) {};
  }
  
+ // Core Verbs //
+ 
  public static final Verb ADD = new Verb("add") {};
  public static final Verb CANCEL = new Verb("cancel") {};
  public static final Verb CHECKIN = new Verb("checkin") {};
@@ -62,22 +68,11 @@ public abstract class Verb {
  public static final Verb UNSAVE = new Verb("unsave") {};
  public static final Verb UPDATE = new Verb("update") {};
  
- // As in "Sally purchased the app"
- public static final Verb PURCHASED = new Verb("purchase") {};
- 
- // As in: "Joe is hosting a meeting"
- public static final Verb HOST = new Verb("host") {};
- 
- // As in: "Mark read the book" ... this is related to "play", but saying that
- // someone "played" a book just doesn't make much sense. A user can 
- // "play" and audio book, but they must "read" the physical or ebook,
- // also works for "Mark read the note", "Sally read the question", etc
- public static final Verb READ = new Verb("read") {};
- 
+
  
- private final String name;
+  private final String name;
   
-  public Verb(String name) {
+  protected Verb(String name) {
     this.name = name;
     VERBS.put(name,this);
   }

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java?rev=1173284&r1=1173283&r2=1173284&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
(original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
Tue Sep 20 18:12:00 2011
@@ -51,7 +51,7 @@ public class ReadingListExample {
     book2.setAuthor(new PersonObject("Rene Descartes"));
     stream.addItem(
       gen.startNew()
-         .set("verb", Verb.READ)
+         .set("verb", Extra.READ)
          .set("object", book2)
          .set("format", Extra.HARDCOVER())
          .complete());

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java?rev=1173284&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
(added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
Tue Sep 20 18:12:00 2011
@@ -0,0 +1,178 @@
+package org.apache.abdera2.examples.activities;
+
+import org.apache.abdera2.activities.extra.Extra;
+import org.apache.abdera2.activities.extra.VersionObject;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.model.Generator;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.activities.model.objects.FileObject;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+
+public class VersionControlExample {
+
+  public static void main(String... args) throws Exception {
+    
+    Collection<Activity> stream = 
+      new Collection<Activity>();
+    
+    Activity template = 
+      new Activity();
+    PersonObject actor = 
+      new PersonObject();
+    actor.setDisplayName("James");
+    template.setActor(actor);
+    
+    Generator<Activity> gen = 
+      template.newGenerator();
+    
+    
+    // first, indicate that we created a document
+    
+    FileObject file = new FileObject();
+    file.setDisplayName("presentation.ppt");
+    file.setId("http://example.org/presentation.ppt");
+    
+    stream.addItem(
+      gen.startNew()
+         .set("object", file)
+         .set("verb", Verb.POST)
+         .complete());
+    
+    // second, indicate that a new version was created
+    VersionObject version = new VersionObject();
+    version.setOf(file);
+    version.setMajor("2");
+    
+    stream.addItem(
+      gen.startNew() 
+         .set("object", version)
+         .set("verb", Verb.POST)
+         .complete());
+    
+    // whoops, the boss rejected the new version
+    stream.addItem(
+      gen.startNew()
+         .set("object", version)
+         .set("verb", Extra.REJECT)
+         .set("actor", new PersonObject("The Boss"))
+         .set("summary", "This version is missing something")
+         .complete());
+    
+    // create a new version to deal with the bosses concerns
+    VersionObject old = version;
+    version = new VersionObject();
+    version.setOf(file);
+    version.setMajor("3");
+    version.setPreviousVersion(old);
+    
+    stream.addItem(
+        gen.startNew() 
+           .set("object", version)
+           .set("verb", Verb.POST)
+           .complete());
+    
+    // the boss approves the new version
+    stream.addItem(
+      gen.startNew()
+         .set("object", version)
+         .set("verb", Extra.APPROVE)
+         .set("actor", new PersonObject("The Boss"))
+         .complete());
+    
+    
+    stream.writeTo(System.out);
+  }
+  
+}
+
+
+/** Produces:
+{
+  "items":[
+    {
+      "verb":"post",
+      "object": {
+
+        "id":"http://example.org/presentation.ppt",
+        "displayName":"presentation.ppt",
+        "objectType":"file"},
+      "actor":{
+
+        "displayName":"James",
+        "objectType":"person" },
+      "objectType":"activity"
+    },
+    {
+      "verb":"post",
+      "object":{
+        "of":{
+          "id":"http://example.org/presentation.ppt",
+          "displayName":"presentation.ppt",
+          "objectType":"file"},
+        "objectType":"version",
+        "major":"2"},
+      "actor":{
+        "displayName":"James",
+        "objectType":"person"},
+      "objectType":"activity"},
+    {
+      "summary":"This version is missing something",
+      "verb":"reject",
+      "object":{
+        "of":{
+          "id":"http://example.org/presentation.ppt",
+          "displayName":"presentation.ppt",
+          "objectType":"file"},
+        "objectType":"version",
+        "major":"2"},
+      "actor":{
+        "displayName":"The Boss",
+        "objectType":"person"},
+      "objectType":"activity"},
+    {
+      "verb":"post",
+      "object":{
+        "of":{
+          "id":"http://example.org/presentation.ppt",
+          "displayName":"presentation.ppt",
+          "objectType":"file"},
+        "previousVersion":{
+          "of":{
+            "id":"http://example.org/presentation.ppt",
+            "displayName":"presentation.ppt",
+            "objectType":"file"},
+          "objectType":"version",
+          "major":"2"},
+        "objectType":"version",
+        "major":"3"},
+      "actor":{
+        "displayName":"James",
+        "objectType":"person"},
+      "objectType":"activity"},
+    {
+      "verb":"approve",
+      "object":{
+        "of":{
+          "id":"http://example.org/presentation.ppt",
+          "displayName":"presentation.ppt",
+          "objectType":"file"},
+        "previousVersion":{
+          "of":{
+            "id":"http://example.org/presentation.ppt", 
+            "displayName":"presentation.ppt",
+            "objectType":"file"},
+          "objectType":"version",
+          "major":"2"},
+        "objectType":"version",
+        "major":"3"},
+      "actor":{
+        "displayName":"The Boss",
+        "objectType":"person"},
+      "objectType":"activity"}
+  ],
+  "totalItems":5,
+  "objectType":"collection"
+}
+
+*/
\ No newline at end of file

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message