changeset 1312:3b8609a88eaf

2009-01-13 Omair Majid <omajid@redhat.com> * rt/net/sourceforge/jnlp/cache/ResourceTracker.java (downloadResource): Call getVersionedResourceURL to get the versioned jar. (initializeResource): Likewise. (getVersionedResourceURL): New function. Constructs a URL with a version-id as the query.
author Omair Majid <omajid@redhat.com>
date Tue, 13 Jan 2009 22:27:58 -0500
parents fe32914531b8
children 9ecdf73ae0e1
files ChangeLog rt/net/sourceforge/jnlp/cache/ResourceTracker.java
diffstat 2 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jan 13 08:30:52 2009 -0500
+++ b/ChangeLog	Tue Jan 13 22:27:58 2009 -0500
@@ -1,3 +1,11 @@
+2009-01-13  Omair Majid  <omajid@redhat.com>
+
+	* rt/net/sourceforge/jnlp/cache/ResourceTracker.java
+	(downloadResource): Call getVersionedResourceURL to get the versioned jar.
+	(initializeResource): Likewise.
+	(getVersionedResourceURL): New function. Constructs a URL with a
+	version-id as the query.
+
 2009-01-13  Gary Benson  <gbenson@redhat.com>
 
 	* contrib/jck/compile-native-code.sh: Build with -m32 or -m64.
--- a/rt/net/sourceforge/jnlp/cache/ResourceTracker.java	Tue Jan 13 08:30:52 2009 -0500
+++ b/rt/net/sourceforge/jnlp/cache/ResourceTracker.java	Tue Jan 13 22:27:58 2009 -0500
@@ -605,7 +605,7 @@
 
         try {
             // create out second in case in does not exist
-            URLConnection con = resource.location.openConnection();
+            URLConnection con = getVersionedResourceURL(resource).openConnection();
             InputStream in = new BufferedInputStream(con.getInputStream());
             OutputStream out = CacheUtil.getOutputStream(resource.location, resource.downloadVersion);
             byte buf[] = new byte[1024];
@@ -652,7 +652,7 @@
             File localFile = CacheUtil.getCacheFile(resource.location, resource.downloadVersion);
 
             // connect
-            URLConnection connection = resource.location.openConnection(); // this won't change so should be okay unsynchronized
+            URLConnection connection = getVersionedResourceURL(resource).openConnection(); // this won't change so should be okay unsynchronized
             int size = connection.getContentLength();
             boolean current = CacheUtil.isCurrent(resource.location, resource.requestVersion, connection) && resource.getUpdatePolicy() != UpdatePolicy.FORCE;
 
@@ -696,6 +696,29 @@
         }
     }
 
+    
+ 
+    private URL getVersionedResourceURL(Resource resource) {
+        String actualLocation = resource.location.getProtocol() + "://"
+                + resource.location.getHost();
+        if (resource.location.getPort() != -1) {
+            actualLocation += ":" + resource.location.getPort();
+        }
+        actualLocation += resource.location.getPath();
+        if (resource.requestVersion != null
+                && resource.requestVersion.isVersionId()) {
+            actualLocation += "?version-id=" + resource.requestVersion;
+        }
+        URL versionedURL;
+        try {
+            versionedURL = new URL(actualLocation);
+        } catch (MalformedURLException e) {
+            return resource.location;
+        }
+        return versionedURL;
+    }
+ 
+    
     /**
      * Pick the next resource to download or initialize.  If there
      * are no more resources requested then one is taken from a