diff options
12 files changed, 98 insertions, 45 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/IArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/IArtifactRepositoryManager.java index ae95f295d..2ef8d2c91 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/IArtifactRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/provisional/p2/artifact/repository/IArtifactRepositoryManager.java @@ -19,8 +19,11 @@ import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; public interface IArtifactRepositoryManager { + public static final IArtifactRequest[] NO_ARTIFACT_REQUEST = new IArtifactRequest[0]; + /** * Constant used to indicate that all repositories are of interest. + * @see #getKnownRepositories(int) */ public static final int REPOSITORIES_ALL = 0; @@ -49,8 +52,6 @@ public interface IArtifactRepositoryManager { */ public static final String TYPE_SIMPLE_REPOSITORY = "org.eclipse.equinox.p2.artifact.repository.simpleRepository"; //$NON-NLS-1$ - public static final IArtifactRequest[] NO_ARTIFACT_REQUEST = new IArtifactRequest[0]; - /** * Adds a repository to the list of artifact repositories tracked by the repository * manager. @@ -88,6 +89,12 @@ public interface IArtifactRepositoryManager { /** * Creates and returns a new empty artifact repository of the given type at * the given location. + * <p> + * The resulting repository is <b>not</b> added to the list of repositories tracked by + * the repository manager. Clients must make a subsequent call to {@link #addRepository(URL)} + * if they want the repository manager to remember the repository for subsequent + * load attempts. + * </p> * * @param location the location for the new repository * @param name the name of the new repository @@ -152,6 +159,12 @@ public interface IArtifactRepositoryManager { * Loads the repository at the given location. The location is expected to contain * data that describes a valid artifact repository of a known type. If this manager * already knows a repository at the given location then that repository is returned. + * <p> + * The resulting repository is added to the list of repositories tracked by + * the repository manager. Clients must make a subsequent call to {@link #removeRepository(URL)} + * if they do not want the repository manager to remember the repository for subsequent + * load attempts. + * </p> * * @param location the location in which to look for a repository description * @param monitor a progress monitor, or <code>null</code> if progress diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java index 212efc46f..d79ea86ae 100644 --- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java +++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java @@ -45,7 +45,9 @@ public class ProvisioningHelper { // for convenience create and add a repository here String repositoryName = location + " - metadata"; //$NON-NLS-1$ try { - return manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + IMetadataRepository repository = manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repository.getLocation()); + return repository; } catch (ProvisionException e) { return null; } diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java index 3730b6986..e46fd55c5 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java @@ -80,6 +80,7 @@ public class FormerState { } try { IMetadataRepository repository = manager.createRepository(location, "Agent rollback repository", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); //$NON-NLS-1$ + manager.addRepository(repository.getLocation()); repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString()); return repository; } catch (ProvisionException e) { diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/p2/directorywatcher/ProvisioningListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/p2/directorywatcher/ProvisioningListener.java index ebbd16a96..1f29756d4 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/p2/directorywatcher/ProvisioningListener.java +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/p2/directorywatcher/ProvisioningListener.java @@ -186,6 +186,7 @@ public class ProvisioningListener extends DirectoryChangeListener { try { String repositoryName = location + " - metadata"; //$NON-NLS-1$ IMetadataRepository repository = manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repository.getLocation()); provider.setMetadataRepository(repository); } catch (ProvisionException e) { LogHelper.log(e); diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java index fbbe6605f..0ca452d0a 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java @@ -113,6 +113,7 @@ public class RepositoryListener extends DirectoryChangeListener { IArtifactRepository repository; if (hidden) { repository = manager.createRepository(stateDirURL, "artifact listener " + repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repository.getLocation()); repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString()); } else { repository = manager.createRepository(stateDirURL, repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY); diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/MetadataCache.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/MetadataCache.java index 2b1772a4e..8662540b0 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/MetadataCache.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/MetadataCache.java @@ -16,7 +16,8 @@ import java.util.EventObject; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.eventbus.*; +import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; +import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener; import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; import org.eclipse.equinox.internal.provisional.p2.engine.*; @@ -49,6 +50,7 @@ public class MetadataCache { } try { IMetadataRepository repository = manager.createRepository(location, REPOSITORY_NAME, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repository.getLocation()); repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString()); return repository; } catch (ProvisionException e) { diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/EclipseGeneratorApplication.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/EclipseGeneratorApplication.java index 503f845d4..3358763bf 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/EclipseGeneratorApplication.java +++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/EclipseGeneratorApplication.java @@ -169,6 +169,7 @@ public class EclipseGeneratorApplication implements IApplication { // TODO for now create a random repo by default. String repositoryName = metadataRepoName == null ? metadataLocation + " - metadata" : metadataRepoName; //$NON-NLS-1$ IMetadataRepository result = manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(result.getLocation()); if (result != null) { result.setProperty(IRepository.PROP_COMPRESSED, compress); if (metadataRepoName != null) diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java index aea481892..d8631a073 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java @@ -146,7 +146,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager { IMetadataRepository result = factory.create(location, name, type); if (result == null) fail(location, ProvisionException.REPOSITORY_FAILED_READ); - addRepository(result); + clearNotFound(location); return result; } @@ -336,6 +336,20 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager { } /** + * Clear the fact that we tried to load a repository at this location and did not find anything. + */ + private void clearNotFound(URL location) { + List badRepos; + if (unavailableRepositories != null) { + badRepos = (List) unavailableRepositories.get(); + if (badRepos != null) { + badRepos.remove(location); + return; + } + } + } + + /** * Cache the fact that we tried to load a repository at this location and did not find anything. */ private void rememberNotFound(URL location) { diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java index 0233acea5..545ecbd39 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java @@ -59,6 +59,12 @@ public interface IMetadataRepositoryManager extends IQueryable { /** * Creates and returns a new empty metadata repository of the given type at * the given location. + * <p> + * The resulting repository is <b>not</b> added to the list of repositories tracked by + * the repository manager. Clients must make a subsequent call to {@link #addRepository(URL)} + * if they want the repository manager to remember the repository for subsequent + * load attempts. + * </p> * * @param location the location for the new repository * @param name the name of the new repository @@ -98,7 +104,38 @@ public interface IMetadataRepositoryManager extends IQueryable { public URL[] getKnownRepositories(int flags); /** + * Returns the property associated with the repository at the given URL, + * without loading the repository. + * <p> + * Note that some properties for a repository can only be + * determined when that repository is loaded. This method will return <code>null</code> + * for such properties. Only values for the properties that are already + * known by a repository manager will be returned. + * <p> + * If a client wishes to retrieve a property value from a repository + * regardless of the cost of retrieving it, the client should load the + * repository and then retrieve the property from the repository itself. + * + * @param location the URL of the repository in question + * @param key the String key of the property desired + * @return the value of the property, or <code>null</code> if the repository + * does not exist, the value does not exist, or the property value + * could not be determined without loading the repository. + * + * @see #loadRepository(URL, IProgressMonitor) + * @see IRepository#getProperties() + * + */ + public String getRepositoryProperty(URL location, String key); + + /** * Loads a repository corresponding to the given URL. + * <p> + * The resulting repository is added to the list of repositories tracked by + * the repository manager. Clients must make a subsequent call to {@link #removeRepository(URL)} + * if they do not want the repository manager to remember the repository for subsequent + * load attempts. + * </p> * * @param location The location of the repository to load * @param monitor a progress monitor, or <code>null</code> if progress @@ -113,13 +150,24 @@ public interface IMetadataRepositoryManager extends IQueryable { public IMetadataRepository loadRepository(URL location, IProgressMonitor monitor) throws ProvisionException; /** + * Removes the metadata repository at the given location from the list of + * metadata repositories tracked by the repository manager. The underlying + * repository is not deleted. + * + * @param location The location of the repository to remove + * @return <code>true</code> if a repository was removed, and + * <code>false</code> otherwise. + */ + public boolean removeRepository(URL location); + + /** * Validates a given URL and returns a status indicating whether a valid repository is likely * to be found at the given URL. Callers must assume that the validity of a * repository location cannot be completely determined until an attempt to load * the repository is made. Implementors should make all attempts to validate * the URL without actually loading the repository. The computation for this - * method must be signficantly faster than that of loading the repository. - * Early detectable error conditions, such as the inexistence of the location, + * method must be significantly faster than that of loading the repository. + * Early detectable error conditions, such as the non-existence of the location, * or an inability to read the location, should be determined in this method. * * @param location The location of the repository to validate @@ -127,7 +175,7 @@ public interface IMetadataRepositoryManager extends IQueryable { * reporting is not desired * @return A status indicating whether a valid repository is likely located at the * location. A status with severity <code>OK</code> indicates that the repository is - * likely to be loadable, or that as much validation as could be done was done. + * likely to be loadable, or that as much validation as could be done was successful. * Reasons for a non-OK status include: * <ul> * <li>The specified location is not a valid repository location.</li> @@ -136,40 +184,4 @@ public interface IMetadataRepositoryManager extends IQueryable { * </ul> */ public IStatus validateRepositoryLocation(URL location, IProgressMonitor monitor); - - /** - * Removes the metadata repository at the given location from the list of - * metadata repositories tracked by the repository manager. The underlying - * repository is not deleted. - * - * @param location The location of the repository to remove - * @return <code>true</code> if a repository was removed, and - * <code>false</code> otherwise. - */ - public boolean removeRepository(URL location); - - /** - * Returns the property associated with the repository at the given URL, - * without loading the repository. - * <p> - * Note that some properties for a repository can only be - * determined when that repository is loaded. This method will return <code>null</code> - * for such properties. Only values for the properties that are already - * known by a repository manager will be returned. - * <p> - * If a client wishes to retrieve a property value from a repository - * regardless of the cost of retrieving it, the client should load the - * repository and then retrieve the property from the repository itself. - * - * @param location the URL of the repository in question - * @param key the String key of the property desired - * @return the value of the property, or <code>null</code> if the repository - * does not exist, the value does not exist, or the property value - * could not be determined without loading the repository. - * - * @see #loadRepository(URL, IProgressMonitor) - * @see IRepository#getProperties() - * - */ - public String getRepositoryProperty(URL location, String key); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLRepositoryTest.java index d6e3ad4a1..138c84dea 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLRepositoryTest.java @@ -67,7 +67,9 @@ public class JarURLRepositoryTest extends TestCase { deleteDirectory(testRepo); testRepo.mkdir(); provider.setFlavor("jartest"); - provider.setMetadataRepository(manager.createRepository(testRepo.toURL(), "testRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY)); + IMetadataRepository repository = manager.createRepository(testRepo.toURL(), "testRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repository.getLocation()); + provider.setMetadataRepository(repository); IStatus result = new Generator(provider).generate(); FileUtils.zip(new File[] {testRepo}, new File(tempDir, "testRepo.jar")); testRepoJar = new File(tempDir, "testRepo.jar"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java index be9396593..6c6b848b6 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java @@ -51,6 +51,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { public void testCompressedRepository() throws MalformedURLException, ProvisionException { IMetadataRepositoryManager manager = getMetadataRepositoryManager(); IMetadataRepository repo = manager.createRepository(repoLocation.toURL(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repo.getLocation()); repo.setProperty(IRepository.PROP_COMPRESSED, "true"); EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); provider.setMetadataRepository(repo); @@ -96,6 +97,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { public void testSetProperty() throws MalformedURLException, ProvisionException { IMetadataRepositoryManager manager = getMetadataRepositoryManager(); IMetadataRepository repo = manager.createRepository(repoLocation.toURL(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repo.getLocation()); Map properties = repo.getProperties(); assertTrue("1.0", !properties.containsKey(TEST_KEY)); repo.setProperty(TEST_KEY, TEST_VALUE); @@ -119,6 +121,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { public void testUncompressedRepository() throws MalformedURLException, ProvisionException { IMetadataRepositoryManager manager = getMetadataRepositoryManager(); IMetadataRepository repo = manager.createRepository(repoLocation.toURL(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(repo.getLocation()); repo.setProperty(IRepository.PROP_COMPRESSED, "false"); EclipseInstallGeneratorInfoProvider provider = new EclipseInstallGeneratorInfoProvider(); provider.setMetadataRepository(repo); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java index eb714af65..7ad00da1d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java @@ -71,6 +71,7 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { //create a new repository File repoLocation = getTempLocation(); IMetadataRepository testRepo = manager.createRepository(repoLocation.toURL(), "MetadataRepositoryManagerTest", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY); + manager.addRepository(testRepo.getLocation()); int newNonSystemCount = manager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_NON_SYSTEM).length; int newSystemCount = manager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_SYSTEM).length; int newAllCount = manager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL).length; |