You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by nl...@apache.org on 2004/11/25 04:44:55 UTC

svn commit: r106543 - /portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java

Author: nlothian
Date: Wed Nov 24 19:44:53 2004
New Revision: 106543

URL: http://svn.apache.org/viewcvs?view=rev&rev=106543
Log:
JIRA PLUTO-84: RenderResponse mime-type wildcard matching is not done. See http://nagoya.apache.org/jira/browse/PLUTO-84

Modified:
   portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java

Modified: portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java
Url: http://svn.apache.org/viewcvs/portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java?view=diff&rev=106543&p1=portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java&r1=106542&p2=portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java&r2=106543
==============================================================================
--- portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java	(original)
+++ portals/pluto/trunk/container/src/java/org/apache/pluto/core/impl/RenderResponseImpl.java	Wed Nov 24 19:44:53 2004
@@ -168,23 +168,32 @@
     private boolean isValidContentType(String type)
     {
         type = stripCharacterEncoding(type);
-        String wildcard = null;
-        int index = type.indexOf("/");
-        if(index > -1) {
-            wildcard = type.substring(0, index);
-        }
-
         PortletEntity entity = portletWindow.getPortletEntity();
         PortletDefinition def = entity.getPortletDefinition();
         ContentTypeSet contentTypes = def.getContentTypeSet();
         Iterator it = contentTypes.iterator();
         while(it.hasNext()) {
             ContentType ct = (ContentType)it.next();
-            if(ct.getContentType().equals(type)) {
-                return true;
-            }
-            else if(ct.getContentType().equals(wildcard)) {
+            String supportedType = ct.getContentType();
+            if (supportedType.equals(type)) {
                 return true;
+            } else if (supportedType.indexOf("*") >= 0) {                
+                // the supported type contains a wildcard
+                int index = supportedType.indexOf("/");
+                String supportedPrefix = supportedType.substring(0, index);
+                String supportedSuffix = supportedType.substring(index + 1, supportedType.length());
+                
+                index = type.indexOf("/");
+                String typePrefix = type.substring(0, index);
+                String typeSuffix = type.substring(index + 1, type.length());
+                                
+                if (supportedPrefix.equals("*") || supportedPrefix.equals(typePrefix)) {
+                    // the prefixes match
+                    if (supportedSuffix.equals("*") || supportedSuffix.equals(typeSuffix)) {
+                        // the suffixes match
+                        return true;
+                    }
+                }                
             }
         }
         return false;