Reviewers: johnfargo,
Description:
* do not render proxy url gadgets if using caja since proxy url gadgets
bypass the entire rewriting stack including the cajoler
Please review this at http://codereview.appspot.com/380041/show
Affected files:
M
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
M
java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
A java/server/src/test/resources/endtoend/failCajaUrlTest.xml
Index:
java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
===================================================================
---
java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
(revision 921049)
+++
java/server/src/test/java/org/apache/shindig/server/endtoend/EndToEndTest.java
(working copy)
@@ -68,6 +68,7 @@
"jsonTest.xml",
"cajaTest.xml",
"failCajaTest.xml",
+ "failCajaUrlTest.xml",
"osapi/personTest.xml",
"osapi/peopleTest.xml",
"osapi/activitiesTest.xml",
@@ -189,6 +190,21 @@
}
@Test
+ public void testCajaFailUrlGadgets() throws Exception {
+ HtmlPage page = executePageTest("failCajaUrlTest", null);
+ NodeList bodyList = page.getElementsByTagName("body");
+
+ // Result should contain just one body
+ assertEquals(1, bodyList.getLength());
+ DomNode body = (DomNode) bodyList.item(0);
+
+ // Failed output contains only an error message
+ assertEquals("Caja does not support url type gadgets.", body.asText());
+ assertEquals(0, body.getChildNodes().getLength());
+ assertEquals(Node.TEXT_NODE, body.getNodeType());
+ }
+
+ @Test
public void testPipelining() throws Exception {
HtmlPage page = executePageTest("pipeliningTest", null);
JSONArray array = new JSONArray(page.asText());
Index: java/server/src/test/resources/endtoend/failCajaUrlTest.xml
===================================================================
--- java/server/src/test/resources/endtoend/failCajaUrlTest.xml (revision 0)
+++ java/server/src/test/resources/endtoend/failCajaUrlTest.xml (revision 0)
@@ -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="proxyTest.html" />
+</Module>
Index:
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
===================================================================
---
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
(revision 921049)
+++
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
(working copy)
@@ -77,7 +77,14 @@
"Requested: '" + gadget.getContext().getView() +
"' Available: " + gadget.getSpec().getViews().keySet(),
HttpServletResponse.SC_NOT_FOUND);
}
-
+
+ if (gadget.getCurrentView().getType() == View.ContentType.URL &&
+
(gadget.getSpec().getModulePrefs().getFeatures().containsKey("caja") ||
+ "1".equals(gadget.getContext().getParameter("caja")))) {
+ return RenderingResults.error("Caja does not support url type
gadgets.",
+ HttpServletResponse.SC_BAD_REQUEST);
+ }
+
if (gadget.getCurrentView().getType() == View.ContentType.URL) {
return
RenderingResults.mustRedirect(gadget.getCurrentView().getHref());
}