Author: rwatler
Date: Wed Jan 27 16:25:22 2010
New Revision: 903711

URL: http://svn.apache.org/viewvc?rev=903711&view=rev
Log:
Replace '*.*' -> '*.psml' system mapping rule with hard coded mapping to reduce 
configuration requirements

Modified:
    
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
    
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml

Modified: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java?rev=903711&r1=903710&r2=903711&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
 (original)
+++ 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
 Wed Jan 27 16:25:22 2010
@@ -2,6 +2,7 @@
 
 import java.util.List;
 
+import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.portalsite.PortalSiteContentTypeMapper;
 
@@ -133,7 +134,24 @@
      */
     public String mapSystemRequestPath(String serverName, String contentType, 
String requestPath)
     {
-        return mapRequestPath(systemRequestPathMappings, serverName, 
contentType, requestPath);
+        String mappedSystemRequestPath = 
mapRequestPath(systemRequestPathMappings, serverName, contentType, requestPath);
+        if (mappedSystemRequestPath != null)
+        {
+            // replace or append page extension to mapped path
+            if (!mappedSystemRequestPath.endsWith(Page.DOCUMENT_TYPE) && 
!mappedSystemRequestPath.endsWith(Folder.PATH_SEPARATOR))
+            {
+                // strip existing extension
+                int lastPathSeparatorIndex = 
mappedSystemRequestPath.lastIndexOf(Folder.PATH_SEPARATOR_CHAR);
+                int lastExtensionSeparatorIndex = 
mappedSystemRequestPath.lastIndexOf('.');
+                if (lastExtensionSeparatorIndex > lastPathSeparatorIndex)
+                {
+                    mappedSystemRequestPath = 
mappedSystemRequestPath.substring(0, lastExtensionSeparatorIndex);
+                }
+                // append page extension
+                mappedSystemRequestPath += Page.DOCUMENT_TYPE;
+            }
+        }
+        return mappedSystemRequestPath;
     }
 
     /* (non-Javadoc)
@@ -178,20 +196,15 @@
     {
         if (requestPathMappings != null)
         {
-            boolean requestPathMapped = false;
             for (RequestPathMapping mapping : requestPathMappings)
             {
                 String mappedRequestPath = mapping.map(serverName, 
contentType, requestPath);
                 if ((mappedRequestPath != null) && 
!mappedRequestPath.equals(requestPath))
                 {
                     requestPath = mappedRequestPath;
-                    requestPathMapped = true;
                 }
             }
-            if (requestPathMapped)
-            {
-                return requestPath;
-            }
+            return requestPath;
         }
         return null;
     }

Modified: 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml?rev=903711&r1=903710&r2=903711&view=diff
==============================================================================
--- 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
 (original)
+++ 
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
 Wed Jan 27 16:25:22 2010
@@ -201,10 +201,6 @@
                    <constructor-arg 
index="0"><value>/preview/</value></constructor-arg>
                    <constructor-arg 
index="1"><value>/</value></constructor-arg>
                </bean>
-               <bean 
class="org.apache.jetspeed.portalsite.impl.RequestPathMapping">
-                   <constructor-arg 
index="0"><value>[.](\w+)&#36;</value></constructor-arg> <!-- use &#36; for '$' 
-->
-                   <constructor-arg 
index="1"><value>.psml</value></constructor-arg>
-               </bean>
            </list>
        </constructor-arg>
        <!-- external content path mapping -->



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to