Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java65
1 files changed, 39 insertions, 26 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java
index 11f73dee6..96de1e39d 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java
@@ -11,22 +11,25 @@
package org.eclipse.equinox.p2.internal.repository.tools;
import java.net.MalformedURLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.ICompositeRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.repository.ICompositeRepository;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.util.NLS;
public class CompositeRepositoryApplication extends AbstractApplication {
- private List childrenToAdd = new ArrayList();
- private List childrenToRemove = new ArrayList();
+ private List<RepositoryDescriptor> childrenToAdd = new ArrayList<RepositoryDescriptor>();
+ private List<RepositoryDescriptor> childrenToRemove = new ArrayList<RepositoryDescriptor>();
+ private boolean removeAllChildren = false;
private boolean failOnExists = false;
private String comparatorID = null;
@@ -34,30 +37,36 @@ public class CompositeRepositoryApplication extends AbstractApplication {
try {
initializeRepos(new NullProgressMonitor());
// load repository
- ICompositeRepository metadataRepo = (ICompositeRepository) destinationMetadataRepository;
+ ICompositeRepository<IInstallableUnit> metadataRepo = (ICompositeRepository<IInstallableUnit>) destinationMetadataRepository;
CompositeArtifactRepository artifactRepo = (CompositeArtifactRepository) destinationArtifactRepository;
- // Remove children from the Composite Repositories
- for (Iterator iterator = childrenToRemove.iterator(); iterator.hasNext();) {
- RepositoryDescriptor child = (RepositoryDescriptor) iterator.next();
- if (child.isArtifact() && artifactRepo != null)
- artifactRepo.removeChild(child.getOriginalRepoLocation());
- if (child.isMetadata() && metadataRepo != null)
- metadataRepo.removeChild(child.getOriginalRepoLocation());
+ if (removeAllChildren) {
+ if (artifactRepo != null)
+ artifactRepo.removeAllChildren();
+ if (metadataRepo != null)
+ metadataRepo.removeAllChildren();
+ } else {
+ // Remove children from the Composite Repositories
+ for (RepositoryDescriptor child : childrenToRemove) {
+ if (child.isArtifact() && artifactRepo != null)
+ artifactRepo.removeChild(child.getOriginalRepoLocation());
+ if (child.isMetadata() && metadataRepo != null)
+ metadataRepo.removeChild(child.getOriginalRepoLocation());
+ }
}
// Add children to the Composite Repositories
- for (Iterator iterator = childrenToAdd.iterator(); iterator.hasNext();) {
- RepositoryDescriptor child = (RepositoryDescriptor) iterator.next();
+ for (RepositoryDescriptor child : childrenToAdd) {
if (child.isArtifact() && artifactRepo != null)
artifactRepo.addChild(child.getOriginalRepoLocation());
if (child.isMetadata() && metadataRepo != null)
metadataRepo.addChild(child.getOriginalRepoLocation());
}
- if (comparatorID != null)
- if (!artifactRepo.validate(comparatorID))
- return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.CompositeRepositoryApplication_failedComparator, comparatorID));
+ if (comparatorID != null) {
+ ArtifactRepositoryValidator validator = new ArtifactRepositoryValidator(comparatorID);
+ return validator.validateComposite(artifactRepo);
+ }
return Status.OK_STATUS;
} finally {
finalizeRepositories();
@@ -72,6 +81,10 @@ public class CompositeRepositoryApplication extends AbstractApplication {
childrenToRemove.add(child);
}
+ public void setRemoveAll(boolean all) {
+ removeAllChildren = all;
+ }
+
public void setFailOnExists(boolean value) {
failOnExists = value;
}
@@ -155,8 +168,8 @@ public class CompositeRepositoryApplication extends AbstractApplication {
/*
* Determine if the repository is valid for this operation
*/
- private boolean validRepositoryLocation(IRepository repository) throws ProvisionException {
- if (repository instanceof ICompositeRepository) {
+ private boolean validRepositoryLocation(IRepository<?> repository) throws ProvisionException {
+ if (repository instanceof ICompositeRepository<?>) {
// if we have an already existing repository at that location, then throw an error
// if the user told us to
if (failOnExists)
@@ -171,7 +184,7 @@ public class CompositeRepositoryApplication extends AbstractApplication {
/*
* Initialize a new repository
*/
- private void initRepository(IRepository repository, RepositoryDescriptor desc) {
+ private void initRepository(IRepository<?> repository, RepositoryDescriptor desc) {
RepositoryHelper.validDestinationRepository(repository);
if (desc.isCompressed() && !repository.getProperties().containsKey(IRepository.PROP_COMPRESSED))
repository.setProperty(IRepository.PROP_COMPRESSED, String.valueOf(true));

Back to the top