abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [2/49] - in /abdera/abdera2: ./ .settings/ activities/ activities/src/ activities/src/main/ activities/src/main/java/ activities/src/main/java/org/ activities/src/main/java/org/apache/ activities/src/main/java/org/apache/abdera2/ a...
Date Tue, 20 Sep 2011 15:57:20 GMT

Added: abdera/abdera2/.classpath
URL: http://svn.apache.org/viewvc/abdera/abdera2/.classpath?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/.classpath (added)
+++ abdera/abdera2/.classpath Tue Sep 20 15:56:46 2011
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="common/src/main/resources"/>
+	<classpathentry kind="src" path="examples/src/main/resources"/>
+	<classpathentry kind="src" path="examples/src/main/java"/>
+	<classpathentry kind="src" path="test/src/test/java"/>
+	<classpathentry kind="src" path="test/src/main/java"/>
+	<classpathentry kind="src" path="test/src/main/resources"/>
+	<classpathentry kind="src" path="server/src/main/resources"/>
+	<classpathentry kind="src" path="server/src/main/java"/>
+	<classpathentry kind="src" path="security/src/main/resources"/>
+	<classpathentry kind="src" path="security/src/main/java"/>
+	<classpathentry kind="src" path="ext/src/main/resources"/>
+	<classpathentry kind="src" path="ext/src/main/java"/>
+	<classpathentry kind="src" path="core/src/main/resources"/>
+	<classpathentry kind="src" path="core/src/main/java"/>
+	<classpathentry kind="src" path="common/src/main/java"/>
+	<classpathentry kind="src" path="client/src/main/java"/>
+	<classpathentry kind="src" path="client/src/main/resources"/>
+	<classpathentry kind="src" path="activities/src/main/resources"/>
+	<classpathentry kind="src" path="activities/src/main/java"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/commons-codec-1.5/commons-codec-1.5.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/httpcomponents-client-4.1.2/lib/httpclient-4.1.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/httpcomponents-client-4.1.2/lib/httpclient-cache-4.1.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/httpcomponents-client-4.1.2/lib/httpcore-4.1.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/httpcomponents-client-4.1.2/lib/httpmime-4.1.2.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.utility"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0 (MacOS X Default)">
+		<attributes>
+			<attribute name="owner.project.facets" value="java"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Jetty"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/google-gson-1.7.1/gson-1.7.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/axiom-api-1.2.12.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/axiom-impl-1.2.12-tests.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/axiom-impl-1.2.12.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/bcprov-jdk16-1.46.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/cglib-2.2.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/commons-logging-1.1.1-tests.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/commons-logging-1.1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/easymock-3.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/geronimo-activation_1.0.2_spec-1.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/geronimo-activation-1.1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/geronimo-javamail_1.3.1_spec-1.3.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/htmlparser-1.2.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/icu4j-4_8_1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/jaxen-1.1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/jetty-6.0.0beta6.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/junit-4.9.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/log4j-1.2.16.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/serializer-2.7.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/stax2-api-3.1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/woodstox-core-asl-4.1.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/woodstox-core-asl-4.1.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/wstx-asl-3.2.0.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/xalan-2.7.1.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/xml-apis-2.0.2.jar"/>
+	<classpathentry exported="true" kind="lib" path="/Users/james/lib/abdera-dependencies/xmlsec-1.4.5.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Propchange: abdera/abdera2/.classpath
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/.project
URL: http://svn.apache.org/viewvc/abdera/abdera2/.project?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/.project (added)
+++ abdera/abdera2/.project Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>abdera2</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+	</natures>
+</projectDescription>

Propchange: abdera/abdera2/.project
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/.settings/org.eclipse.core.resources.prefs
URL: http://svn.apache.org/viewvc/abdera/abdera2/.settings/org.eclipse.core.resources.prefs?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/.settings/org.eclipse.core.resources.prefs (added)
+++ abdera/abdera2/.settings/org.eclipse.core.resources.prefs Tue Sep 20 15:56:46 2011
@@ -0,0 +1,3 @@
+#Wed Sep 14 10:25:43 PDT 2011
+eclipse.preferences.version=1
+encoding//common/src/main/java/org/apache/abdera2/common/geo/IsoPosition.java=UTF-8

Propchange: abdera/abdera2/.settings/org.eclipse.core.resources.prefs
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/abdera/abdera2/.settings/org.eclipse.jdt.core.prefs?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/.settings/org.eclipse.jdt.core.prefs (added)
+++ abdera/abdera2/.settings/org.eclipse.jdt.core.prefs Tue Sep 20 15:56:46 2011
@@ -0,0 +1,12 @@
+#Sat May 15 09:30:55 PDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5

Propchange: abdera/abdera2/.settings/org.eclipse.jdt.core.prefs
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/.settings/org.eclipse.wst.common.component
URL: http://svn.apache.org/viewvc/abdera/abdera2/.settings/org.eclipse.wst.common.component?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/.settings/org.eclipse.wst.common.component (added)
+++ abdera/abdera2/.settings/org.eclipse.wst.common.component Tue Sep 20 15:56:46 2011
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="abdera2">
+        <wb-resource deploy-path="/" source-path="/activities/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/activities/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/client/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/client/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/common/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/common/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/core/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/core/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/ext/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/ext/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/security/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/security/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/server/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/test/src/main/java"/>
+        <wb-resource deploy-path="/" source-path="/test/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/server/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/test/src/java"/>
+        <wb-resource deploy-path="/" source-path="/test/src/test/java"/>
+        <wb-resource deploy-path="/" source-path="/examples/src/main/resources"/>
+        <wb-resource deploy-path="/" source-path="/examples/src/main/java"/>
+    </wb-module>
+</project-modules>

Added: abdera/abdera2/.settings/org.eclipse.wst.common.project.facet.core.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/.settings/org.eclipse.wst.common.project.facet.core.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/.settings/org.eclipse.wst.common.project.facet.core.xml (added)
+++ abdera/abdera2/.settings/org.eclipse.wst.common.project.facet.core.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v7.0"/>
+  <fixed facet="java"/>
+  <fixed facet="jst.utility"/>
+  <installed facet="java" version="1.5"/>
+  <installed facet="jst.utility" version="1.0"/>
+</faceted-project>

Propchange: abdera/abdera2/.settings/org.eclipse.wst.common.project.facet.core.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/README
URL: http://svn.apache.org/viewvc/abdera/abdera2/README?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/README (added)
+++ abdera/abdera2/README Tue Sep 20 15:56:46 2011
@@ -0,0 +1,3 @@
+This is an as-yet incomplete update for Abdera. All of the base dependencies
+have been updated and a broad range of significant changes have been made to
+the overall code structure, many of the apis and implementation detail. 
\ No newline at end of file

