abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r631351 - in /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server: ProviderHelper.java RequestContext.java context/AbstractRequestContext.java context/RequestContextWrapper.java
Date Tue, 26 Feb 2008 19:35:00 GMT
Author: jmsnell
Date: Tue Feb 26 11:34:56 2008
New Revision: 631351

URL: http://svn.apache.org/viewvc?rev=631351&view=rev
Log:
Minor utility method updates

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java?rev=631351&r1=631350&r2=631351&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java
Tue Feb 26 11:34:56 2008
@@ -582,4 +582,39 @@
       }
      return editUri;
   }
+  
+  public static String[] getAcceptableTypes(
+    RequestContext request) {
+      String accept = request.getAccept();
+      return orderByQ(accept);
+  }
+  
+  public static boolean isPreferred(
+    RequestContext request,
+    String s1,
+    String s2) {
+      return isPreferred(
+        getAcceptableTypes(request),
+        s1,s2);
+  }
+  
+  public static boolean isPreferred(
+    String[] accepts, 
+    String s1, 
+    String s2) {
+      int i1 = accepts.length, i2 = accepts.length;
+      for (int n = 0; n < accepts.length; n++) {
+        if (MimeTypeHelper.isMatch(s1, accepts[n])) {
+          i1 = n;
+          break;
+        }
+      }
+      for (int n = 0; n < accepts.length; n++) {
+        if (MimeTypeHelper.isMatch(s2, accepts[n])) {
+          i2 = n;
+          break;
+        }
+      }
+      return i1 < i2;
+  }
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java?rev=631351&r1=631350&r2=631351&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
Tue Feb 26 11:34:56 2008
@@ -237,4 +237,6 @@
    * are resolved against the base URI 
    */
   String absoluteUrlFor(Object key, Object param);
+  
+  boolean isAtom();
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java?rev=631351&r1=631350&r2=631351&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
Tue Feb 26 11:34:56 2008
@@ -36,6 +36,7 @@
 import org.apache.abdera.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.impl.SimpleTarget;
 import org.apache.abdera.protocol.util.AbstractRequest;
+import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -188,5 +189,13 @@
     Object param) {
       return getResolvedUri().resolve(
         urlFor(key,param)).toString();
+  }
+  
+  public boolean isAtom() {
+    try {
+      return MimeTypeHelper.isAtom(getContentType().toString());
+    } catch (Exception e) {
+      return false;
     }
+  }
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java?rev=631351&r1=631350&r2=631351&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java
Tue Feb 26 11:34:56 2008
@@ -289,5 +289,9 @@
       return request.getResolvedUri().resolve(
         urlFor(key,param)).toString();
   }
+
+  public boolean isAtom() {
+    return request.isAtom();
+  }
   
 }



Mime
View raw message