streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject [3/4] git commit: STREAMS-139 | Modified buildProvider to make logic more understandable
Date Tue, 12 Aug 2014 21:44:37 GMT
STREAMS-139 | Modified buildProvider to make logic more understandable


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/6eb9707a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/6eb9707a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/6eb9707a

Branch: refs/heads/master
Commit: 6eb9707ae9de40e399f3a89801fa952867a5c9a8
Parents: 9e72ae7
Author: Robert Douglas <rdouglas@w2odigital.com>
Authored: Wed Aug 6 11:14:55 2014 -0500
Committer: Robert Douglas <rdouglas@w2odigital.com>
Committed: Wed Aug 6 11:14:55 2014 -0500

----------------------------------------------------------------------
 .../serializer/SyndEntryActivitySerializer.java | 31 ++++++++++++++++----
 1 file changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/6eb9707a/streams-contrib/streams-provider-rss/src/main/java/org/apache/streams/rss/serializer/SyndEntryActivitySerializer.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-rss/src/main/java/org/apache/streams/rss/serializer/SyndEntryActivitySerializer.java
b/streams-contrib/streams-provider-rss/src/main/java/org/apache/streams/rss/serializer/SyndEntryActivitySerializer.java
index 9edcd12..06839f3 100644
--- a/streams-contrib/streams-provider-rss/src/main/java/org/apache/streams/rss/serializer/SyndEntryActivitySerializer.java
+++ b/streams-contrib/streams-provider-rss/src/main/java/org/apache/streams/rss/serializer/SyndEntryActivitySerializer.java
@@ -178,12 +178,20 @@ public class SyndEntryActivitySerializer implements ActivitySerializer<ObjectNod
         if (entry.get("uri") != null)
             uri = entry.get("uri").textValue();
 
-        if (uri != null) {
-            if((uri.startsWith("http") || uri.startsWith("www")) || (link == null || !(link.startsWith("http")
|| link.startsWith("www")))) {
-                resourceLocation = uri;
-            } else {
-                resourceLocation = link;
-            }
+        /**
+         * Order of precedence for resourceLocation selection
+         *
+         * 1. Valid URI
+         * 2. Valid Link
+         * 3. Non-null URI
+         * 4. Non-null Link
+         */
+        if(isValidResource(uri))
+            resourceLocation = uri;
+        else if(isValidResource(link))
+            resourceLocation = link;
+        else if(uri != null || link != null) {
+            resourceLocation = (uri != null) ? uri : link;
         }
 
         provider.setId("id:providers:rss");
@@ -194,6 +202,17 @@ public class SyndEntryActivitySerializer implements ActivitySerializer<ObjectNod
     }
 
     /**
+     * Tests whether or not the passed in resource is a valid URI
+     * @param resource
+     * @return boolean of whether or not the resource is valid
+     */
+    private boolean isValidResource(String resource) {
+        if(resource != null && resource.startsWith("http") || resource.startsWith("www"))
+            return true;
+        return false;
+    }
+
+    /**
      * Given an RSS object and an existing activity,
      * add the Rome extension to that activity and return it
      *


Mime
View raw message