Added: abdera/abdera2/activities/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/pom.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/pom.xml (added)
+++ abdera/abdera2/activities/pom.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,59 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.abdera2</groupId>
+    <artifactId>abdera2</artifactId>
+    <version>2.0-SNAPSHOT</version>  
+  </parent>  
+
+  <artifactId>abdera2-activities</artifactId>
+  <packaging>bundle</packaging>
+  <name>Abdera2 Activities</name>
+  <version>2.0-SNAPSHOT</version>  
+  <description>JSON Activity Streams Implementation</description>
+
+  <properties>
+    <topDir>${basedir}/..</topDir>
+    <!-- 
+    <abdera.osgi.default.exports>
+		  org.apache.abdera.activities.*
+	  </abdera.osgi.default.exports>
+    <abdera.osgi.default.imports>
+      org.apache.commons.codec*;version="[1.5,2)",
+      *
+    </abdera.osgi.default.imports>
+    -->
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.abdera2</groupId>
+      <artifactId>abdera2-common</artifactId>
+      <version>2.0-SNAPSHOT</version>  
+    </dependency>
+      <dependency>
+        <groupId>com.google.code.gson</groupId>
+        <artifactId>gson</artifactId>
+      </dependency>
+  </dependencies>
+</project>

Propchange: abdera/abdera2/activities/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesClient.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,58 @@
+package org.apache.abdera2.activities.client;
+
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.protocol.client.BasicClient;
+import org.apache.abdera2.protocol.client.Client;
+import org.apache.abdera2.protocol.client.ClientWrapper;
+import org.apache.abdera2.protocol.client.RequestOptions;
+import org.apache.abdera2.protocol.client.Session;
+
+public class ActivitiesClient 
+  extends ClientWrapper {
+
+  public ActivitiesClient() {
+    super(new BasicClient());
+  }
+  
+  public ActivitiesClient(Client client) {
+    super(client);
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public <T extends Session> T newSession() {
+    return (T)new ActivitiesSession(this);
+  }
+
+  public <T extends Collection<?>>T getCollection(String uri) {
+    ActivitiesSession session = newSession();
+    return session.getCollection(uri);
+  }
+  
+  public <T extends Collection<?>>T getCollection(String uri, RequestOptions options) {
+    ActivitiesSession session = newSession();
+    return session.getCollection(uri,options);
+  }
+  
+  public <T extends Activity>T getActivity(String uri) {
+    ActivitiesSession session = newSession();
+    return session.getActivity(uri);
+  }
+  
+  public <T extends Activity>T getActivity(String uri, RequestOptions options) {
+    ActivitiesSession session = newSession();
+    return session.getActivity(uri,options);
+  }
+  
+  public <T extends ASObject>T getObject(String uri) {
+    ActivitiesSession session = newSession();
+    return session.getObject(uri);
+  }
+  
+  public <T extends ASObject>T getObject(String uri, RequestOptions options) {
+    ActivitiesSession session = newSession();
+    return session.getObject(uri,options);
+  }
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivitiesSession.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,159 @@
+package org.apache.abdera2.activities.client;
+
+import java.util.Date;
+
+import javax.activation.MimeType;
+
+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.Collection;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.protocol.ProtocolException;
+import org.apache.abdera2.protocol.client.Client;
+import org.apache.abdera2.protocol.client.ClientResponse;
+import org.apache.abdera2.protocol.client.RequestOptions;
+import org.apache.abdera2.protocol.client.Session;
+
+public class ActivitiesSession 
+  extends Session {
+
+  private final IO io;
+  
+  protected ActivitiesSession(Client client) {
+    super(client);
+    this.io = IO.get();
+  }
+
+  public IO getIO() {
+    return io;
+  }
+  
+  protected ActivitiesClient getActivitiesClient() {
+    return (ActivitiesClient) client;
+  }
+
+  public <T extends Collection<?>>T getCollection(String uri) {
+    return getCollection(uri, this.getDefaultRequestOptions());
+  }
+  
+  public <T extends ClientResponse>T post(String uri, ASBase base) {
+    return post(uri,base, this.getDefaultRequestOptions());
+  }
+  
+  public <T extends ClientResponse>T post(String uri, ASBase base, RequestOptions options) {
+    ActivityEntity entity = new ActivityEntity(base);
+    return post(uri, entity, options);
+  }
+
+  public <T extends ClientResponse>T put(String uri, ASBase base) {
+    return put(uri,base, this.getDefaultRequestOptions());
+  }
+  
+  public <T extends ClientResponse>T put(String uri, ASBase base, RequestOptions options) {
+    ActivityEntity entity = new ActivityEntity(base);
+    return put(uri, entity, options);
+  }
+  
+  @SuppressWarnings("unchecked")
+  public <T extends Collection<?>>T getCollection(String uri, RequestOptions options) {
+    ClientResponse cr = get(uri, options);
+    try {
+      if (cr != null) {
+        switch(cr.getType()) {
+        case SUCCESSFUL:
+          try {
+            T t = (T)io.readCollection(cr.getReader());
+            setDocProperties(cr,t);
+            return t;
+          } catch (Throwable t) {
+            throw new ProtocolException(601, t.getMessage());
+          }
+        default:
+          throw new ProtocolException(cr.getStatus(), cr.getStatusText());
+        }
+      } else {
+        throw new ProtocolException(600, "Null Response");
+      }
+    } finally {
+      if (cr != null) cr.release();
+    }
+  }
+  
+  public <T extends Activity>T getActivity(String uri) {
+    return getActivity(uri,this.getDefaultRequestOptions());
+  }
+  
+  @SuppressWarnings("unchecked")
+  public <T extends Activity>T getActivity(String uri, RequestOptions options) {
+    ClientResponse cr = get(uri, options);
+    try {
+      if (cr != null) {
+        switch(cr.getType()) {
+        case SUCCESSFUL:
+          try {
+            T t = (T)io.readActivity(cr.getReader());
+            setDocProperties(cr,t);
+            return t;
+          } catch (Throwable t) {
+            throw new ProtocolException(601, t.getMessage());
+          }
+        default:
+          throw new ProtocolException(cr.getStatus(), cr.getStatusText());
+        }
+      } else {
+        throw new ProtocolException(600, "Null Response");
+      }
+    } finally {
+      if (cr != null) cr.release();
+    }
+  }
+  
+  public <T extends ASObject>T getObject(String uri) {
+    return getObject(uri, this.getDefaultRequestOptions());
+  }
+  
+  @SuppressWarnings("unchecked")
+  public <T extends ASObject>T getObject(String uri, RequestOptions options) {
+    ClientResponse cr = get(uri, options);
+    try {
+      if (cr != null) {
+        switch(cr.getType()) {
+        case SUCCESSFUL:
+          try {
+            T t = (T)io.readObject(cr.getReader());
+            setDocProperties(cr,t);
+            return t;
+          } catch (Throwable t) {
+            throw new ProtocolException(601, t.getMessage());
+          }
+        default:
+          throw new ProtocolException(cr.getStatus(), cr.getStatusText());
+        }
+      } else {
+        throw new ProtocolException(600, "Null Response");
+      }
+    } finally {
+      if (cr != null) cr.release();
+    }
+  }
+  
+  private void setDocProperties(ClientResponse resp, ASBase base) {
+    EntityTag etag = resp.getEntityTag();
+    if (etag != null)
+        base.setEntityTag(etag);
+    Date lm = resp.getLastModified();
+    if (lm != null)
+        base.setLastModified(lm);
+    MimeType mt = resp.getContentType();
+    if (mt != null)
+        base.setContentType(mt.toString());
+    String language = resp.getContentLanguage();
+    if (language != null)
+        base.setLanguage(language);
+    String slug = resp.getSlug();
+    if (slug != null)
+        base.setSlug(slug);
+  }
+}

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

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivityEntity.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivityEntity.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivityEntity.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/client/ActivityEntity.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.client;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.abdera2.activities.model.ASBase;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.BasicHttpEntity;
+import org.apache.http.message.BasicHeader;
+
+/**
+ * Required for the Apache Commons HTTP AbderaClient.
+ */
+public class ActivityEntity
+  extends BasicHttpEntity 
+  implements HttpEntity {
+
+    private final ASBase base;
+    private final Header ct;
+    private final long len;
+    private byte[] buf = null;
+
+    /**
+     * Create the entity using the specified Activity element. 
+     * The content length will not be calculated automatically so the 
+     * Content-Length header in the part will not be specified. The 
+     * Content-Type will be automatically detected based on the type of
+     * element passed in.
+     */
+    public ActivityEntity(ASBase base) {
+      this(base,false,null);
+    }
+    
+    /**
+     * Create the entity using the specified Activity document or element.
+     * The content length will not be calculated. The Content-Type 
+     * specified will be used. If contentType is null, the Content-Type 
+     * will be automatically detected based on the type of element passed in.
+     */
+    public ActivityEntity(ASBase base, String contentType) {
+      this(base,false,contentType);
+    }
+    
+    /**
+     * Create the entity using the specified Activity document or element.
+     * The content length will be automatically calculated if the 
+     * calclen argument is true. The Content-Type will be automatically
+     * detected based on the type of element passed in.
+     */
+    public ActivityEntity(ASBase base, boolean calclen) {
+      this(base,calclen,null);
+    }
+    
+    /**
+     * Create the entity using the specified Activity document or element.
+     * The content length will be automatically calculated if the 
+     * calclen argument is true. The Content-Type specified will be
+     * used. If contentType is null, the Content-Type will be automatically
+     * detected based on the type of element passed in.
+     */
+    public ActivityEntity(ASBase base, boolean calclen, String contentType) {
+        this.base = base;
+        this.ct = new BasicHeader(
+          "Content-Type", 
+          contentType!=null?contentType:"application/json");
+        if (calclen) {
+          ByteArrayOutputStream out = 
+            new ByteArrayOutputStream();
+          base.writeTo(out);
+          buf = out.toByteArray();
+          len = buf.length;
+        } else len = -1;
+    }
+
+    public boolean isRepeatable() {
+        return true;
+    }
+
+    public void writeTo(OutputStream out) throws IOException {
+      base.writeTo(out);
+    }
+    
+    public InputStream getContent() {
+      try {
+        if (buf == null) {
+          ByteArrayOutputStream out = 
+            new ByteArrayOutputStream();
+          base.writeTo(out);
+          buf = out.toByteArray();
+        }
+        return new ByteArrayInputStream(buf);
+      } catch (Throwable t) {
+        throw new RuntimeException(t);
+      }
+    }
+
+    public long getContentLength() {
+        return len;
+    }
+
+    public boolean isChunked() {
+      return len == -1;
+    }
+    
+    public Header getContentType() {
+        return ct;
+    }
+
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ASContext.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,37 @@
+package org.apache.abdera2.activities.extra;
+
+import java.util.Iterator;
+
+import org.apache.abdera2.activities.model.ASBase;
+import org.apache.abdera2.common.templates.AbstractContext;
+
+/**
+ * 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
+ */
+public final class ASContext 
+  extends AbstractContext {
+  private static final long serialVersionUID = 4445623432125049535L;
+  private final ASBase base;
+  
+  public ASContext(ASBase base) {
+    this.base = base;
+  }
+  
+  public <T> T resolve(String var) {
+    return base.getProperty(var);
+  }
+
+  public void clear() {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean contains(String var) {
+    return base.has(var);
+  }
+
+  public Iterator<String> iterator() {
+    return base.iterator();
+  }
+}
\ No newline at end of file

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

Added: 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/extra/BookObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/BookObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,57 @@
+package org.apache.abdera2.activities.extra;
+
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.common.anno.Name;
+
+@Name("book")
+public class BookObject extends CreativeWork {
+
+  private static final long serialVersionUID = -178336535850006357L;
+
+  public BookObject() {}
+  
+  public BookObject(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getFormat() {
+    return getProperty("format");
+  }
+  
+  public void setFormat(ASObject format) {
+    setProperty("format", format);
+  }
+  
+  public String getEdition() {
+    return getProperty("edition");
+  }
+  
+  public void setEdition(String edition) {
+    setProperty("edition", edition);
+  }
+  
+  public String getIsbn() {
+    return getProperty("isbn");
+  }
+  
+  public void setIsbn(String isbn) {
+    setProperty("isbn", isbn);
+  }
+  
+  public int getPageCount() {
+    return (Integer)getProperty("pageCount");
+  }
+  
+  public void setPageCount(int pageCount) {
+    setProperty("pageCount", pageCount);
+  }
+
+  public <T extends ASObject>T getIllustrator() {
+    return getProperty("illustrator");
+  }
+  
+  public void setIllustrator(ASObject illustrator) {
+    setProperty("illustrator", illustrator);
+  }
+  
+}

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

Added: 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/extra/CreativeWork.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/CreativeWork.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,63 @@
+package org.apache.abdera2.activities.extra;
+
+import org.apache.abdera2.activities.model.ASObject;
+
+public abstract class CreativeWork extends ASObject {
+
+  private static final long serialVersionUID = -178336535850006357L;
+
+  public CreativeWork() {}
+  
+  public CreativeWork(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getAbout() {
+    return getProperty("about");
+  }
+  
+  public void setAbout(ASObject about) {
+    setProperty("about", about);
+  }
+  
+  public <T extends ASObject>T getGenre() {
+    return getProperty("genre");
+  }
+  
+  public void setGenre(ASObject genre) {
+    setProperty("genre", genre);
+  }
+  
+  public <T extends ASObject>T getPublisher() {
+    return getProperty("publisher");
+  }
+  
+  public void setPublisher(ASObject publisher) {
+    setProperty("publisher", publisher);
+  }
+  
+  public <T extends ASObject>T getProvider() {
+    return getProperty("provider");
+  }
+  
+  public void setProvider(ASObject provider) {
+    setProperty("provider", provider);
+  }
+  
+  public <T extends ASObject>T getContributor() {
+    return getProperty("contributor");
+  }
+  
+  public void setContributor(ASObject contributor) {
+    setProperty("contributor", contributor);
+  }
+  
+  public <T extends ASObject>T getEditor() {
+    return getProperty("editor");
+  }
+  
+  public void setEditor(ASObject editor) {
+    setProperty("editor", editor);
+  }
+ 
+}

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

Added: 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/extra/ExtendedEventObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/ExtendedEventObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,50 @@
+package org.apache.abdera2.activities.extra;
+
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.objects.EventObject;
+
+public abstract class ExtendedEventObject extends EventObject {
+
+  private static final long serialVersionUID = 8368535995814591315L;
+
+  public <T extends ASObject>T getHost() {
+    return getProperty("host");
+  }
+  
+  public void setHost(ASObject host) {
+    setProperty("host", host);
+  }
+  
+  public <T extends ASObject>T getOffers() {
+    return getProperty("offers");
+  }
+  
+  public void setOffers(ASObject offers) {
+    setProperty("offers", offers);
+  }
+  
+  public <T extends ASObject>T getSubEvents() {
+    return getProperty("subEvents");
+  }
+  
+  public void setSubEvents(ASObject subEvents) {
+    setProperty("subEvents", subEvents);
+  }
+  
+  public <T extends ASObject>T getSuperEvent() {
+    return getProperty("superEvent");
+  }
+  
+  public void setSuperEvent(ASObject superEvent) {
+    setProperty("superEvent", superEvent);
+  }
+  
+  public <T extends ASObject>T getPerformers() {
+    return getProperty("performers");
+  }
+  
+  public void setPerformers(ASObject performers) {
+    setProperty("performers", performers);
+  }
+  
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,135 @@
+package org.apache.abdera2.activities.extra;
+
+
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.IO;
+
+public class Extra {
+
+  @SuppressWarnings("unchecked")
+  public static void initExtras(IO io) {
+
+    io.addObjectMapping(
+      BookObject.class,
+      MovieObject.class,
+      OfferObject.class,
+      TvEpisodeObject.class,
+      TvSeasonObject.class,
+      TvSeriesObject.class);
+  }
+  
+  /**
+   * 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");
+  }
+  
+  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/extra/Extra.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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/extra/MovieObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/MovieObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,80 @@
+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.activities.model.MediaLink;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.common.date.Duration;
+
+@Name("movie")
+@Properties({
+  @Property(name="preview",to=MediaLink.class),
+  @Property(name="duration",to=Duration.class)
+})
+public class MovieObject extends CreativeWork {
+
+  private static final long serialVersionUID = -1551754630697817614L;
+
+  public MovieObject() {}
+  
+  public MovieObject(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getActors() {
+    return getProperty("actors");
+  }
+  
+  public void setActors(ASObject actors) {
+    setProperty("actors", actors);
+  }
+  
+  public <T extends ASObject>T getDirector() {
+    return getProperty("director");
+  }
+  
+  public void setDirector(ASObject director) {
+    setProperty("director", director);
+  }
+  
+  public Duration getDuration() {
+    return getProperty("duration");
+  }
+  
+  public void setDuration(Duration duration) {
+    setProperty("duration", duration);
+  }
+  
+  public <T extends ASObject>T getMusicBy() {
+    return getProperty("musicBy");
+  }
+  
+  public void setMusicBy(ASObject musicBy) {
+    setProperty("musicBy", musicBy);
+  }
+  
+  public <T extends ASObject>T getProducer() {
+    return getProperty("producer");
+  }
+  
+  public void setProducer(ASObject producer) {
+    setProperty("producer", producer);
+  }
+  
+  public <T extends ASObject>T getProductionCompany() {
+    return getProperty("productionCompany");
+  }
+  
+  public void setProductionCompany(ASObject org) {
+    setProperty("productionCompany", org);
+  }
+  
+  public MediaLink getPreview() {
+    return getProperty("preview");
+  }
+  
+  public void setPreview(MediaLink link) {
+    setProperty("preview", link);
+  }
+}

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

Added: 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/extra/OfferObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/OfferObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,88 @@
+package org.apache.abdera2.activities.extra;
+
+import java.util.Date;
+
+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;
+
+@Name("offer")
+@Properties({
+  @Property(name="validFrom",to=Date.class),
+  @Property(name="validUntil",to=Date.class)
+})
+public class OfferObject extends ASObject {
+
+  private static final long serialVersionUID = 8693274483912587801L;
+
+  public OfferObject() {}
+  
+  public OfferObject(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getAvailability() {
+    return getProperty("availability");
+  }
+  
+  public void setAvailability(ASObject availability) {
+    setProperty("availability", availability);
+  }
+  
+  public <T extends ASObject>T getCondition() {
+    return getProperty("condition");
+  }
+  
+  public void setCondition(ASObject condition) {
+    setProperty("condition", condition);
+  }
+  
+  public <T extends ASObject>T getItem() {
+    return getProperty("item");
+  }
+  
+  public void setItem(ASObject item) {
+    setProperty("item", item);
+  }
+  
+  public String getPrice() {
+    return getProperty("price");
+  }
+  
+  public void setPrice(String price) {
+    setProperty("price", price);
+  }
+  
+  public String getCurrency() {
+    return getProperty("currency");
+  }
+  
+  public void setCurrency(String currency) {
+    setProperty("currency",currency);
+  }
+  
+  public Date getValidUntil() {
+    return getProperty("validUntil");
+  }
+  
+  public void setValidUntil(Date date) {
+    setProperty("validUntil", date);
+  }
+  
+  public Date getValidFrom() {
+    return getProperty("validFrom");
+  }
+  
+  public void setValidFrom(Date date) {
+    setProperty("validFrom", date);
+  }
+
+  public <T extends ASObject>T getRestriction() {
+    return getProperty("restriction");
+  }
+  
+  public void setRestriction(ASObject restriction) {
+    setProperty("restriction", restriction);
+  }
+}

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

Added: 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/extra/TvEpisodeObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvEpisodeObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,94 @@
+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.activities.model.MediaLink;
+import org.apache.abdera2.common.anno.Name;
+
+@Name("tv-episode")
+@Properties({
+  @Property(name="preview",to=MediaLink.class)
+})
+public class TvEpisodeObject extends CreativeWork {
+
+  private static final long serialVersionUID = -1551754630697817614L;
+
+  public TvEpisodeObject() {}
+  
+  public TvEpisodeObject(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getActors() {
+    return getProperty("actors");
+  }
+  
+  public void setActors(ASObject actors) {
+    setProperty("actors", actors);
+  }
+  
+  public <T extends ASObject>T getDirector() {
+    return getProperty("director");
+  }
+  
+  public void setDirector(ASObject director) {
+    setProperty("director", director);
+  }
+
+  public <T extends ASObject>T getMusicBy() {
+    return getProperty("musicBy");
+  }
+  
+  public void setMusicBy(ASObject musicBy) {
+    setProperty("musicBy", musicBy);
+  }
+  
+  public <T extends ASObject>T getProducer() {
+    return getProperty("producer");
+  }
+  
+  public void setProducer(ASObject producer) {
+    setProperty("producer", producer);
+  }
+  
+  public <T extends ASObject>T getProductionCompany() {
+    return getProperty("productionCompany");
+  }
+  
+  public void setProductionCompany(ASObject org) {
+    setProperty("productionCompany", org);
+  }
+  
+  public MediaLink getPreview() {
+    return getProperty("preview");
+  }
+  
+  public void setPreview(MediaLink link) {
+    setProperty("preview", link);
+  }
+  
+  public <T extends ASObject>T getSeries() {
+    return getProperty("series");
+  }
+  
+  public void setSeries(ASObject series) {
+    setProperty("series", series);
+  }
+  
+  public <T extends ASObject>T getSeason() {
+    return getProperty("season");
+  }
+  
+  public void setSeason(ASObject season) {
+    setProperty("season", season);
+  }
+  
+  public int getEpisodeNumber() {
+    return (Integer)getProperty("episode");
+  }
+  
+  public void setEpisodeNumber(int episode) {
+    setProperty("episode", episode);
+  }
+}

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

Added: 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/extra/TvSeasonObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeasonObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,114 @@
+package org.apache.abdera2.activities.extra;
+
+import java.util.Date;
+
+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.common.anno.Name;
+
+@Name("tv-season")
+@Properties({
+  @Property(name="startDate",to=Date.class),
+  @Property(name="endDate",to=Date.class),
+  @Property(name="preview",to=MediaLink.class)
+})
+public class TvSeasonObject extends CreativeWork {
+
+  private static final long serialVersionUID = -1551754630697817614L;
+
+  public TvSeasonObject() {}
+  
+  public TvSeasonObject(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getActors() {
+    return getProperty("actors");
+  }
+  
+  public void setActor(ASObject actors) {
+    setProperty("actors", actors);
+  }
+  
+  public <T extends ASObject>T getDirector() {
+    return getProperty("director");
+  }
+  
+  public void setDirector(ASObject object) {
+    setProperty("director", object);
+  }
+  
+  public <T extends ASObject>T getMusicBy() {
+    return getProperty("musicBy");
+  }
+  
+  public void setMusicBy(ASObject musicBy) {
+    setProperty("musicBy", musicBy);
+  }
+  
+  public <T extends ASObject>T getProducer() {
+    return getProperty("producer");
+  }
+  
+  public void setProducer(ASObject producer) {
+    setProperty("producer", producer);
+  }
+  
+  public <T extends ASObject>T getProductionCompany() {
+    return getProperty("productionCompany");
+  }
+  
+  public void setProductionCompany(ASObject org) {
+    setProperty("productionCompany", org);
+  }
+  
+  public MediaLink getPreview() {
+    return getProperty("preview");
+  }
+  
+  public void setPreview(MediaLink link) {
+    setProperty("preview", link);
+  }
+  
+  public Date getStartDate() {
+    return getProperty("startDate");
+  }
+  
+  public void setStartDate(Date date) {
+    setProperty("startDate", date);
+  }
+  
+  public Date getEndDate() {
+    return getProperty("endDate");
+  }
+  
+  public void setEndDate(Date date) {
+    setProperty("endDate", date);
+  }
+  
+  public <T extends ASObject>T getEpisodes() {
+    return getProperty("episodes");
+  }
+  
+  public void setEpisodes(ASObject episodes) {
+    setProperty("episodes", episodes);
+  }
+  
+  public <T extends ASObject>T getSeries() {
+    return getProperty("series");
+  }
+  
+  public void setSeries(ASObject series) {
+    setProperty("series", series);
+  }
+  
+  public int getSeasonNumber() {
+    return (Integer)getProperty("season");
+  }
+  
+  public void setSeasonNumber(int season) {
+    setProperty("season", season);
+  }
+}

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

Added: 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/extra/TvSeriesObject.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/TvSeriesObject.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,106 @@
+package org.apache.abdera2.activities.extra;
+
+import java.util.Date;
+
+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.common.anno.Name;
+
+@Name("tv-series")
+@Properties({
+  @Property(name="startDate",to=Date.class),
+  @Property(name="endDate",to=Date.class),
+  @Property(name="preview",to=MediaLink.class)
+})
+public class TvSeriesObject extends CreativeWork {
+
+  private static final long serialVersionUID = -1551754630697817614L;
+
+  public TvSeriesObject() {}
+  
+  public TvSeriesObject(String displayName) {
+    setDisplayName(displayName);
+  }
+  
+  public <T extends ASObject>T getActors() {
+    return getProperty("actors");
+  }
+  
+  public void setActor(ASObject actors) {
+    setProperty("actors", actors);
+  }
+  
+  public <T extends ASObject>T getDirector() {
+    return getProperty("director");
+  }
+  
+  public void setDirector(ASObject object) {
+    setProperty("director", object);
+  }
+
+  public <T extends ASObject>T getMusicBy() {
+    return getProperty("musicBy");
+  }
+  
+  public void setMusicBy(ASObject musicBy) {
+    setProperty("musicBy", musicBy);
+  }
+  
+  public <T extends ASObject>T getProducer() {
+    return getProperty("producer");
+  }
+  
+  public void setProducer(ASObject producer) {
+    setProperty("producer", producer);
+  }
+  
+  public <T extends ASObject>T getProductionCompany() {
+    return getProperty("productionCompany");
+  }
+  
+  public void setProductionCompany(ASObject org) {
+    setProperty("productionCompany", org);
+  }
+  
+  public MediaLink getPreview() {
+    return getProperty("preview");
+  }
+  
+  public void setPreview(MediaLink link) {
+    setProperty("preview", link);
+  }
+  
+  public Date getStartDate() {
+    return getProperty("startDate");
+  }
+  
+  public void setStartDate(Date date) {
+    setProperty("startDate", date);
+  }
+  
+  public Date getEndDate() {
+    return getProperty("endDate");
+  }
+  
+  public void setEndDate(Date date) {
+    setProperty("endDate", date);
+  }
+  
+  public <T extends ASObject>T getSeasons() {
+    return getProperty("seasons");
+  }
+  
+  public void setSeasons(ASObject seasons) {
+    setProperty("seasons", seasons);
+  }
+  
+  public <T extends ASObject>T getEpisodes() {
+    return getProperty("episodes");
+  }
+  
+  public void setEpisodes(ASObject episodes) {
+    setProperty("episodes", episodes);
+  }
+}

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

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/AdaptedType.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/AdaptedType.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/AdaptedType.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/AdaptedType.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,19 @@
+package org.apache.abdera2.activities.io.gson;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Intended to be used on TypeAdapter instances to 
+ * identify the adapted type
+ */
+@Retention(RUNTIME)
+@Target( {TYPE})
+@Inherited
+public @interface AdaptedType {
+  Class<?> value();
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/AdaptedType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.Discover;
+import org.apache.abdera2.common.anno.AnnoUtil;
+import org.apache.abdera2.common.geo.IsoPosition;
+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.activities.model.*;
+import org.apache.abdera2.activities.model.objects.AccountObject;
+import org.apache.abdera2.activities.model.objects.Address;
+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.BookmarkObject;
+import org.apache.abdera2.activities.model.objects.CommentObject;
+import org.apache.abdera2.activities.model.objects.EventObject;
+import org.apache.abdera2.activities.model.objects.FileObject;
+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.NameObject;
+import org.apache.abdera2.activities.model.objects.NoteObject;
+import org.apache.abdera2.activities.model.objects.OrganizationObject;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+import org.apache.abdera2.activities.model.objects.PlaceObject;
+import org.apache.abdera2.activities.model.objects.ProductObject;
+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.VideoObject;
+import org.apache.abdera2.activities.protocol.ErrorObject;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+
+/**
+ * (De)serialization of ASBase object
+ */
+public class BaseAdapter 
+  implements GsonTypeAdapter<ASBase> {
+
+  private final Map<String,Class<?>> map = 
+    new ConcurrentHashMap<String,Class<?>>();
+  private final Map<String,Class<? extends ASObject>> objsmap =
+    new ConcurrentHashMap<String,Class<? extends ASObject>>();
+  
+  public BaseAdapter() {
+    initPropMap();
+  }
+  
+  @SuppressWarnings("unchecked")
+  private void initPropMap() {
+    map.put("verb",Verb.class);
+    map.put("url",IRI.class);
+    map.put("fileurl", IRI.class);
+    map.put("gadget", IRI.class);
+    map.put("updated", Date.class);
+    map.put("published", Date.class);
+    map.put("lang", Lang.class);
+    map.put("icon", MediaLink.class);
+    map.put("image", MediaLink.class);
+    map.put("totalitems", Integer.class);
+    map.put("duration", Integer.class);
+    map.put("height", Integer.class);
+    map.put("location", PlaceObject.class);
+    map.put("mood", Mood.class);
+    map.put("address", Address.class);
+    map.put("stream", MediaLink.class);
+    map.put("fullimage", MediaLink.class);
+    map.put("endtime", Date.class);
+    map.put("starttime", Date.class);
+    map.put("mimetype", MimeType.class);
+    map.put("rating", Double.class);
+    map.put("position", IsoPosition.class);
+    map.put("etag", EntityTag.class);
+    
+    // From the replies spec
+    map.put("attending", Collection.class);
+    map.put("followers", Collection.class);
+    map.put("following", Collection.class);
+    map.put("friends", Collection.class);
+    map.put("friend-requests", Collection.class);
+    map.put("likes", Collection.class);
+    map.put("notAttending", Collection.class);
+    map.put("maybeAttending", Collection.class);
+    map.put("members", Collection.class);
+    map.put("replies", Collection.class);
+    map.put("reviews", Collection.class);
+    map.put("saves", Collection.class);
+    map.put("shares", Collection.class);
+    
+    processType(
+      objsmap,map,
+      Address.class,
+      Activity.class,
+      ArticleObject.class,
+      AudioObject.class,
+      BadgeObject.class,
+      BookmarkObject.class,
+      Collection.class,
+      CommentObject.class,
+      EventObject.class,
+      FileObject.class,
+      GroupObject.class,
+      ImageObject.class,
+      NoteObject.class,
+      PersonObject.class,
+      PlaceObject.class,
+      ProductObject.class,
+      QuestionObject.class,
+      ReviewObject.class,
+      ServiceObject.class,
+      VideoObject.class,
+      ErrorObject.class,
+      NameObject.class,
+      AccountObject.class,
+      OrganizationObject.class);
+  }
+  
+  private static void processType(
+    Map<String,Class<? extends ASObject>> map, 
+    Map<String,Class<?>> propsmap,
+    Class<? extends ASObject>... _classes) {
+    for (Class<? extends ASObject> _class : _classes) {
+      String name = AnnoUtil.getName(_class);
+      map.put(name, _class);
+      if (_class.isAnnotationPresent(Properties.class)) {
+        Properties props = _class.getAnnotation(Properties.class);
+        for (Property prop : props.value()) {
+          String _propname = prop.name();
+          Class<?> _propclass = prop.to();
+          propsmap.put(_propname, _propclass);
+        }
+      }
+    }
+  }
+  
+  public void addObjectMap(Class<? extends ASObject>... _class) {
+    processType(objsmap,map,_class);
+  }
+  
+  public void addPropertyMap(String name, Class<?> _class) {
+    map.put(name,_class);
+  }
+  
+  public JsonElement serialize(
+    ASBase asbase, 
+    Type type,
+    JsonSerializationContext context) {
+
+    JsonObject el = new JsonObject();
+    
+    for (String key : asbase) {
+      Object val = asbase.getProperty(key);
+      if (val != null) {
+        JsonElement value = null;
+        if (val instanceof Verb)
+          value = context.serialize(val, Verb.class);
+        else 
+          value = context.serialize(val, val.getClass());
+        el.add(key, value);
+      }
+    }
+    
+    return el;
+  }
+
+  public ASBase deserialize(
+    JsonElement el, 
+    Type type,
+    JsonDeserializationContext context) 
+      throws JsonParseException {
+    JsonObject obj = (JsonObject)el;
+    ASBase base = null;
+    if (type == Collection.class) {
+      base = new Collection<ASObject>();
+    } else if (type == Activity.class) {
+      base = new Activity();
+    } else if (type == MediaLink.class) {
+      base = new MediaLink();
+    } else if (type == PlaceObject.class) {
+      base = new PlaceObject();
+    } else if (type == Mood.class) {
+      base = new Mood();
+    } else if (type == Address.class) {
+      base = new Address();
+    } else {
+      JsonPrimitive ot = obj.getAsJsonPrimitive("objectType");
+      if (ot != null) {
+        String ots = ot.getAsString();
+        Class<? extends ASObject> _class = objsmap.get(ots);
+        if (_class != null) {
+          base = Discover.locate(_class, _class.getName());
+          try {
+            base = _class.newInstance();
+          } catch (Throwable t) {}
+          
+        } else base = new ASObject(ots);
+      } 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")) {
+          base = new Collection<ASObject>();
+        } else {
+          base = new ASObject(); // anonymous object
+        }
+      }
+    }
+    for (Entry<String,JsonElement> entry : obj.entrySet()) {
+      String name = entry.getKey();
+      Class<?> _class = map.get(name.toLowerCase(Locale.US));
+      JsonElement val = entry.getValue();
+      if (val.isJsonPrimitive()) {
+        if (_class != null) {
+          base.setProperty(name, context.deserialize(val,_class));
+        } else {
+          JsonPrimitive prim = val.getAsJsonPrimitive();
+          if (prim.isBoolean()) 
+            base.setProperty(name, prim.getAsBoolean());
+          else if (prim.isNumber())
+            base.setProperty(name, prim.getAsNumber());
+          else {
+            base.setProperty(name, prim.getAsString());
+          }
+        }
+      } else if (val.isJsonArray()) {
+        List<Object> list = new ArrayList<Object>();
+        JsonArray arr = val.getAsJsonArray();
+        processArray(arr, _class, context, list);
+        base.setProperty(name, list);
+      } else if (val.isJsonObject()) {
+        if (map.containsKey(name)) {
+          base.setProperty(name, context.deserialize(val, map.get(name)));
+        } else
+          base.setProperty(name, context.deserialize(val, ASObject.class));
+      }
+    }
+    return base;
+  }
+
+  private void processArray(JsonArray arr, Class<?> _class, JsonDeserializationContext context, List<Object> list) {
+    for (JsonElement mem : arr) {
+      if (mem.isJsonPrimitive()) {
+        if (_class != null) {
+          list.add(context.deserialize(mem, _class));
+        } else {
+          JsonPrimitive prim2 = (JsonPrimitive) mem;
+          if (prim2.isBoolean())
+            list.add(prim2.getAsBoolean());
+          else if (prim2.isNumber())
+            list.add(prim2.getAsNumber());
+          else
+            list.add(prim2.getAsString());
+        }
+      } else if (mem.isJsonObject()) {
+        list.add(context.deserialize(mem, _class!=null?_class:ASObject.class));
+      } else if (mem.isJsonArray()) {
+        JsonArray array = mem.getAsJsonArray();
+        List<Object> objs = new ArrayList<Object>();
+        processArray(array,_class,context,objs);
+        list.add(objs);
+      }
+    }
+  }
+  
+  public Class<ASBase> getAdaptedClass() {
+    return ASBase.class;
+  }
+
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DateAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DateAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DateAdapter.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DateAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import java.util.Date;
+
+import org.apache.abdera2.common.date.DateTime;
+
+@AdaptedType(Date.class)
+public class DateAdapter
+  extends SimpleAdapter<Date> {
+
+  protected String serialize(Date t) {
+    return DateTime.format(t);
+  }
+
+  protected Date deserialize(String v) {
+    return DateTime.parse(v);
+  }
+
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DateAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DurationAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DurationAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DurationAdapter.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DurationAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import org.apache.abdera2.common.date.Duration;
+
+@AdaptedType(Duration.class)
+public class DurationAdapter
+  extends SimpleAdapter<Duration> {
+
+  protected String serialize(Duration t) {
+    return t.toString();
+  }
+
+  protected Duration deserialize(String v) {
+    return Duration.parse(v);
+  }
+
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/DurationAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/EntityTagAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/EntityTagAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/EntityTagAdapter.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/EntityTagAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import org.apache.abdera2.common.http.EntityTag;
+
+@AdaptedType(EntityTag.class)
+public class EntityTagAdapter 
+  extends SimpleAdapter<EntityTag> {
+
+  protected EntityTag deserialize(String v) {
+    return new EntityTag(v);
+  }
+
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/EntityTagAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,274 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Date;
+
+import org.apache.abdera2.common.date.Duration;
+import org.apache.abdera2.common.date.Interval;
+import org.apache.abdera2.common.geo.IsoPosition;
+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.templates.Template;
+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.Collection;
+import org.apache.abdera2.activities.model.CollectionWriter;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.MediaLink;
+import org.apache.abdera2.activities.model.TypeAdapter;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.activities.model.objects.Address;
+import org.apache.abdera2.activities.model.objects.Mood;
+import org.apache.abdera2.activities.model.objects.PlaceObject;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.stream.JsonWriter;
+
+@SuppressWarnings("unchecked")
+public class GsonIO extends IO {
+
+  private final Gson gson;
+  private final BaseAdapter asbs;
+  
+  public GsonIO() {
+    this.asbs = new BaseAdapter();
+    this.gson = gson(false,(BaseAdapter)asbs);
+  }
+  
+  public GsonIO(TypeAdapter<?>... adapters) {
+    this.asbs = new BaseAdapter();
+    this.gson = gson(false,asbs, adapters);
+  }
+  
+  public GsonIO(Boolean prettyprint) {
+    this.asbs = new BaseAdapter();
+    this.gson = gson(prettyprint,(BaseAdapter)asbs);
+  }
+  
+  public GsonIO(Boolean prettyprint, TypeAdapter<?>... adapters) {
+    this.asbs = new BaseAdapter();
+    this.gson = gson(prettyprint,asbs, adapters);
+  }
+  
+  private static Gson gson(Boolean pretty, BaseAdapter asbs, TypeAdapter<?>... adapters) {
+    GsonBuilder gb = new GsonBuilder();    
+    gb.registerTypeHierarchyAdapter(Verb.class, new VerbAdapter());
+    gb.registerTypeHierarchyAdapter(Lang.class, new LangAdapter());
+    gb.registerTypeHierarchyAdapter(ASBase.class,  asbs);  
+    gb.registerTypeAdapter(ASBase.class, asbs);
+    gb.registerTypeAdapter(Date.class, new DateAdapter());
+    gb.registerTypeAdapter(Duration.class, new DurationAdapter());
+    gb.registerTypeAdapter(Interval.class, new IntervalAdapter());
+    gb.registerTypeAdapter(Activity.class,  asbs);
+    gb.registerTypeAdapter(PlaceObject.class, asbs);
+    gb.registerTypeAdapter(Mood.class, asbs);
+    gb.registerTypeAdapter(Address.class, asbs);
+    gb.registerTypeAdapter(IRI.class, new IriAdapter());
+    gb.registerTypeAdapter(IsoPosition.class, new PositionAdapter());
+    gb.registerTypeAdapter(EntityTag.class, new EntityTagAdapter());
+    gb.registerTypeAdapter(Template.class, new TemplateAdapter());
+    for(TypeAdapter<?> adapter : adapters) {
+      if (adapter instanceof GsonTypeAdapter) {
+        gb.registerTypeAdapter(
+          adapter.getAdaptedClass(), adapter);
+      }
+    }
+    gb.enableComplexMapKeySerialization();
+    if (pretty)
+      gb.setPrettyPrinting();
+    return gb.create();
+  }
+  
+  public String write(ASBase base) {
+    return gson.toJson(base);
+  }
+  
+  public void write(ASBase base, Appendable writer) {
+    gson.toJson(base, writer);
+  }
+
+  public <T extends ASBase>T read(Reader reader) {
+    return (T)gson.fromJson(reader, ASBase.class);
+  }
+  
+  public <T extends ASBase>T read(String json) {
+    return (T)gson.fromJson(json, ASBase.class);
+  }
+  
+  public Activity readActivity(Reader reader) {
+    return gson.fromJson(reader, Activity.class);
+  }
+  
+  public Activity readActivity(String json) {
+    return gson.fromJson(json, Activity.class);
+  }
+  
+  public <T extends ASObject>Collection<T> readCollection(Reader reader) {
+    return gson.fromJson(reader, Collection.class);
+  }
+  
+  public <T extends ASObject>Collection<T> readCollection(String json) {
+    return gson.fromJson(json, Collection.class);
+  }
+  
+  public <T extends ASObject>T readObject(Reader reader) {
+    return (T)gson.fromJson(reader, ASObject.class);
+  }
+  
+  public <T extends ASObject>T readObject(String json) {
+    return (T)gson.fromJson(json, ASObject.class);
+  }
+  
+  public MediaLink readMediaLink(Reader reader) {
+    return gson.fromJson(reader, MediaLink.class);
+  }
+  
+  public MediaLink readMediaLink(String json) {
+    return gson.fromJson(json, MediaLink.class);
+  }
+
+  @Override
+  public void addPropertyMapping(String name, Class<?> _class) {
+    asbs.addPropertyMap(name, _class);
+  }
+
+  @Override
+  public void addObjectMapping(Class<? extends ASObject>... _class) {
+    asbs.addObjectMap(_class);
+  }
+  
+  public void writeCollection(
+    OutputStream out, 
+    String charset,
+    ASBase header,
+    Iterable<ASObject> objects) {
+    try {
+      OutputStreamWriter outw = 
+        new OutputStreamWriter(out,charset);
+      writeCollection(outw,header,objects);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  public void writeCollection(
+    Writer out,
+    ASBase header,
+    Iterable<ASObject> objects) {
+    try {
+      JsonWriter writer = new JsonWriter(out);
+      writer.beginObject();
+      if (header != null) {
+        for (String name : header) {
+          Object val = header.getProperty(name);
+          writer.name(name);
+          if (val != null) {
+            gson.toJson(val,val.getClass(),writer);
+          } else writer.nullValue();
+        }
+      }
+      writer.name("items");
+      writer.beginArray();
+      for (ASObject obj : objects) {
+        gson.toJson(obj,ASBase.class,writer);
+      }
+      writer.endArray();
+      writer.endObject();
+      writer.flush();
+      if (autoclose)
+        writer.close();
+    } catch (IOException t) {
+      throw new RuntimeException(t);
+    }
+  }
+  
+  public CollectionWriter getCollectionWriter(Writer out) {
+    return new GsonCollectionWriter(gson,out, autoclose);
+  }
+  
+  private static class GsonCollectionWriter
+    implements CollectionWriter {
+    private final JsonWriter writer;
+    private final Gson gson;
+    private final boolean autoclose;
+    private boolean _items = false;
+    private boolean _header = false;
+    GsonCollectionWriter(Gson gson, Writer out, boolean autoclose) {
+      this.gson = gson;
+      this.writer = new JsonWriter(out);
+      this.autoclose = autoclose;
+      try {
+        writer.beginObject();
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }
+    public void writeHeader(ASBase base) {
+      if (_items || _header)
+        throw new IllegalStateException();
+      try {
+        if (base != null) {
+          for (String name : base) {
+            Object val = base.getProperty(name);
+            writer.name(name);
+            if (val != null) {
+              gson.toJson(val,val.getClass(),writer);
+            } else writer.nullValue();
+          }
+        }
+        _header = true;
+        writer.flush();
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }
+    public void writeObject(ASObject object) {
+      try {
+        if (!_items) {
+          writer.name("items");
+          writer.beginArray();
+          _items = true;
+        }
+        gson.toJson(object,ASBase.class,writer);
+        writer.flush();
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }
+    public void complete() {
+      try {
+        if (_items) writer.endArray();
+        writer.endObject();
+        writer.flush();
+        if (autoclose) 
+          writer.close();
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }
+  }
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonIO.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonTypeAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonTypeAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonTypeAdapter.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonTypeAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import org.apache.abdera2.activities.model.TypeAdapter;
+
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonSerializer;
+
+public interface GsonTypeAdapter<T> 
+  extends TypeAdapter<T>, JsonSerializer<T>, JsonDeserializer<T> {
+
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/GsonTypeAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/IntervalAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/IntervalAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/IntervalAdapter.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/IntervalAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.activities.io.gson;
+
+import org.apache.abdera2.common.date.Interval;
+
+@AdaptedType(Interval.class)
+public class IntervalAdapter
+  extends SimpleAdapter<Interval> {
+
+  protected String serialize(Interval t) {
+    return t.toString();
+  }
+
+  protected Interval deserialize(String v) {
+    return Interval.parse(v);
+  }
+
+}



Mime
View raw message