Author: jasvir
Date: Thu Mar 11 01:28:28 2010
New Revision: 921658

URL: http://svn.apache.org/viewvc?rev=921658&view=rev
Log:
Description
* do not render type url gadgets if using caja since proxy url gadgets bypass
the entire rewriting stack including the cajoler


Added:
    shindig/trunk/java/server/src/test/resources/endtoend/failCajaUrlTest.xml
Modified:
    
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
    
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java

Modified: 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java?rev=921658&r1=921657&r2=921658&view=diff
==============================================================================
--- 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
 (original)
+++ 
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
 Thu Mar 11 01:28:28 2010
@@ -77,8 +77,12 @@ public class Renderer {
             "Requested: '" + gadget.getContext().getView() +
             "' Available: " + gadget.getSpec().getViews().keySet(), 
HttpServletResponse.SC_NOT_FOUND);
       }
-
+      
       if (gadget.getCurrentView().getType() == View.ContentType.URL) {
+        if (requiresCaja(gadget)) {
+          return RenderingResults.error("Caja does not support url type 
gadgets.",
+            HttpServletResponse.SC_BAD_REQUEST);
+        }
         return 
RenderingResults.mustRedirect(gadget.getCurrentView().getHref());
       }
 
@@ -106,6 +110,14 @@ public class Renderer {
   }
 
   /**
+   * Returns true iff the gadget opts into the caja or the container forces 
caja by flag
+   */
+  private boolean requiresCaja(Gadget gadget) {
+    return gadget.getSpec().getModulePrefs().getFeatures().containsKey("caja")
+        || "1".equals(gadget.getContext().getParameter("caja"));
+  }
+  
+  /**
    * Validates that the parent parameter was acceptable.
    *
    * @return True if the parent parameter is valid for the current container.

Modified: 
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java?rev=921658&r1=921657&r2=921658&view=diff
==============================================================================
--- 
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
 (original)
+++ 
shindig/trunk/java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
 Thu Mar 11 01:28:28 2010
@@ -24,6 +24,7 @@ import org.apache.shindig.common.JsonAss
 import org.apache.shindig.common.crypto.BlobCrypterException;
 
 import com.gargoylesoftware.htmlunit.CollectingAlertHandler;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
 import com.gargoylesoftware.htmlunit.Page;
 import com.gargoylesoftware.htmlunit.WebClient;
@@ -68,6 +69,7 @@ public class EndToEndTest {
     "jsonTest.xml",
     "cajaTest.xml",
     "failCajaTest.xml",      
+    "failCajaUrlTest.xml",      
     "osapi/personTest.xml",
     "osapi/peopleTest.xml",
     "osapi/activitiesTest.xml",
@@ -189,6 +191,15 @@ public class EndToEndTest {
   }
 
   @Test
+  public void testCajaFailUrlGadgets() throws Exception {
+    try {
+      HtmlPage page = executePageTest("failCajaUrlTest", null, /* caja */ 
true);
+    } catch (FailingHttpStatusCodeException e) {
+      assertEquals(HttpServletResponse.SC_BAD_REQUEST, e.getStatusCode());
+    }
+  }
+
+  @Test
   public void testPipelining() throws Exception {
     HtmlPage page = executePageTest("pipeliningTest", null);
     JSONArray array = new JSONArray(page.asText());

Added: shindig/trunk/java/server/src/test/resources/endtoend/failCajaUrlTest.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/java/server/src/test/resources/endtoend/failCajaUrlTest.xml?rev=921658&view=auto
==============================================================================
--- shindig/trunk/java/server/src/test/resources/endtoend/failCajaUrlTest.xml 
(added)
+++ shindig/trunk/java/server/src/test/resources/endtoend/failCajaUrlTest.xml 
Thu Mar 11 01:28:28 2010
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<Module>
+  <ModulePrefs title="EndToEndTest">
+  </ModulePrefs>
+  <Content type="url" href="http://www.example.com"; />
+</Module>


Reply via email to