diff options
Diffstat (limited to 'netx/net/sourceforge/jnlp/cache')
-rw-r--r-- | netx/net/sourceforge/jnlp/cache/CacheUtil.java | 29 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/cache/ResourceTracker.java | 38 |
2 files changed, 23 insertions, 44 deletions
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java index f2988f5..5e27b84 100644 --- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java +++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java @@ -18,25 +18,38 @@ package net.sourceforge.jnlp.cache; import static net.sourceforge.jnlp.runtime.Translator.R; -import java.io.*; -import java.net.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FilePermission; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; +import java.security.Permission; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Set; -import java.security.*; -import javax.jnlp.*; -import net.sourceforge.jnlp.*; +import javax.jnlp.DownloadServiceListener; + +import net.sourceforge.jnlp.Version; import net.sourceforge.jnlp.config.DeploymentConfiguration; -import net.sourceforge.jnlp.runtime.*; +import net.sourceforge.jnlp.runtime.ApplicationInstance; +import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.FileUtils; import net.sourceforge.jnlp.util.PropertiesFile; +import net.sourceforge.jnlp.util.UrlUtils; /** * Provides static methods to interact with the cache, download @@ -72,8 +85,8 @@ public class CacheUtil { return true; } try { - URL nu1 = ResourceTracker.normalizeUrl(u1, false); - URL nu2 = ResourceTracker.normalizeUrl(u2, false); + URL nu1 = UrlUtils.normalizeUrl(u1); + URL nu2 = UrlUtils.normalizeUrl(u2); if (notNullUrlEquals(nu1, nu2)) { return true; } diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java index 36ef3c6..dffbb3b 100644 --- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java +++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java @@ -50,6 +50,7 @@ import net.sourceforge.jnlp.event.DownloadEvent; import net.sourceforge.jnlp.event.DownloadListener; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.StreamUtils; +import net.sourceforge.jnlp.util.UrlUtils; import net.sourceforge.jnlp.util.WeakList; /** @@ -115,15 +116,6 @@ public class ResourceTracker { private static final int ERROR = Resource.ERROR; private static final int STARTED = Resource.STARTED; - // normalization of url - private static final char PATH_DELIMITER_MARK = '/'; - private static final String PATH_DELIMITER = "" + PATH_DELIMITER_MARK; - private static final char QUERY_DELIMITER_MARK = '&'; - private static final String QUERY_DELIMITER = "" + QUERY_DELIMITER_MARK; - private static final char QUERY_MARK = '?'; - private static final char HREF_MARK = '#'; - private static final String UTF8 = "utf-8"; - /** max threads */ private static final int maxThreads = 5; @@ -190,7 +182,7 @@ public class ResourceTracker { if (location == null) throw new IllegalResourceDescriptorException("location==null"); try { - location = normalizeUrl(location, JNLPRuntime.isDebug()); + location = UrlUtils.normalizeUrl(location); } catch (Exception ex) { System.err.println("Normalization of " + location.toString() + " have failed"); ex.printStackTrace(); @@ -1195,30 +1187,4 @@ public class ResourceTracker { // selectNextResource(); } }; - - public static URL normalizeUrl(URL u, boolean debug) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException { - if (u == null) { - return null; - } - String protocol = u.getProtocol(); - - if (protocol == null || "file".equals(protocol)) { - return u; - } - - if (u.getPath() == null) { - return u; - } - - //Decode the URL before encoding - URL decodedURL = new URL(URLDecoder.decode(u.toString(), UTF8)); - - //Create URI with the decoded URL - URI uri = new URI(decodedURL.getProtocol(), null, decodedURL.getHost(), decodedURL.getPort(), decodedURL.getPath(), decodedURL.getQuery(), null); - - //Returns the encoded URL - URL encodedURL = new URL(uri.toASCIIString()); - - return encodedURL; - } } |