Author: lresende
Date: Sun Apr  6 08:47:35 2008
New Revision: 645253

URL: http://svn.apache.org/viewvc?rev=645253&view=rev
Log:
TUSCANY-2202 - properly handling path when running in a web container 
environment

Modified:
    
incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java

Modified: 
incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java?rev=645253&r1=645252&r2=645253&view=diff
==============================================================================
--- 
incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
 (original)
+++ 
incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
 Sun Apr  6 08:47:35 2008
@@ -147,7 +147,7 @@
         // No authentication required for a get request
 
         // Get the request path
-        String path = 
URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()),
 "UTF-8");
+        String path = URLDecoder.decode(getPath(request), "UTF-8");
 
         logger.info(">>> FeedEndPointServlet " + request.getRequestURI());
 
@@ -320,7 +320,7 @@
         }
 
         // Get the request path
-        String path = 
URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()),
 "UTF-8");
+        String path = URLDecoder.decode(getPath(request), "UTF-8");
 
         if (path == null || path.length() == 0 || path.equals("/")) {
             org.apache.abdera.model.Entry createdFeedEntry = null;
@@ -426,7 +426,7 @@
         }
 
         // Get the request path
-        String path = 
request.getRequestURI().substring(request.getServletPath().length());
+        String path = URLDecoder.decode(getPath(request), "UTF-8");
 
         if (path != null && path.startsWith("/")) {
             String id = path.substring(1);
@@ -512,7 +512,7 @@
         }
 
         // Get the request path
-        String path = 
URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()),
 "UTF-8");
+        String path = URLDecoder.decode(getPath(request), "UTF-8");
 
         String id;
         if (path != null && path.startsWith("/")) {
@@ -533,6 +533,31 @@
                 throw new 
ServletException((Throwable)responseMessage.getBody());
             }
         }
+    }
+    
+    /**
+     * Retrieve the path considering embedded container and/or webapp container
+     * @param request
+     * @return
+     */
+    private String getPath(HttpServletRequest request) {
+       String path = null;
+
+       String requestURI = request.getRequestURI();
+       if(! requestURI.endsWith("/")) {
+               requestURI += "/";
+       }
+       
+       if(request.getContextPath() == null || 
request.getContextPath().length() == 0) {
+               //embedded container
+               path = 
request.getRequestURI().substring(request.getServletPath().length());
+       } else {
+               //web-container case... 
+               path = 
request.getRequestURI().substring(request.getContextPath().length() + 
request.getServletPath().length());                
+       }
+       
+       return path;
+       
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to