diff options
author | John Arthorne | 2008-10-09 03:22:47 +0000 |
---|---|---|
committer | John Arthorne | 2008-10-09 03:22:47 +0000 |
commit | 773624727040c3a294359169f0f8d4aa22a7071d (patch) | |
tree | f51675a1f16deb759720dc7c3a4daa379935fdbd /bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox | |
parent | dfe94e43cf371e39d46b07c9f0e6c6b28eeb000e (diff) | |
download | rt.equinox.p2-773624727040c3a294359169f0f8d4aa22a7071d.tar.gz rt.equinox.p2-773624727040c3a294359169f0f8d4aa22a7071d.tar.xz rt.equinox.p2-773624727040c3a294359169f0f8d4aa22a7071d.zip |
Bug 237776 Replace URL by URI
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java index 72678305d..e2a966b56 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java @@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.p2.metadata.repository; import java.io.*; +import java.net.URI; import java.net.URL; import java.util.EventObject; import org.eclipse.core.runtime.*; @@ -41,9 +42,8 @@ public class CacheManager { /** * Returns a hash of the URL. */ - private int computeHash(URL repositoryLocation) { - //don't use URL#hashCode because it performs DNS lookups - return repositoryLocation.toExternalForm().hashCode(); + private int computeHash(URI repositoryLocation) { + return repositoryLocation.hashCode(); } /** @@ -57,17 +57,17 @@ public class CacheManager { * @throws IOException * @throws ProvisionException */ - public File createCache(URL repositoryLocation, IProgressMonitor monitor) throws IOException, ProvisionException { + public File createCache(URI repositoryLocation, IProgressMonitor monitor) throws IOException, ProvisionException { File cacheFile = getCache(repositoryLocation); - URL jarLocation = URLMetadataRepository.getActualLocation(repositoryLocation, JAR_EXTENSION); - URL xmlLocation = URLMetadataRepository.getActualLocation(repositoryLocation, XML_EXTENSION); + URI jarLocation = URLMetadataRepository.getActualLocation(repositoryLocation, JAR_EXTENSION); + URI xmlLocation = URLMetadataRepository.getActualLocation(repositoryLocation, XML_EXTENSION); AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$ File dataAreaFile = URLUtil.toFile(dataArea); int hashCode = computeHash(repositoryLocation); if (cacheFile == null || isCacheStale(repositoryLocation, cacheFile)) { long lastModifiedRemote = getTransport().getLastModified(jarLocation); - URL remoteFile; + URI remoteFile; if (lastModifiedRemote != 0) { cacheFile = new File(dataAreaFile, CONTENT_FILENAME + hashCode + JAR_EXTENSION); remoteFile = jarLocation; @@ -82,7 +82,7 @@ public class CacheManager { cacheFile.getParentFile().mkdirs(); OutputStream metadata = new BufferedOutputStream(new FileOutputStream(cacheFile)); try { - IStatus result = getTransport().download(remoteFile.toExternalForm(), metadata, monitor); + IStatus result = getTransport().download(remoteFile.toString(), metadata, monitor); if (!result.isOK()) { throw new ProvisionException(result); } @@ -97,7 +97,7 @@ public class CacheManager { * Deletes the local cache file for the given repository * @param repositoryLocation */ - void deleteCache(URL repositoryLocation) { + void deleteCache(URI repositoryLocation) { File cacheFile = getCache(repositoryLocation); if (cacheFile != null) safeDelete(cacheFile); @@ -109,7 +109,7 @@ public class CacheManager { * @return A {@link File} pointing to the cache file or <code>null</code> if * the cache file does not exist. */ - private File getCache(URL repositoryLocation) { + private File getCache(URI repositoryLocation) { AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$ File dataAreaFile = URLUtil.toFile(dataArea); @@ -144,10 +144,10 @@ public class CacheManager { * if the cache file is in sync with the repository. The cache file is * considered stale if there is no local cache file. */ - private boolean isCacheStale(URL repositoryLocation, File cacheFile) { + private boolean isCacheStale(URI repositoryLocation, File cacheFile) { long lastModified = cacheFile.lastModified(); String name = cacheFile.getName(); - URL metadataLocation = null; + URI metadataLocation = null; if (name.endsWith(XML_EXTENSION)) { metadataLocation = URLMetadataRepository.getActualLocation(repositoryLocation, XML_EXTENSION); } else if (name.endsWith(JAR_EXTENSION)) { |