abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r601926 - in /incubator/abdera/java/trunk/extensions/sharing/src: main/java/org/apache/abdera/ext/sharing/History.java main/java/org/apache/abdera/ext/sharing/SharingHelper.java test/java/org/apache/abdera/test/ext/sharing/SharingTest.java
Date Fri, 07 Dec 2007 00:26:39 GMT
Author: jmsnell
Date: Thu Dec  6 16:26:38 2007
New Revision: 601926

URL: http://svn.apache.org/viewvc?rev=601926&view=rev
Log:
Update SSE impl per http://dev.live.com/feedsync/spec/v1.htm

Modified:
    incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/History.java
    incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/SharingHelper.java
    incubator/abdera/java/trunk/extensions/sharing/src/test/java/org/apache/abdera/test/ext/sharing/SharingTest.java

Modified: incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/History.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/History.java?rev=601926&r1=601925&r2=601926&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/History.java
(original)
+++ incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/History.java
Thu Dec  6 16:26:38 2007
@@ -69,6 +69,8 @@
   
   public void setBy(String by) {
     if (by != null) {
+      if (!SharingHelper.isValidEndpointIdentifier(by))
+        throw new IllegalArgumentException("Invalid Endpoint Identifier");
       setAttributeValue("by", by);
     } else {
       removeAttribute(new QName("by"));

Modified: incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/SharingHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/SharingHelper.java?rev=601926&r1=601925&r2=601926&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/SharingHelper.java
(original)
+++ incubator/abdera/java/trunk/extensions/sharing/src/main/java/org/apache/abdera/ext/sharing/SharingHelper.java
Thu Dec  6 16:26:38 2007
@@ -33,7 +33,7 @@
 
 public class SharingHelper {
 
-  public static final String SSENS = "http://www.microsoft.com/schemas/sse";
+  public static final String SSENS = "http://feedsync.org/2007/feedsync";
   public static final String SSEPFX = "sx";
   
   public static final QName SSE_SHARING = new QName(SSENS, "sharing", SSEPFX);
@@ -43,7 +43,6 @@
   public static final QName SSE_SYNC = new QName(SSENS, "sync", SSEPFX);
   public static final QName SSE_UNPUBLISHED = new QName(SSENS, "unpublished", SSEPFX);
   
-  
   protected static boolean isTrue(String value) {
     return value.equalsIgnoreCase("true") || 
            value.equals("1") || 
@@ -386,5 +385,64 @@
       }
     }
     return false;
+  }
+  
+  public static boolean isValidEndpointIdentifier(String id) {
+    if (id == null) return false;
+    char[] chars = id.toCharArray();
+    for (int i = 0; i < chars.length; i++) {
+      char c = chars[i];
+      if (!is_alphanum(c) && 
+          !is_reserved_or_other(c) && 
+          !is_hex(chars,i)) {
+        return false;
+      }
+    }
+    return true;
+  }
+  
+  private static boolean is_alphanum(char c) {
+    return (c >= 'a' && c <= 'z') || 
+           (c >= 'A' && c <= 'Z') || 
+           (c >= '0' && c <= '9'); 
+  }
+  
+  private static boolean is_reserved_or_other(char c) {
+    return c == '/' ||
+           c == '?' ||
+           c == '#' ||
+           c == '(' ||
+           c == ')' ||
+           c == '+' ||
+           c == ',' ||
+           c == '-' ||
+           c == '.' ||
+           c == ':' ||
+           c == '=' ||
+           c == '@' ||
+           c == ';' ||
+           c == '$' ||
+           c == '_' ||
+           c == '!' ||
+           c == '*' ||
+           c == '\'';
+  }
+
+  private static boolean is_hex(char[] chars, int i) {
+    if (chars[i] == '%') {
+      if (i + 2 > chars.length) return false;
+      return is_hex(chars[i],chars[i+1],chars[i+2]);
+    }
+    return false;
+  }
+  
+  private static boolean is_hexdigit(char c) {
+    return (c >= 'a' && c <= 'f') || 
+           (c >= 'A' && c <= 'F') || 
+           (c >= '0' && c <= '9'); 
+  }
+  
+  private static boolean is_hex(char c, char c2, char c3) {
+    return (c == '%' && is_hexdigit(c2) && is_hexdigit(c3));
   }
 }

Modified: incubator/abdera/java/trunk/extensions/sharing/src/test/java/org/apache/abdera/test/ext/sharing/SharingTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/sharing/src/test/java/org/apache/abdera/test/ext/sharing/SharingTest.java?rev=601926&r1=601925&r2=601926&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/sharing/src/test/java/org/apache/abdera/test/ext/sharing/SharingTest.java
(original)
+++ incubator/abdera/java/trunk/extensions/sharing/src/test/java/org/apache/abdera/test/ext/sharing/SharingTest.java
Thu Dec  6 16:26:38 2007
@@ -62,7 +62,7 @@
     
     String ex = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                 "<feed xmlns=\"http://www.w3.org/2005/Atom\" " +
-                "xmlns:sx=\"http://www.microsoft.com/schemas/sse\">" +
+                "xmlns:sx=\"http://feedsync.org/2007/feedsync\">" +
                 "<title>To Do List</title>" +
                 "<subtitle>A list of items to do</subtitle>" + 
                 "<link rel=\"self\" href=\"http://example.com/partial.xml\"/>" +



Mime
View raw message