changeset 8:5b479d60cadb

Enabled parsing jnlp file located at jnlp_href for applet parameters.
author Andrew Su <asu@redhat.com>
date Wed, 20 Oct 2010 10:17:46 -0400
parents 3b526d8b7bb2
children cc9fbbbe8865
files ChangeLog netx/net/sourceforge/jnlp/PluginBridge.java
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Oct 20 16:07:09 2010 +0200
+++ b/ChangeLog	Wed Oct 20 10:17:46 2010 -0400
@@ -1,3 +1,9 @@
+2010-10-20  Andrew Su  <asu@redhat.com>
+
+	* PluginBridge.java:
+	(PluginBridge): Added parsing for jnlp_href, and reading the jnlp file
+	for applet parameters.
+
 2010-10-20  Matthias Klose  <doko@ubuntu.com>
 
 	* Makefile.am (stamps/extra-class-files.stamp): Fix -sourcepath.
--- a/netx/net/sourceforge/jnlp/PluginBridge.java	Wed Oct 20 16:07:09 2010 +0200
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java	Wed Oct 20 10:17:46 2010 -0400
@@ -26,9 +26,11 @@
 import java.net.MalformedURLException;
 import java.util.Calendar;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.Locale;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Map;
 
 import net.sourceforge.jnlp.runtime.JNLPRuntime;
 
@@ -50,6 +52,26 @@
         fileVersion = new Version("1.1");
         this.codeBase = codebase;
         this.sourceLocation = documentBase;
+        
+        if (atts.containsKey("jnlp_href")){
+            try {
+                URL jnlp = new URL(codeBase.toExternalForm() + (String) atts.get("jnlp_href"));
+                JNLPFile jnlp_file = new JNLPFile(jnlp);
+                Map jnlp_params = jnlp_file.getApplet().getParameters();
+                
+                // Change the parameter name to lowercase to follow conventions.
+                Iterator it = jnlp_params.keySet().iterator();
+                while(it.hasNext()){
+                    String key = (String) it.next();
+                    atts.put(key.toLowerCase(), jnlp_params.get(key));
+                }
+            } catch (MalformedURLException e) {
+                // Don't fail because we cannot get the jnlp file. Parameters are optional not required.
+                // it is the site developer who should ensure that file exist.
+                System.err.println("Unable to get JNLP file at: " + codeBase.toExternalForm() 
+                        + (String) atts.get("jnlp_href"));
+            }
+        }
 
         // also, see if cache_archive is specified
         if (atts.get("cache_archive") != null && ((String) atts.get("cache_archive")).length() > 0) {