abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1187164 - in /abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities: model/ model/objects/ protocol/ protocol/basic/
Date Fri, 21 Oct 2011 01:51:41 GMT
Author: jmsnell
Date: Fri Oct 21 01:51:40 2011
New Revision: 1187164

URL: http://svn.apache.org/viewvc?rev=1187164&view=rev
Log: (empty)

Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
Fri Oct 21 01:51:40 2011
@@ -316,64 +316,64 @@ public class Activity extends ASObject {
       list.add(obj);
   }
 
-  public static ActivityGenerator make() {
-    return new ActivityGenerator();
+  public static <T extends Activity>ActivityGenerator<T> makeActivity() {
+    return new ActivityGenerator<T>();
   }
   
-  public static class ActivityGenerator extends ASObjectGenerator<Activity> {
+  public static class ActivityGenerator<T extends Activity> extends ASObjectGenerator<T>
{
     ActivityGenerator() {
-      super(Activity.class);
+      super((Class<? extends T>) Activity.class);
     }
-    protected ActivityGenerator(Class<? extends Activity> _class) {
+    protected ActivityGenerator(Class<? extends T> _class) {
       super(_class);
     }
-    public <T extends ActivityGenerator>T to(ASObject object) {
+    public <X extends ActivityGenerator<T>>X to(ASObject object) {
       item.addAudience(Audience.TO, object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T cc(ASObject object) {
+    public <X extends ActivityGenerator<T>>X cc(ASObject object) {
       item.addAudience(Audience.CC, object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T bcc(ASObject object) {
+    public <X extends ActivityGenerator<T>>X bcc(ASObject object) {
       item.addAudience(Audience.BCC, object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T bto(ASObject object) {
+    public <X extends ActivityGenerator<T>>X bto(ASObject object) {
       item.addAudience(Audience.BTO, object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T actor(ASObject object) {
+    public <X extends ActivityGenerator<T>>X actor(ASObject object) {
       item.setActor(object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T generator(ASObject object) {
+    public <X extends ActivityGenerator<T>>X generator(ASObject object) {
       item.setGenerator(object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T icon(MediaLink link) {
+    public <X extends ActivityGenerator<T>>X icon(MediaLink link) {
       item.setIcon(link);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T object(ASObject object) {
+    public <X extends ActivityGenerator<T>>X object(ASObject object) {
       item.setObject(object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T provider(ASObject object) {
+    public <X extends ActivityGenerator<T>>X provider(ASObject object) {
       item.setProvider(object);
-      return (T)this;
+      return (X)this;
     }
-    public <T extends ActivityGenerator>T target(ASObject object) {
+    public <X extends ActivityGenerator<T>>X target(ASObject object) {
       item.setTarget(object);
-      return (T)this;
+      return (X)this;
     }
-    public <X extends ActivityGenerator>X title(String title) {
+    public <X extends ActivityGenerator<T>>X title(String title) {
       item.setTitle(title);
       return (X)this;
     }
-    public <T extends ActivityGenerator>T verb(Verb verb) {
+    public <X extends ActivityGenerator<T>>X verb(Verb verb) {
       item.setVerb(verb);
-      return (T)this;
+      return (X)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
Fri Oct 21 01:51:40 2011
@@ -124,7 +124,7 @@ public class Collection<T extends ASObje
     setTotalItems(list.size());
   }
   
-  public static <T extends ASObject>CollectionGenerator<T> make() {
+  public static <T extends ASObject>CollectionGenerator<T> makeCollection() {
     return new CollectionGenerator<T>();
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/EmbeddedExperience.java
Fri Oct 21 01:51:40 2011
@@ -67,7 +67,7 @@ public class EmbeddedExperience 
     setGadget(new IRI(iri));
   }
   
-  public static EmbeddedExperienceGenerator make() {
+  public static EmbeddedExperienceGenerator makeEmbeddedExperience() {
     return new EmbeddedExperienceGenerator();
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/MediaLink.java
Fri Oct 21 01:51:40 2011
@@ -83,7 +83,7 @@ public class MediaLink extends ASBase {
     setUrl(new IRI(url));
   }
   
-  public static MediaLinkGenerator make() {
+  public static MediaLinkGenerator makeMediaLink() {
     return new MediaLinkGenerator();
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
Fri Oct 21 01:51:40 2011
@@ -286,8 +286,7 @@ public class PersonObject 
     list.add(org);
   }
   
-  @SuppressWarnings("rawtypes")
-  public static <T extends PersonObject>PersonObjectGenerator makePerson() {
+  public static <T extends PersonObject>PersonObjectGenerator<T> makePerson()
{
     return new PersonObjectGenerator<T>();
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
Fri Oct 21 01:51:40 2011
@@ -18,7 +18,6 @@
 package org.apache.abdera2.activities.protocol;
 
 import java.io.IOException;
-import java.util.Date;
 
 import org.apache.abdera2.activities.model.ASBase;
 import org.apache.abdera2.activities.model.ASObject;
@@ -31,6 +30,7 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.ResponseContextException;
+import org.joda.time.DateTime;
 
 @SuppressWarnings("unchecked")
 public abstract class AbstractActivitiesCollectionAdapter
@@ -43,54 +43,58 @@ public abstract class AbstractActivities
   }
   
   protected <S extends ResponseContext>S buildCreateEntryResponse(String link, ASBase
base) {
-    ActivitiesResponseContext<ASBase> rc = 
-      new ActivitiesResponseContext<ASBase>(base);
-    rc.setLocation(link);
-    rc.setContentLocation(rc.getLocation().toString());
-    rc.setEntityTag(AbstractActivitiesProvider.calculateEntityTag(base));
-    rc.setStatus(201);
-    return (S)rc;
+    return (S)
+      new ActivitiesResponseContext<ASBase>(base)
+        .setLocation(link)
+        .setContentLocation(link)
+        .setEntityTag(AbstractActivitiesProvider.calculateEntityTag(base))
+        .setStatus(201);
   }
 
   protected <S extends ResponseContext>S buildGetEntryResponse(RequestContext request,
ASObject base)
       throws ResponseContextException {
       base.setSource(createSourceObject(request));
-      ActivitiesResponseContext<ASObject> rc = 
-        new ActivitiesResponseContext<ASObject>(base);
-      rc.setEntityTag(AbstractActivitiesProvider.calculateEntityTag(base));
-      return (S)rc;
+      return (S)
+        new ActivitiesResponseContext<ASObject>(base)
+         .setEntityTag(AbstractActivitiesProvider.calculateEntityTag(base));
   }
 
   protected <S extends ResponseContext>S buildGetFeedResponse(Collection<ASObject>
collection) {
-      ActivitiesResponseContext<Collection<ASObject>> rc = 
-        new ActivitiesResponseContext<Collection<ASObject>>(collection);
-      rc.setEntityTag(AbstractActivitiesProvider.calculateEntityTag(collection));
-      return (S)rc;
+      return (S) 
+        new ActivitiesResponseContext<Collection<ASObject>>(collection)
+          .setEntityTag(AbstractActivitiesProvider.calculateEntityTag(collection));
   }
 
   protected ServiceObject createSourceObject(RequestContext request) throws ResponseContextException
{
-    ServiceObject object = new ServiceObject();
-    object.setDisplayName(getTitle(request));
-    object.setId(getId(request));
-    PersonObject personObject = new PersonObject();
-    personObject.setDisplayName(getAuthor(request));
-    object.setProperty("author", personObject);
-    return object;
+    return 
+      ServiceObject
+        .makeService()
+        .displayName(getTitle(request))
+        .id(getId(request))
+        .author(
+          PersonObject
+            .makePerson()
+            .displayName(getAuthor(request))
+            .get())
+        .get();
   }
   
   /**
    * Create the base feed for the requested collection.
    */
   protected Collection<ASObject> createCollectionBase(RequestContext request) throws
ResponseContextException {
-      Collection<ASObject> collection = 
-        new Collection<ASObject>();
-      collection.setProperty("id", getId(request));
-      collection.setProperty("title", getTitle(request));
-      collection.setProperty("updated", new Date());  
-      PersonObject personObject = new PersonObject();
-      personObject.setDisplayName(getAuthor(request));
-      collection.setProperty("author", personObject);
-      return collection;
+    return 
+      Collection
+        .makeCollection()
+        .id(getId(request))
+        .set("title", getTitle(request))
+        .set("updated", DateTime.now())
+        .set("author", 
+          PersonObject
+            .makePerson()
+            .displayName(getAuthor(request))
+            .get()) 
+        .get();
   }
 
   protected ASObject getEntryFromRequest(RequestContext request) throws ResponseContextException
{

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
Fri Oct 21 01:51:40 2011
@@ -73,14 +73,15 @@ public abstract class AbstractActivities
     int code,
     String message, 
     Throwable t) {
-      ErrorObject errorObject = new ErrorObject();
-      errorObject.setDisplayName(message);
-      errorObject.setCode(code);
-      ActivitiesResponseContext<ErrorObject> rc = 
-        new ActivitiesResponseContext<ErrorObject>(errorObject);
-      rc.setStatus(code);
-      rc.setStatusText(message);
-      return (S)rc;
+      return (S) 
+        new ActivitiesResponseContext<ErrorObject>(
+            ErrorObject
+            .makeError()
+            .code(code)
+            .displayName(message)
+            .get())
+        .setStatus(code)
+        .setStatusText(message);
   }
 
   @Override

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
Fri Oct 21 01:51:40 2011
@@ -63,19 +63,19 @@ public abstract class AbstractActivities
     return typeAdapters;
   }
   
-  @SuppressWarnings("unchecked")
   public <S extends ResponseContext> S createErrorResponse(
     int code,
     String message, 
     Throwable t) {
-      ErrorObject errorObject = new ErrorObject();
-      errorObject.setDisplayName(message);
-      errorObject.setCode(code);
-      ActivitiesResponseContext<ErrorObject> rc = 
-        new ActivitiesResponseContext<ErrorObject>(errorObject);
-      rc.setStatus(code);
-      rc.setStatusText(message);
-      return (S)rc;
+      return 
+        new ActivitiesResponseContext<ErrorObject>(
+          ErrorObject
+            .makeError()
+            .code(code)
+            .displayName(message)
+            .get())
+        .setStatus(code)
+        .setStatusText(message);
   }
   
   @SuppressWarnings("unchecked")

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java
Fri Oct 21 01:51:40 2011
@@ -37,11 +37,28 @@ public class ErrorObject extends ASObjec
   public String getObjectType() {
     return TYPE;
   }
-  public void setObjectType(String objectType) {}
   public int getCode() {
     return (Integer)getProperty("code");
   }
   public void setCode(int code) {
     setProperty("code",code);
   }
+  
+  public static <T extends ErrorObject>ErrorObjectGenerator<T> makeError() {
+    return new ErrorObjectGenerator<T>();
+  }
+  
+  @SuppressWarnings("unchecked")
+  public static class ErrorObjectGenerator<T extends ErrorObject> extends ASObjectGenerator<T>
{
+    public ErrorObjectGenerator() {
+      super((Class<? extends T>) ErrorObject.class);
+    }
+    public ErrorObjectGenerator(Class<T> _class) {
+      super(_class);
+    }
+    public <X extends ErrorObjectGenerator<T>>X code(int code) {
+      item.setCode(code);
+      return (X)this;
+    }
+  }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java?rev=1187164&r1=1187163&r2=1187164&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
Fri Oct 21 01:51:40 2011
@@ -17,7 +17,6 @@
  */
 package org.apache.abdera2.activities.protocol.basic;
 
-import java.util.Date;
 import java.util.LinkedHashSet;
 import java.util.UUID;
 import java.util.logging.Logger;
@@ -43,6 +42,7 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.RequestContext.Scope;
 import org.apache.abdera2.common.pusher.ChannelManager;
 import org.apache.abdera2.common.pusher.Pusher;
+import org.joda.time.DateTime;
 
 /**
  * The BasicAdapter provides a simplistic interface for working with Atompub collections
with a restricted set of
@@ -69,21 +69,25 @@ public abstract class BasicAdapter exten
     }
 
     protected Collection<ASObject> createCollection() {
-      Collection<ASObject> col = new Collection<ASObject>();
-      col.setProperty("id", config.getFeedUri());
-      col.setProperty("title", config.getFeedTitle());
-      col.setProperty("updated", new Date());
-      PersonObject person = new PersonObject();
-      person.setDisplayName(config.getFeedAuthor());
-      col.setProperty("author", person);
+      Collection<ASObject> col = 
+        Collection
+          .makeCollection()
+          .id(config.getFeedUri())
+          .set("title", config.getFeedTitle())
+          .set("updated", DateTime.now())
+          .set("author", 
+            PersonObject
+              .makePerson()
+              .displayName(config.getFeedAuthor())
+              .get())
+          .get();
       col.setItems(new LinkedHashSet<ASObject>());
       return col;
     }
     
     protected void addEditLinkToObject(ASObject object) throws Exception {
-      if (AbstractActivitiesProvider.getEditUriFromEntry(object) == null) {
+      if (AbstractActivitiesProvider.getEditUriFromEntry(object) == null)
         object.setProperty("editLink", object.getId());
-      }
     }
 
     protected void setObjectIdIfNull(ASObject object) throws Exception {
@@ -139,10 +143,9 @@ public abstract class BasicAdapter exten
                   retl.addItem(err);
                 }
               }
-              ActivitiesResponseContext<Collection<ASObject>> rc = 
-                new ActivitiesResponseContext<Collection<ASObject>>(retl);
-              rc.setStatus(createFlag?201:200);
-              return (S)rc;
+              return (S)
+                new ActivitiesResponseContext<Collection<ASObject>>(retl)
+                  .setStatus(createFlag?201:200);
             } else if (base instanceof ASObject){
               String entryId = !createFlag ? target.getParameter(BasicProvider.PARAM_ENTRY)
: null;
               ASObject inputEntry = (ASObject) base;
@@ -190,12 +193,10 @@ public abstract class BasicAdapter exten
         String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
         try {
             ASObject object = getItem(entryId);
-            
             if (object != null) {
-              ActivitiesResponseContext<ASObject> rc = 
-                new ActivitiesResponseContext<ASObject>(object);
-              rc.setStatus(200);
-              return (S)rc;
+              return (S) 
+                new ActivitiesResponseContext<ASObject>(object)
+                  .setStatus(200);
             } else return (S)ProviderHelper.notfound(request);       
         } catch (Exception e) {
             return (S)ProviderHelper.servererror(request, e.getMessage(), e);
@@ -208,10 +209,9 @@ public abstract class BasicAdapter exten
               getCollection();
 
             if (collection != null) { 
-              ActivitiesResponseContext<Collection<ASObject>> rc = 
-                new ActivitiesResponseContext<Collection<ASObject>>(collection);
-              rc.setStatus(200);
-              return (S)rc;
+              return (S) 
+                new ActivitiesResponseContext<Collection<ASObject>>(collection)
+                  .setStatus(200);
             } else return (S)ProviderHelper.notfound(request);
         } catch (Exception e) {
             return (S)ProviderHelper.servererror(request, e.getMessage(), e);



Mime
View raw message