abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r619071 - in /incubator/abdera/java/trunk: dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
Date Wed, 06 Feb 2008 17:01:08 GMT
Author: jmsnell
Date: Wed Feb  6 09:01:05 2008
New Revision: 619071

URL: http://svn.apache.org/viewvc?rev=619071&view=rev
Log:
Add method to IRI to copy the current IRI with a trailing slash appended if the path does
not already contain a trailing slash..

  e.g. IRI iri = new IRI("/foo/bar");
       IRI ts = iri.trailingSlash();
       System.out.println(ts);
       Outputs: /foo/bar/
       
Submit patch for https://issues.apache.org/jira/browse/ABDERA-103, modified to use the new
trailingSlash method

Modified:
    incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java

Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java?rev=619071&r1=619070&r2=619071&view=diff
==============================================================================
--- incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java
(original)
+++ incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/iri/IRI.java
Wed Feb  6 09:01:05 2008
@@ -659,4 +659,22 @@
     UnicodeCharacterDatabase.getCanonicalClass(1);
     Nameprep.prep("");
   }
+  
+  /**
+   * Returns a new IRI with a trailing slash appended to the path, if necessary
+   */
+  public IRI trailingSlash() {
+    return new IRI(
+      _scheme,
+      scheme,
+      authority,
+      userinfo,
+      host,
+      port,
+      path.endsWith("/") ? path : path + "/",
+      query,
+      fragment
+    );
+  }
+   
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java?rev=619071&r1=619070&r2=619071&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
Wed Feb  6 09:01:05 2008
@@ -17,8 +17,6 @@
 */
 package org.apache.abdera.protocol.server.impl;
 
-import static org.apache.abdera.protocol.server.ProviderHelper.calculateEntityTag;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Date;
@@ -29,10 +27,9 @@
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.i18n.iri.IRI;
-import org.apache.abdera.model.AtomDate;
-import org.apache.abdera.i18n.text.Filter;
 import org.apache.abdera.i18n.text.UrlEncoding;
 import org.apache.abdera.i18n.text.CharUtils.Profile;
+import org.apache.abdera.model.AtomDate;
 import org.apache.abdera.model.Content;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
@@ -146,6 +143,7 @@
   }
 
   protected String getLink(String name, T entryObj, IRI feedIri, RequestContext request)
{
+    feedIri = feedIri.trailingSlash();
     IRI entryIri = feedIri.resolve(UrlEncoding.encode(name, Profile.PATH.filter()));
     
     String link = entryIri.toString();
@@ -302,11 +300,7 @@
 
   private IRI getFeedIRI(T entryObj, RequestContext request) {
     String feedIri = getFeedIriForEntry(entryObj, request);
-    if (!feedIri.endsWith("/")) {
-      feedIri += "/";
-    }
-    
-    return new IRI(feedIri);
+    return new IRI(feedIri).trailingSlash();
   }
   
   /**



Mime
View raw message