Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2011-04-21 18:09:44 +0000
committerPascal Rapicault2011-04-21 18:09:44 +0000
commit03036d570e54be8c6aab5ccb0dfadb612ab4a253 (patch)
tree03f616085f4d8260410a04df79869e61c6f61783 /bundles/org.eclipse.equinox.p2.metadata.repository
parentb25650473f7a2ef13e0266581c4dd3abce497042 (diff)
downloadrt.equinox.p2-03036d570e54be8c6aab5ccb0dfadb612ab4a253.tar.gz
rt.equinox.p2-03036d570e54be8c6aab5ccb0dfadb612ab4a253.tar.xz
rt.equinox.p2-03036d570e54be8c6aab5ccb0dfadb612ab4a253.zip
Bug 312984 - [repository] Composite repo should have the ability to be marked in error if a child repo is badv20110421
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java63
1 files changed, 51 insertions, 12 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
index ab01e4b44..3b331a83b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
@@ -35,7 +35,10 @@ import org.eclipse.osgi.util.NLS;
public class CompositeMetadataRepository extends AbstractMetadataRepository implements ICompositeRepository<IInstallableUnit>, IIndexProvider<IInstallableUnit> {
static final public String REPOSITORY_TYPE = CompositeMetadataRepository.class.getName();
- public static final String PI_REPOSITORY_TYPE = "compositeMetadataRepository"; //$NON-NLS-1$
+ static final public String PI_REPOSITORY_TYPE = "compositeMetadataRepository"; //$NON-NLS-1$
+ static final public String PROP_ATOMIC_LOADING = "p2.atomic.composite.loading"; //$NON-NLS-1$
+ static final public boolean ATOMIC_LOADING_DEFAULT = false;
+
static final private Integer REPOSITORY_VERSION = new Integer(1);
static final public String XML_EXTENSION = ".xml"; //$NON-NLS-1$
static final private String JAR_EXTENSION = ".jar"; //$NON-NLS-1$
@@ -89,22 +92,25 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
return isLocal();
}
- CompositeMetadataRepository(IMetadataRepositoryManager manager, URI location, String name, Map<String, String> properties) {
- super(manager.getAgent(), name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$
- this.manager = manager;
- //when creating a repository, we must ensure it exists on disk so a subsequent load will succeed
- save();
- }
-
/*
* This is only called by the parser when loading a repository.
*/
- CompositeMetadataRepository(IMetadataRepositoryManager manager, CompositeRepositoryState state, IProgressMonitor monitor) {
+ CompositeMetadataRepository(IMetadataRepositoryManager manager, CompositeRepositoryState state, IProgressMonitor monitor) throws ProvisionException {
super(manager.getAgent(), state.getName(), state.getType(), state.getVersion(), state.getLocation(), state.getDescription(), state.getProvider(), state.getProperties());
this.manager = manager;
SubMonitor sub = SubMonitor.convert(monitor, 100 * state.getChildren().length);
+ List<URI> repositoriesToBeRemovedOnFailure = new ArrayList<URI>();
+ boolean failOnChildFailure = shouldFailOnChildFailure(state);
for (URI child : state.getChildren())
- addChild(child, false, sub.newChild(100));
+ addChild(child, false, sub.newChild(100), failOnChildFailure, repositoriesToBeRemovedOnFailure);
+
+ }
+
+ CompositeMetadataRepository(IMetadataRepositoryManager manager, URI location, String name, Map<String, String> properties) {
+ super(manager.getAgent(), name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$
+ this.manager = manager;
+ //when creating a repository, we must ensure it exists on disk so a subsequent load will succeed
+ save();
}
/*
@@ -141,7 +147,8 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
}
}
- private void addChild(URI childURI, boolean save, IProgressMonitor monitor) {
+ //successfully loaded repo will be added to the list repositoriesToBeRemovedOnFailure if the list is not null and the repo wasn't previously loaded
+ private void addChild(URI childURI, boolean save, IProgressMonitor monitor, boolean propagateException, List<URI> repositoriesToBeRemovedOnFailure) throws ProvisionException {
SubMonitor sub = SubMonitor.convert(monitor);
URI absolute = URIUtil.makeAbsolute(childURI, getLocation());
if (childrenURIs.contains(childURI) || childrenURIs.contains(absolute)) {
@@ -161,13 +168,21 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
getManager().setEnabled(absolute, false);
//set repository to system to hide from users
getManager().setRepositoryProperty(absolute, IRepository.PROP_SYSTEM, String.valueOf(true));
+ if (propagateException)
+ repositoriesToBeRemovedOnFailure.add(absolute);
}
currentRepo.compress(iuPool); // Share IUs across this CompositeMetadataRepository
// we successfully loaded the repo so remember it
loadedRepos.add(currentRepo);
+
} catch (ProvisionException e) {
//repository failed to load. fall through
LogHelper.log(e);
+ if (propagateException) {
+ removeFromRepoManager(repositoriesToBeRemovedOnFailure);
+ String msg = NLS.bind(Messages.io_failedRead, getLocation());
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, e));
+ }
}
}
@@ -175,7 +190,11 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
* @see org.eclipse.equinox.p2.repository.ICompositeRepository#addChild(java.net.URI)
*/
public void addChild(URI childURI) {
- addChild(childURI, true, null);
+ try {
+ addChild(childURI, true, null, false, null);
+ } catch (ProvisionException e) {
+ //already logged
+ }
}
/* (non-Javadoc)
@@ -377,4 +396,24 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
return null;
}
+ private void removeFromRepoManager(List<URI> currentLoadedRepositories) {
+ if (currentLoadedRepositories == null)
+ return;
+ for (URI loadedChild : currentLoadedRepositories) {
+ manager.removeRepository(loadedChild);
+ }
+ }
+
+ private boolean shouldFailOnChildFailure(CompositeRepositoryState state) {
+ Map<String, String> repoProperties = state.getProperties();
+ boolean failOnChildFailure = ATOMIC_LOADING_DEFAULT;
+ if (repoProperties != null) {
+ String value = repoProperties.get(PROP_ATOMIC_LOADING);
+ if (value != null) {
+ failOnChildFailure = Boolean.parseBoolean(value);
+ }
+ }
+ return failOnChildFailure;
+ }
+
}

Back to the top