abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1196760 - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/extra/ activities/src/main/java/org/apache/abdera2/activities/io/gson/ activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/j...
Date Wed, 02 Nov 2011 18:52:17 GMT
Author: jmsnell
Date: Wed Nov  2 18:52:16 2011
New Revision: 1196760

URL: http://svn.apache.org/viewvc?rev=1196760&view=rev
Log:
some additional refactoring

Added:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ExtendedEventObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java   (with props)
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java   (contents, props changed)
      - copied, changed from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
Removed:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java
Modified:
    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/BaseAdapter.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/Verb.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java

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=1196760&r1=1196759&r2=1196760&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 Wed Nov  2 18:52:16 2011
@@ -29,9 +29,8 @@ public final class ASContext 
   @SuppressWarnings({ "unchecked", "rawtypes" })
   public <T> T resolve(String var) {
     Object obj = base.getProperty(var);
-    if (obj instanceof Iterable) {
+    if (obj instanceof Iterable)
       return (T)new IterableWrapper((Iterable)obj);
-    }
     return obj instanceof ASBase ? 
       (T)new ASContext((ASBase)obj) :
       (T)base.getProperty(var);

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=1196760&r1=1196759&r2=1196760&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 Wed Nov  2 18:52:16 2011
@@ -7,15 +7,14 @@ import net.sf.cglib.proxy.Enhancer;
 import net.sf.cglib.proxy.MethodInterceptor;
 import net.sf.cglib.proxy.MethodProxy;
 
+import org.apache.abdera2.activities.model.ASBase;
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.Activity;
 import org.apache.abdera2.activities.model.Activity.Audience;
-import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.activities.model.Verb;
 import org.apache.abdera2.common.anno.AnnoUtil;
 import org.apache.abdera2.common.anno.Name;
 import org.apache.abdera2.common.date.DateTimes;
-import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.selector.AbstractSelector;
 import org.apache.abdera2.common.selector.PropertySelector;
 import org.apache.abdera2.common.selector.Selector;
@@ -28,14 +27,22 @@ import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
 
+
+import static org.apache.abdera2.activities.model.objects.Objects.*;
+import static org.apache.abdera2.common.misc.Comparisons.*;
 import static com.google.common.base.Preconditions.*;
 
+
 /**
  * Miscellaneous extensions
  */
 @SuppressWarnings("unchecked")
 public class Extra {
 
+  /**
+   * Returns a Selector that tests whether the provided 
+   * activity uses the given Verb.
+   */
   public static Selector<Activity> usesVerb(Verb verb) {
     return PropertySelector.<Activity>create(
       Activity.class, 
@@ -43,21 +50,39 @@ public class Extra {
       Predicates.equalTo(verb));
   }
   
-  public static <A extends ASObject>Selector<A> published(Class<A> _class, Predicate<?> predicate) {
+  /**
+   * Returns a selector that tests the given Objects "published" property.
+   * This can typically be used with the various Range predicates provided
+   * by the (@see org.apache.abdera2.common.date.DateTimes) class
+   */
+  public static <A extends ASObject>Selector<A> published(
+    Class<A> _class, 
+    Predicate<?> predicate) {
     return PropertySelector.<A>create(
       _class,
       "getPublished",
       predicate);
   }
   
+  /**
+   * Returns a selector that tests the given Activities "published" property.
+   */
   public static Selector<Activity> activityPublished(Predicate<DateTime> predicate) {
     return published(Activity.class,predicate);
   }
   
+  /**
+   * Returns a selector that tests the given Objects "published" property
+   */
   public static Selector<ASObject> objectPublished(Predicate<DateTime> predicate) {
     return published(ASObject.class,predicate);
   }
   
+  /**
+   * Returns a Selector that tests the given Objects "updated" property.
+   * This can typically be used with the various Range predicates provided
+   * by the (@see org.apache.abder2.common.date.DateTimes) class
+   */
   public static <A extends ASObject>Selector<A> updated(Class<A> _class, Predicate<DateTime> predicate) {
     return PropertySelector.<A>create(
       _class,
@@ -65,71 +90,20 @@ public class Extra {
       predicate);
   }
   
+  /**
+   * Returns a Selector that tests the given Activities "updated" property.
+   */
   public static Selector<Activity> activityUpdated(Predicate<DateTime> predicate) {
     return updated(Activity.class,predicate);
   }
   
-  public static Selector<ASObject> objectUpdated(Predicate<DateTime> predicate) {
-    return updated(ASObject.class,predicate);
-  }
-  
-  // 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.
+   * Returns a Selector that tests the given Objects "updated" property
    */
-  public static void initExtras(IO io) {
-
-    io.addObjectMapping(
-      BookObject.class,
-      MovieObject.class,
-      OfferObject.class,
-      TvEpisodeObject.class,
-      TvSeasonObject.class,
-      TvSeriesObject.class,
-      VersionObject.class,
-      BinaryObject.class);
+  public static Selector<ASObject> objectUpdated(Predicate<DateTime> predicate) {
+    return updated(ASObject.class,predicate);
   }
-   
+       
   public static Selector<Activity> isTo(ASObject obj) {
     return Extra.audienceHas(Audience.TO, sameIdentity(obj));
   }
@@ -577,123 +551,6 @@ public class Extra {
   }
   
   /**
-   * Special AS Object that represents the authenticated user
-   */
-  public static ASObject SELF() {
-    return new ASObject("@self");
-  }
-  
-  /**
-   * Special AS Object that represents the authenticated user.
-   * synonymous with @self
-   */
-  public static ASObject ME() {
-    return new ASObject("@me");
-  }
-  
-  /**
-   * Special AS Object that represents the authenticated users 
-   * collection of direct contacts
-   */
-  public static ASObject FRIENDS() {
-    return new ASObject("@friends");
-  }
-  
-  /**
-   * Special AS Object that represents a subset of the authenticated users
-   * collection of direct contacts
-   */
-  public static ASObject FRIENDS(String id) {
-    ASObject obj = FRIENDS();
-    obj.setId(id);
-    return obj;
-  }
-  
-  /**
-   * Special AS Object that represents the authenticated users collection
-   * of extended contacts (e.g. friends of friends)
-   */
-  public static ASObject NETWORK() {
-    return new ASObject("@network");
-  }
-  
-  /**
-   * Special AS Object that represents everyone. synonymous with @public
-   */
-  public static ASObject ALL() {
-    return new ASObject("@all");
-  }
-  
-  /**
-   * Special AS Object that represents everyone
-   */
-  public static ASObject PUBLIC() {
-    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);
-    obj.setId(id);
-    return obj;
-  }
-  
-  public static ASObject DISCONTINUED() {
-    return anonymousObject("discontinued");
-  }
-  
-  public static ASObject INSTOCK() {
-    return anonymousObject("in-stock");
-  }
-  
-  public static ASObject INSTOREONLY() {
-    return anonymousObject("in-store-only");
-  }
-  
-  public static ASObject ONLINEONLY() {
-    return anonymousObject("online-only");
-  }
-  
-  public static ASObject OUTOFSTOCK() {
-    return anonymousObject("out-of-stock");
-  }
-  
-  public static ASObject PREORDER() {
-    return anonymousObject("pre-order");
-  }
-  
-  public static ASObject EBOOK() {
-    return anonymousObject("ebook");
-  }
-  
-  public static ASObject HARDCOVER() {
-    return anonymousObject("hardcover");
-  }
-  
-  public static ASObject PAPERBACK() {
-    return anonymousObject("paperback");
-  }
-  
-  public static ASObject DAMAGED() {
-    return anonymousObject("damaged");
-  }
-  
-  public static ASObject NEW() {
-    return anonymousObject("new");
-  }
-  
-  public static ASObject REFURBISHED() {
-    return anonymousObject("refurbished");
-  }
-  
-  public static ASObject USED() {
-    return anonymousObject("used");
-  }
-  
-  /**
    * Returns a Selector that tests if two objects are identity equivalent.
    * ASObjets are identity equivalent if they have the same objectType
    * and id property values.
@@ -722,20 +579,18 @@ public class Extra {
   private static Equivalence<ASObject> identity() {
     return new Equivalence<ASObject>() {
       protected boolean doEquivalent(ASObject a, ASObject b) {
-        if (a != null && b == null) return false;
-        if (a == null && b != null) return false;
+        if (bothAreNull(a,b)) return true;
+        if (onlyOneIsNull(a,b)) return false;
         String aot = a.getObjectType();
         String bot = b.getObjectType();
-        if (aot != null && bot == null) return false;
-        if (aot == null && bot != null) return false; 
-        if (aot != null)
-          if (!aot.equalsIgnoreCase(bot)) return false;
+        if (bothAreNull(aot,bot)) return true;
+        if (onlyOneIsNull(aot,bot)) return false;
+        if (!aot.equalsIgnoreCase(bot)) return false;
         String aid = a.getId();
         String bid = b.getId();
-        if (aid != null && bid == null) return false;
-        if (aid == null && bid != null) return false;
-        if (aid != null)
-          if (!aid.equals(bid)) return false;
+        if (bothAreNull(aid,bid)) return true;
+        if (onlyOneIsNull(aid,bid)) return false;
+        if (!aid.equals(bid)) return false;
         return true;
       }
       protected int doHash(ASObject t) {
@@ -768,50 +623,18 @@ public class Extra {
   private static class PublishedComparator 
     extends DateTimes.DateTimeComparator<ASObject> {
       public int compare(ASObject a1, ASObject a2) {
-        DateTime d1 = a1.getPublished();
-        DateTime d2 = a2.getPublished();
-        return innerCompare(d1,d2);
+        return innerCompare(
+          a1.getPublished(), 
+          a2.getPublished());
       }
   }
   
   
-  private static String get_name(Method obj) {   
-    String name = null;
-    if (obj.isAnnotationPresent(Name.class))
-      name = obj.getAnnotation(Name.class).value();
-    else {
-      name = obj.getName();
-      if (name.startsWith("get") || 
-        name.startsWith("set"))
-      name = name.substring(3);
-      name = CaseFormat.UPPER_CAMEL.to(
-          CaseFormat.LOWER_CAMEL, name);
-    }
-    return name;
-  }
- 
-  /**
-   * Uses cglib to create an extension of the base ASObject type
-   * that implements the given interface. All setter/getter methods
-   * on the supplied interface will be mapped to properties on the
-   * underlying ASObject.. for instance, getFoo() and setFoo(..) will
-   * be mapped to a "foo" property
-   */
-  public static <T>T extend(
-    Class<T> type, 
-    Class<? extends ASObject> base) {
-    checkNotNull(type);
-    Enhancer e = new Enhancer();
-    if (type.isInterface()) {
-      e.setSuperclass(base);
-      e.setInterfaces(MoreFunctions.array(type));
-    } else if (ASObject.class.isAssignableFrom(type)) {
-      e.setSuperclass(type);
-    }
-    e.setCallback(new ExtensionObjectProxy(type,base));
-    ASObject obj = (ASObject) e.create();
-    obj.setObjectType(AnnoUtil.getName(type));
-    return type.cast(obj);
+  private static Class<?>[] addin(Class<?>[] types, Class<?> type) {
+    Class<?>[] ntypes = new Class<?>[types.length+1];
+    System.arraycopy(types, 0, ntypes, 0, types.length);
+    ntypes[ntypes.length-1] = type;
+    return ntypes;
   }
   
   /**
@@ -821,30 +644,31 @@ public class Extra {
    * underlying ASObject.. for instance, getFoo() and setFoo(..) will
    * be mapped to a "foo" property
    */
-  public static <T>T extend(Class<T> type) {
+  public static <X extends ASBase,M>M extend(
+    X object,
+    Class<?> type) {
     checkNotNull(type);
+    checkNotNull(object);
     Enhancer e = new Enhancer();
     if (type.isInterface()) {
-      e.setSuperclass(ASObject.class);
-      e.setInterfaces(MoreFunctions.array(type));
+      e.setSuperclass(type);
+      e.setInterfaces(addin(object.getClass().getInterfaces(),type));
     } else if (ASObject.class.isAssignableFrom(type)) {
       e.setSuperclass(type);
     }
-    e.setCallback(new ExtensionObjectProxy(type));
-    ASObject obj = (ASObject) e.create();
-    obj.setObjectType(type.getSimpleName().toLowerCase());
-    return type.cast(obj);
+    e.setCallback(new ExtensionWrapper(type,object));
+    object.setProperty("objectType",AnnoUtil.getName(type));
+    return (M)e.create();
   }
   
-  private static class ExtensionObjectProxy 
+  
+  private static class ExtensionWrapper 
     implements MethodInterceptor {
     private final Class<?> type;
-    private final Class<?> base;
-    ExtensionObjectProxy(Class<?> type) {
-      this.type = type;
-      this.base = type;
-    }
-    ExtensionObjectProxy(Class<?> type, Class<?> base) {
+    private final ASBase base;
+    ExtensionWrapper(
+      Class<?> type, 
+      ASBase base) {
       this.type = type;
       this.base = base;
     }
@@ -854,9 +678,7 @@ public class Extra {
       Object[] args,
       MethodProxy proxy) 
         throws Throwable {
-      ASObject as = (ASObject) obj;
-      if (method.getDeclaringClass().equals(type) ||
-          method.getDeclaringClass().equals(base)) {
+      if (method.getDeclaringClass().equals(type)) {
         boolean setter = 
           method.getName().matches("[Ss]et.+") || 
           (void.class.isAssignableFrom(method.getReturnType()) && 
@@ -865,12 +687,27 @@ public class Extra {
         if (setter) {
           if (args.length != 1)
             throw new IllegalArgumentException();
-          as.setProperty(name,args[0]);
+          base.setProperty(name,args[0]);
           return null;
         } else {
-          return method.getReturnType().cast(as.getProperty(name));
+          return method.getReturnType().cast(base.getProperty(name));
         }
-      } else return proxy.invokeSuper(obj, args);
+      } else return proxy.invokeSuper(base, args);
     }    
   }
+  
+  private static String get_name(Method obj) {   
+    String name = null;
+    if (obj.isAnnotationPresent(Name.class))
+      name = obj.getAnnotation(Name.class).value();
+    else {
+      name = obj.getName();
+      if (name.startsWith("get") || 
+        name.startsWith("set"))
+      name = name.substring(3);
+      name = CaseFormat.UPPER_CAMEL.to(
+          CaseFormat.LOWER_CAMEL, name);
+    }
+    return name;
+  }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java Wed Nov  2 18:52:16 2011
@@ -38,6 +38,8 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.objects.ArticleObject;
 import org.apache.abdera2.activities.model.objects.AudioObject;
 import org.apache.abdera2.activities.model.objects.BadgeObject;
+import org.apache.abdera2.activities.model.objects.BinaryObject;
+import org.apache.abdera2.activities.model.objects.BookObject;
 import org.apache.abdera2.activities.model.objects.BookmarkObject;
 import org.apache.abdera2.activities.model.objects.CommentObject;
 import org.apache.abdera2.activities.model.objects.EventObject;
@@ -45,8 +47,10 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.objects.GroupObject;
 import org.apache.abdera2.activities.model.objects.ImageObject;
 import org.apache.abdera2.activities.model.objects.Mood;
+import org.apache.abdera2.activities.model.objects.MovieObject;
 import org.apache.abdera2.activities.model.objects.NameObject;
 import org.apache.abdera2.activities.model.objects.NoteObject;
+import org.apache.abdera2.activities.model.objects.OfferObject;
 import org.apache.abdera2.activities.model.objects.OrganizationObject;
 import org.apache.abdera2.activities.model.objects.PersonObject;
 import org.apache.abdera2.activities.model.objects.PlaceObject;
@@ -54,6 +58,10 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.objects.QuestionObject;
 import org.apache.abdera2.activities.model.objects.ReviewObject;
 import org.apache.abdera2.activities.model.objects.ServiceObject;
+import org.apache.abdera2.activities.model.objects.TvEpisodeObject;
+import org.apache.abdera2.activities.model.objects.TvSeasonObject;
+import org.apache.abdera2.activities.model.objects.TvSeriesObject;
+import org.apache.abdera2.activities.model.objects.VersionObject;
 import org.apache.abdera2.activities.model.objects.VideoObject;
 import org.apache.abdera2.activities.protocol.ErrorObject;
 import org.joda.time.DateTime;
@@ -147,7 +155,16 @@ public class BaseAdapter 
       ErrorObject.class,
       NameObject.class,
       AccountObject.class,
-      OrganizationObject.class);
+      OrganizationObject.class,
+      BookObject.class,
+      MovieObject.class,
+      OfferObject.class,
+      TvEpisodeObject.class,
+      TvSeasonObject.class,
+      TvSeriesObject.class,
+      VersionObject.class,
+      BinaryObject.class
+    );
   }
   
   private static void processType(
@@ -205,19 +222,19 @@ public class BaseAdapter 
       throws JsonParseException {
     JsonObject obj = (JsonObject)el;
     ASBase base = null;
-    if (type == Collection.class) {
+    if (type == Collection.class)
       base = new Collection<ASObject>();
-    } else if (type == Activity.class) {
+    else if (type == Activity.class)
       base = new Activity();
-    } else if (type == MediaLink.class) {
+    else if (type == MediaLink.class)
       base = new MediaLink();
-    } else if (type == PlaceObject.class) {
+    else if (type == PlaceObject.class)
       base = new PlaceObject();
-    } else if (type == Mood.class) {
+    else if (type == Mood.class)
       base = new Mood();
-    } else if (type == Address.class) {
+    else if (type == Address.class)
       base = new Address();
-    } else {
+    else {
       JsonPrimitive ot = obj.getAsJsonPrimitive("objectType");
       if (ot != null) {
         String ots = ot.getAsString();
@@ -232,7 +249,7 @@ public class BaseAdapter 
       } else {
         if (obj.has("verb") && (obj.has("actor") || obj.has("object") || obj.has("target"))) {
           base = new Activity();
-        } else if (obj.has("items") && obj.has("totalItems")) {
+        } else if (obj.has("items")) {
           base = new Collection<ASObject>();
         } else {
           base = new ASObject(); // anonymous object

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=1196760&r1=1196759&r2=1196760&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 Wed Nov  2 18:52:16 2011
@@ -29,12 +29,14 @@ import java.util.Map;
 
 import javax.activation.MimeType;
 
+import org.apache.abdera2.activities.extra.Extra;
 import org.apache.abdera2.activities.model.Generator.Copyable;
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.lang.Lang;
 import org.apache.abdera2.common.mediatype.MimeTypeParseException;
 
+import static com.google.common.base.Preconditions.*;
 import com.google.common.base.Function;
 
 /**
@@ -108,11 +110,13 @@ public class ASBase 
     return true;
   }
 
+  /** 
+   * if we already implement the type, just return 
+   * a cast to that type... otherwise, create a 
+   * new instance and copy all the properties over 
+   **/
   public <T extends ASBase>T as(Class<T> type) {
     try {
-      // if we already implement the type, just return 
-      // casted as that type... otherwise, create a 
-      // new instance and copy all the properties over
       if (type.isAssignableFrom(this.getClass()))
         return type.cast(this);
       ASBase t = type.newInstance();
@@ -128,6 +132,20 @@ public class ASBase 
       throw new RuntimeException(t);
     }
   }
+  
+  /**
+   * Returns this object wrapped with the specified interface.
+   * The argument MUST be an interface. This is used as a means
+   * of extending the object in a type-safe manner. Instead of 
+   * calling setProperty("foo","bar"), you can define an 
+   * extension interface with the methods setFoo(String m) and 
+   * getFoo().. so that obj.extend(MyExt.class).setFoo("bar") 
+   * will set the "foo" property.
+   */
+  public <T>T extend(Class<T> as) {
+    checkArgument(as.isInterface(),"Extension is not an interface!");
+    return Extra.extend(this,as);
+  }
  
   public String toString() {
     return IO.get().write(this);

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=1196760&r1=1196759&r2=1196760&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 Wed Nov  2 18:52:16 2011
@@ -68,6 +68,18 @@ public abstract class Verb {
  public static final Verb UNSAVE = new Verb("unsave") {};
  public static final Verb UPDATE = new Verb("update") {};
  
+ 
+ public static final Verb PURCHASE = new Verb("purchase") {};  
+ public static final Verb CONSUME = new Verb("consume") {};
+ public static final Verb HOST = new Verb("host") {};
+ public static final Verb READ = new Verb("read") {};
+ public static final Verb APPROVE = new Verb("approve") {};
+ public static final Verb REJECT = new Verb("reject") {};
+ public static final Verb ARCHIVE = new Verb("archive") {};
+ public static final Verb INSTALL = new Verb("install") {};
+ public static final Verb CLOSE = new Verb("close") {};
+ public static final Verb OPEN = new Verb("open") {};
+ public static final Verb RESOLVE = new Verb("resolve") {};
 
  
   private final String name;

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BinaryObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java Wed Nov  2 18:52:16 2011
@@ -1,4 +1,4 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -11,7 +11,6 @@ import javax.activation.MimeType;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;
-import org.apache.abdera2.activities.model.objects.FileObject;
 import org.apache.abdera2.common.anno.Name;
 import org.apache.abdera2.common.io.Compression;
 import org.apache.abdera2.common.io.Compression.CompressionCodec;

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java Wed Nov  2 18:52:16 2011
@@ -1,4 +1,4 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
@@ -35,12 +35,20 @@ public class BookObject extends Creative
     setProperty("edition", edition);
   }
   
-  public String getIsbn() {
-    return getProperty("isbn");
+  public String getIsbn10() {
+    return getProperty("isbn10");
   }
   
-  public void setIsbn(String isbn) {
-    setProperty("isbn", isbn);
+  public void setIsbn10(String isbn) {
+    setProperty("isbn10", isbn);
+  }
+  
+  public String getIsbn13() {
+    return getProperty("isbn13");
+  }
+  
+  public void setIsbn13(String isbn) {
+    setProperty("isbn13", isbn);
   }
   
   public int getPageCount() {
@@ -84,8 +92,8 @@ public class BookObject extends Creative
       item.setIllustrator(obj);
       return (X)this;
     }
-    public <X extends BookObjectGenerator<T>>X isbn(String val) {
-      item.setIsbn(val);
+    public <X extends BookObjectGenerator<T>>X isbn10(String val) {
+      item.setIsbn10(val);
       return (X)this;
     }
     public <X extends BookObjectGenerator<T>>X pageCount(int count) {

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java Wed Nov  2 18:52:16 2011
@@ -1,4 +1,4 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.model.ASObject;
 

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ExtendedEventObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ExtendedEventObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ExtendedEventObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ExtendedEventObject.java Wed Nov  2 18:52:16 2011
@@ -1,7 +1,6 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.model.ASObject;
-import org.apache.abdera2.activities.model.objects.EventObject;
 
 /**
  * Abstract extension of the basic event object type that adds

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ExtendedEventObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java Wed Nov  2 18:52:16 2011
@@ -1,4 +1,4 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java?rev=1196760&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java Wed Nov  2 18:52:16 2011
@@ -0,0 +1,125 @@
+package org.apache.abdera2.activities.model.objects;
+
+import org.apache.abdera2.activities.model.ASObject;
+
+public class Objects {
+
+  /**
+   * Special AS Object that represents the authenticated user
+   */
+  public static ASObject SELF() {
+    return new ASObject("@self");
+  }
+  
+  /**
+   * Special AS Object that represents the authenticated user.
+   * synonymous with @self
+   */
+  public static ASObject ME() {
+    return new ASObject("@me");
+  }
+  
+  /**
+   * Special AS Object that represents the authenticated users 
+   * collection of direct contacts
+   */
+  public static ASObject FRIENDS() {
+    return new ASObject("@friends");
+  }
+  
+  /**
+   * Special AS Object that represents a subset of the authenticated users
+   * collection of direct contacts
+   */
+  public static ASObject FRIENDS(String id) {
+    ASObject obj = FRIENDS();
+    obj.setId(id);
+    return obj;
+  }
+  
+  /**
+   * Special AS Object that represents the authenticated users collection
+   * of extended contacts (e.g. friends of friends)
+   */
+  public static ASObject NETWORK() {
+    return new ASObject("@network");
+  }
+  
+  /**
+   * Special AS Object that represents everyone. synonymous with @public
+   */
+  public static ASObject ALL() {
+    return new ASObject("@all");
+  }
+  
+  /**
+   * Special AS Object that represents everyone
+   */
+  public static ASObject PUBLIC() {
+    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);
+    obj.setId(id);
+    return obj;
+  }
+  
+  public static ASObject DISCONTINUED() {
+    return anonymousObject("discontinued");
+  }
+  
+  public static ASObject INSTOCK() {
+    return anonymousObject("in-stock");
+  }
+  
+  public static ASObject INSTOREONLY() {
+    return anonymousObject("in-store-only");
+  }
+  
+  public static ASObject ONLINEONLY() {
+    return anonymousObject("online-only");
+  }
+  
+  public static ASObject OUTOFSTOCK() {
+    return anonymousObject("out-of-stock");
+  }
+  
+  public static ASObject PREORDER() {
+    return anonymousObject("pre-order");
+  }
+  
+  public static ASObject EBOOK() {
+    return anonymousObject("ebook");
+  }
+  
+  public static ASObject HARDCOVER() {
+    return anonymousObject("hardcover");
+  }
+  
+  public static ASObject PAPERBACK() {
+    return anonymousObject("paperback");
+  }
+  
+  public static ASObject DAMAGED() {
+    return anonymousObject("damaged");
+  }
+  
+  public static ASObject NEW() {
+    return anonymousObject("new");
+  }
+  
+  public static ASObject REFURBISHED() {
+    return anonymousObject("refurbished");
+  }
+  
+  public static ASObject USED() {
+    return anonymousObject("used");
+  }
+
+  
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java Wed Nov  2 18:52:16 2011
@@ -1,4 +1,4 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java Wed Nov  2 18:52:16 2011
@@ -1,9 +1,10 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 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.activities.model.MediaLink;
+import org.apache.abdera2.activities.model.objects.CreativeWork.CreativeWorkGenerator;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java Wed Nov  2 18:52:16 2011
@@ -1,9 +1,10 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 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.activities.model.MediaLink;
+import org.apache.abdera2.activities.model.objects.CreativeWork.CreativeWorkGenerator;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java (from r1187146, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java Wed Nov  2 18:52:16 2011
@@ -1,9 +1,10 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 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.activities.model.MediaLink;
+import org.apache.abdera2.activities.model.objects.CreativeWork.CreativeWorkGenerator;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java (from r1187146, 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/model/objects/VersionObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java&r1=1187146&r2=1196760&rev=1196760&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/VersionObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java Wed Nov  2 18:52:16 2011
@@ -1,4 +1,4 @@
-package org.apache.abdera2.activities.extra;
+package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;

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

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/ApiKey.java Wed Nov  2 18:52:16 2011
@@ -206,7 +206,32 @@ public class ApiKey extends KeyBase {
     public String get() {
       return !hex ? key.generateNext() : key.generateNextHex();
     }
-    
+    @Override
+    public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + (hex ? 1231 : 1237);
+      result = prime * result + ((key == null) ? 0 : key.hashCode());
+      return result;
+    }
+    @Override
+    public boolean equals(Object obj) {
+      if (this == obj)
+        return true;
+      if (obj == null)
+        return false;
+      if (getClass() != obj.getClass())
+        return false;
+      ApiKeySupplier other = (ApiKeySupplier) obj;
+      if (hex != other.hex)
+        return false;
+      if (key == null) {
+        if (other.key != null)
+          return false;
+      } else if (!key.equals(other.key))
+        return false;
+      return true;
+    }
   }
 
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/KeyBase.java Wed Nov  2 18:52:16 2011
@@ -97,4 +97,39 @@ public abstract class KeyBase 
       s = c + s;
     return s;
   }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((alg == null) ? 0 : alg.hashCode());
+    result = prime * result + ((key == null) ? 0 : key.hashCode());
+    result = prime * result + size;
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    KeyBase other = (KeyBase) obj;
+    if (alg == null) {
+      if (other.alg != null)
+        return false;
+    } else if (!alg.equals(other.alg))
+      return false;
+    if (key == null) {
+      if (other.key != null)
+        return false;
+    } else if (!key.equals(other.key))
+      return false;
+    if (size != other.size)
+      return false;
+    return true;
+  }
+  
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/security/Otp.java Wed Nov  2 18:52:16 2011
@@ -184,5 +184,28 @@ public abstract class Otp extends KeyBas
       String r = Long.toHexString(t);
       return dec(pad(r,16,'0'));
     }
+
+    @Override
+    public int hashCode() {
+      final int prime = 31;
+      int result = super.hashCode();
+      result = prime * result + step;
+      return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (this == obj)
+        return true;
+      if (!super.equals(obj))
+        return false;
+      if (getClass() != obj.getClass())
+        return false;
+      Totp other = (Totp) obj;
+      if (step != other.step)
+        return false;
+      return true;
+    }
+    
   }
 }

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java Wed Nov  2 18:52:16 2011
@@ -6,7 +6,7 @@ import java.io.ByteArrayOutputStream;
 import org.apache.abdera2.activities.model.Activity;
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.IO;
-import org.apache.abdera2.activities.model.Verb;
+import static org.apache.abdera2.activities.model.Verb.FOLLOW;
 import static org.apache.abdera2.activities.model.Activity.makeActivity;
 import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
 
@@ -22,7 +22,7 @@ public class Activities {
           makePerson()
             .displayName("James")
             .get())
-        .verb(Verb.FOLLOW)
+        .verb(FOLLOW)
         .object(
           makePerson()
             .email("john.doe@example.org")

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java Wed Nov  2 18:52:16 2011
@@ -6,16 +6,14 @@ import java.net.URL;
 
 import javax.activation.DataHandler;
 
-import org.apache.abdera2.activities.extra.BinaryObject;
-import org.apache.abdera2.activities.extra.Extra;
 import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.activities.model.objects.BadgeObject;
-import org.apache.abdera2.common.io.Compression.CompressionCodec;
-import org.apache.abdera2.common.security.HashHelper;
+import org.apache.abdera2.activities.model.objects.BinaryObject;
 
-
-import static org.apache.abdera2.activities.extra.BinaryObject.makeBinary;
+import static org.apache.abdera2.common.io.Compression.CompressionCodec.DEFLATE;
+import static org.apache.abdera2.common.security.HashHelper.Md5;
 import static org.apache.abdera2.activities.model.objects.BadgeObject.makeBadge;
+import static org.apache.abdera2.activities.model.objects.BinaryObject.makeBinary;
 
 /**
  * Illustrates the extension "binary" objectType... this can be useful, 
@@ -27,7 +25,6 @@ public class BinaryDataObjectExample {
   public static void main(String... args) throws Exception {
     
     IO io = IO.get();
-    Extra.initExtras(io);
     
     URL url = BinaryDataObjectExample.class.getResource("/info.png");
     DataHandler dataHandler = new DataHandler(url); 
@@ -38,8 +35,8 @@ public class BinaryDataObjectExample {
           makeBinary()
             .data(
               dataHandler, 
-              new HashHelper.Md5(), 
-              CompressionCodec.DEFLATE)
+              new Md5(), 
+              DEFLATE)
             .get())
         .get();
     
@@ -51,7 +48,7 @@ public class BinaryDataObjectExample {
     BinaryObject dataObject = (BinaryObject) badge.getAttachments().iterator().next();
     
     String md5 = dataObject.getProperty("md5");
-    HashHelper.Md5 check = new HashHelper.Md5();
+    Md5 check = new Md5();
     
     // decompression will be applied automatically
     InputStream in = dataObject.getInputStream(); 

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java Wed Nov  2 18:52:16 2011
@@ -1,7 +1,7 @@
 package org.apache.abdera2.examples.activities;
 
-import org.apache.abdera2.activities.extra.ExtendedEventObject;
 import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.objects.ExtendedEventObject;
 import org.apache.abdera2.activities.model.objects.PersonObject;
 import org.apache.abdera2.common.anno.Name;
 
@@ -25,6 +25,14 @@ public class ExtendingBaseObjectExample 
     hangout.setHost(new PersonObject("james"));
     hangout.getAttending(true).addItem(new PersonObject("joe"));
 
+    // another way to extend the Activity Stream object 
+    // is by using the extend() method and passing in a 
+    // simple Interface...
+    OtherExtensions oe = hangout.extend(OtherExtensions.class);
+    oe.setFoo("this is the value");
+    
+    // this is a type-safe alternative to using hangout.setProperty("foo","this is the value");
+    
     io.write(hangout,System.out,"UTF-8");
   }
 
@@ -33,4 +41,9 @@ public class ExtendingBaseObjectExample 
     extends ExtendedEventObject {
     private static final long serialVersionUID = -5466869609152673390L;
   }
+  
+  public static interface OtherExtensions {
+    public String getFoo();
+    public void setFoo(String bar);
+  }
 }

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=1196760&r1=1196759&r2=1196760&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 Wed Nov  2 18:52:16 2011
@@ -1,15 +1,17 @@
 package org.apache.abdera2.examples.activities;
 
-import org.apache.abdera2.activities.extra.Extra;
 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.IO;
-import org.apache.abdera2.activities.model.Verb;
 
+import static org.apache.abdera2.activities.model.Verb.SAVE;
+import static org.apache.abdera2.activities.model.Verb.CONSUME;
+import static org.apache.abdera2.activities.model.objects.Objects.EBOOK;
+import static org.apache.abdera2.activities.model.objects.Objects.HARDCOVER;
 import static org.apache.abdera2.activities.model.Activity.makeActivity;
+import static org.apache.abdera2.activities.model.objects.BookObject.makeBook;
 import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
-import static org.apache.abdera2.activities.extra.BookObject.makeBook;
 import static org.apache.abdera2.activities.model.Collection.makeCollection;
 
 /**
@@ -25,7 +27,6 @@ public class ReadingListExample {
     
     // Building an activity stream for a reading list
     IO io = IO.get();
-    Extra.initExtras(io);
     
     Generator<Activity> gen = 
       makeActivity()
@@ -41,18 +42,18 @@ public class ReadingListExample {
     // Add a book we want to read
     builder.item(
       gen.startNew()
-         .set("verb", Verb.SAVE)
+         .set("verb", SAVE)
          .set("object", 
            makeBook()
              .displayName("The Cat in the Hat")
              .get())
-         .set("format", Extra.EBOOK())
+         .set("format", EBOOK())
          .complete());
     
     // Add a book we just finished
     builder.item(
       gen.startNew()
-         .set("verb", Extra.READ)
+         .set("verb", CONSUME)
          .set("object", 
            makeBook()
              .displayName("Meditations on the Method")
@@ -61,7 +62,7 @@ public class ReadingListExample {
                  .displayName("Rene Descartes")
                  .get())
              .get())
-         .set("format", Extra.HARDCOVER())
+         .set("format", HARDCOVER())
          .complete());
     
     builder.get().writeTo(io,System.out);

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java?rev=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java Wed Nov  2 18:52:16 2011
@@ -1,9 +1,10 @@
 package org.apache.abdera2.examples.activities;
 
-import org.apache.abdera2.activities.extra.Extra;
 import org.apache.abdera2.activities.model.Activity;
 import org.apache.abdera2.activities.model.objects.NoteObject;
 import org.apache.abdera2.activities.model.objects.PersonObject;
+import static org.apache.abdera2.activities.model.objects.Objects.FRIENDS;
+import static org.apache.abdera2.activities.model.objects.Objects.NETWORK;
 
 public class RepliesAndTargetingExample {
 
@@ -12,9 +13,9 @@ public class RepliesAndTargetingExample 
     Activity activity = 
       Activity.makeActivity()
         .to(new PersonObject("bob"))
-        .cc(Extra.FRIENDS("Colleagues"))
+        .cc(FRIENDS("Colleagues"))
         .bto(new PersonObject("sally"))
-        .bcc(Extra.NETWORK())
+        .bcc(NETWORK())
         .inReplyTo(
           NoteObject
             .makeNote()

Modified: 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=1196760&r1=1196759&r2=1196760&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java Wed Nov  2 18:52:16 2011
@@ -1,18 +1,19 @@
 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.VersionObject;
 
+import static org.apache.abdera2.activities.model.Verb.POST;
+import static org.apache.abdera2.activities.model.Verb.REJECT;
+import static org.apache.abdera2.activities.model.Verb.APPROVE;
 import static org.apache.abdera2.activities.model.Collection.makeCollection;
 import static org.apache.abdera2.activities.model.Activity.makeActivity;
 import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
+import static org.apache.abdera2.activities.model.objects.VersionObject.makeVersion;
 import static org.apache.abdera2.activities.model.objects.FileObject.makeFile;
-import static org.apache.abdera2.activities.extra.VersionObject.makeVersion;
 
 public class VersionControlExample {
 
@@ -40,7 +41,7 @@ public class VersionControlExample {
     builder.item(
       gen.startNew()
         .set("object", file)
-        .set("verb", Verb.POST)
+        .set("verb", POST)
         .complete());
     
     // second, indicate that a new version was created
@@ -53,14 +54,14 @@ public class VersionControlExample {
     builder.item(
       gen.startNew() 
          .set("object", version)
-         .set("verb", Verb.POST)
+         .set("verb", POST)
          .complete());
     
     // whoops, the boss rejected the new version
     builder.item(
       gen.startNew()
          .set("object", version)
-         .set("verb", Extra.REJECT)
+         .set("verb", REJECT)
          .set("actor", makePerson().displayName("The Boss").get())
          .set("summary", "This version is missing something")
          .complete());
@@ -76,14 +77,14 @@ public class VersionControlExample {
     builder.item(
         gen.startNew() 
            .set("object", version)
-           .set("verb", Verb.POST)
+           .set("verb", POST)
            .complete());
     
     // the boss approves the new version
     builder.item(
       gen.startNew()
          .set("object", version)
-         .set("verb", Extra.APPROVE)
+         .set("verb", APPROVE)
          .set("actor", makePerson().displayName("The Boss").get())
          .complete());
     



Mime
View raw message