shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mherma...@apache.org
Subject svn commit: r1099650 - in /shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/uri/DefaultJsUriManager.java main/java/org/apache/shindig/gadgets/uri/UriCommon.java test/java/org/apache/shindig/gadgets/uri/DefaultJsUriManagerTest.java
Date Thu, 05 May 2011 01:25:44 GMT
Author: mhermanto
Date: Thu May  5 01:25:43 2011
New Revision: 1099650

URL: http://svn.apache.org/viewvc?rev=1099650&view=rev
Log:
Add backward-compatible loaded functionality.
Add backward-compatible loaded functionality 

Modified:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsUriManager.java
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsUriManagerTest.java

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsUriManager.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsUriManager.java?rev=1099650&r1=1099649&r2=1099650&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsUriManager.java
(original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultJsUriManager.java
Thu May  5 01:25:43 2011
@@ -33,17 +33,22 @@ import org.apache.shindig.gadgets.http.H
 import org.apache.shindig.gadgets.uri.UriCommon.Param;
 
 import java.util.Collection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * Generates and validates URLs serviced by a gadget JavaScript service (JsServlet).
  */
 public class DefaultJsUriManager implements JsUriManager {
+  
   static final String JS_HOST_PARAM = "gadgets.uri.js.host";
   static final String JS_PATH_PARAM = "gadgets.uri.js.path";
   static final JsUri INVALID_URI = new JsUri(UriStatus.BAD_URI);
   protected static final String JS_SUFFIX = ".js";
   protected static final String JS_DELIMITER = ":";
 
+  private static final Logger LOG = Logger.getLogger(DefaultJsUriManager.class.getName());
+  
   private final ContainerConfig config;
   private final Versioner versioner;
 
@@ -176,7 +181,18 @@ public class DefaultJsUriManager impleme
 
     String[] splits = path.split("!");
     Collection<String> libs = getJsLibs(splits.length >= 1 ? splits[0] : "");
-    Collection<String> have = getJsLibs(splits.length >= 2 ? splits[1] : "");
+    
+    String haveString = (splits.length >= 2 ? splits[1] : "");
+    String haveQueryParam = uri.getQueryParameter(Param.LOADED.getKey());
+    if (haveQueryParam == null) {
+      haveQueryParam = "";
+    } else {
+      LOG.log(Level.WARNING, "Using deprecated query param ?loaded=c:d in URL. " +
+          "Replace by specifying it in path as /gadgets/js/a:b!c:d.js");
+    }
+    haveString = haveString + JS_DELIMITER + haveQueryParam;
+    Collection<String> have = getJsLibs(haveString);
+    
     UriStatus status = UriStatus.VALID_UNVERSIONED;
     String version = uri.getQueryParameter(Param.VERSION.getKey());
     if (version != null && versioner != null) {

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java?rev=1099650&r1=1099649&r2=1099650&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java
(original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java
Thu May  5 01:25:43 2011
@@ -50,6 +50,7 @@ public interface UriCommon {
     COMPILE_MODE("compile"),
     JSLOAD("jsload"),
     ONLOAD("onload"),
+    LOADED("loaded"),
     NO_HINT("nohint"),
     REPOSITORY_ID("r"),
 

Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsUriManagerTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsUriManagerTest.java?rev=1099650&r1=1099649&r2=1099650&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsUriManagerTest.java
(original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultJsUriManagerTest.java
Thu May  5 01:25:43 2011
@@ -251,6 +251,23 @@ public class DefaultJsUriManagerTest {
   }
 
   @Test
+  public void processPathWithLoadedJs() throws GadgetException {
+    ContainerConfig config = mockConfig("http://host", "/gadgets/js");
+    TestDefaultJsUriManager manager = makeManager(config, null);
+    Uri testUri = Uri.parse("http://host/gadgets/js/feature:another!load1:load2.js?" +
+        Param.LOADED.getKey() + "=load3:load4&" +
+        Param.CONTAINER.getKey() + '=' + CONTAINER);
+    JsUri jsUri = manager.processExternJsUri(testUri);
+    assertFalse(manager.hadError());
+    List<String> extern = Lists.newArrayList("feature", "another");
+    List<String> loadsInPath = Lists.newArrayList("load1", "load2");
+    List<String> loadsInQueryParam = Lists.newArrayList("load3", "load4");
+    assertCollectionEquals(jsUri.getLibs(), extern);
+    assertCollectionEquals(jsUri.getLoadedLibs(), Lists.newArrayList(
+        "load1", "load2", "load3", "load4"));
+  }
+
+  @Test
   public void processValidUnversionedNoVersioner() throws GadgetException {
     String targetHost = "target-host.org";
     ContainerConfig config = mockConfig("http://" + targetHost, "/gadgets/js");



Mime
View raw message