Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2008-04-23 14:57:01 +0000
committerJohn Arthorne2008-04-23 14:57:01 +0000
commit18be005aed89140ad668810ac9c1bd1c92b54e58 (patch)
treec65836fae06e4f99e5a9d55dedfddceb965e2761 /bundles
parent9100513781d3d518cd91b378ecfdda455a071816 (diff)
downloadrt.equinox.p2-18be005aed89140ad668810ac9c1bd1c92b54e58.tar.gz
rt.equinox.p2-18be005aed89140ad668810ac9c1bd1c92b54e58.tar.xz
rt.equinox.p2-18be005aed89140ad668810ac9c1bd1c92b54e58.zip
Bug 227383 UpdatesiteArtifactRepository is always unmodifiable
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/EclipseGeneratorApplication.java93
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java33
4 files changed, 92 insertions, 66 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
index 571e85661..f2e4c86a8 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java
@@ -184,12 +184,15 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme
}
public IArtifactRepository createRepository(URL location, String name, String type, Map properties) throws ProvisionException {
+ boolean loaded = false;
try {
- loadRepository(location, (IProgressMonitor) null);
- fail(location, ProvisionException.REPOSITORY_EXISTS);
+ loadRepository(location, (IProgressMonitor) null, type, true);
+ loaded = true;
} catch (ProvisionException e) {
//expected - fall through and create a new repository
}
+ if (loaded)
+ fail(location, ProvisionException.REPOSITORY_EXISTS);
IExtension extension = RegistryFactory.getRegistry().getExtension(Activator.REPO_PROVIDER_XPT, type);
if (extension == null)
fail(location, ProvisionException.REPOSITORY_UNKNOWN_TYPE);
@@ -224,8 +227,14 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, code, msg, null));
}
- private IExtension[] findMatchingRepositoryExtensions(String suffix) {
- IConfigurationElement[] elt = RegistryFactory.getRegistry().getConfigurationElementsFor(Activator.REPO_PROVIDER_XPT);
+ private IExtension[] findMatchingRepositoryExtensions(String suffix, String type) {
+ IConfigurationElement[] elt = null;
+ if (type != null && type.length() > 0) {
+ IExtension ext = RegistryFactory.getRegistry().getExtension(Activator.REPO_PROVIDER_XPT, type);
+ elt = (ext != null) ? ext.getConfigurationElements() : new IConfigurationElement[0];
+ } else {
+ elt = RegistryFactory.getRegistry().getConfigurationElementsFor(Activator.REPO_PROVIDER_XPT);
+ }
int count = 0;
for (int i = 0; i < elt.length; i++) {
if (EL_FILTER.equals(elt[i].getName())) {
@@ -362,10 +371,10 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme
}
public IArtifactRepository loadRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
- return loadRepository(location, monitor, true);
+ return loadRepository(location, monitor, null, true);
}
- private IArtifactRepository loadRepository(URL location, IProgressMonitor monitor, boolean signalAdd) throws ProvisionException {
+ private IArtifactRepository loadRepository(URL location, IProgressMonitor monitor, String type, boolean signalAdd) throws ProvisionException {
// TODO do something with the monitor
IArtifactRepository result = getRepository(location);
if (result != null)
@@ -375,7 +384,7 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme
String[] suffixes = getAllSuffixes();
SubMonitor sub = SubMonitor.convert(monitor, suffixes.length * 100);
for (int i = 0; i < suffixes.length; i++) {
- result = loadRepository(location, suffixes[i], sub.newChild(100));
+ result = loadRepository(location, suffixes[i], type, sub.newChild(100));
if (result != null) {
addRepository(result, signalAdd);
return result;
@@ -386,8 +395,8 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme
return null;
}
- private IArtifactRepository loadRepository(URL location, String suffix, SubMonitor monitor) {
- IExtension[] providers = findMatchingRepositoryExtensions(suffix);
+ private IArtifactRepository loadRepository(URL location, String suffix, String type, SubMonitor monitor) {
+ IExtension[] providers = findMatchingRepositoryExtensions(suffix, type);
// Loop over the candidates and return the first one that successfully loads
monitor.beginTask("", providers.length * 10); //$NON-NLS-1$
for (int i = 0; i < providers.length; i++)
@@ -456,7 +465,7 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme
clearNotFound(location);
if (!removeRepository(location))
fail(location, ProvisionException.REPOSITORY_NOT_FOUND);
- return loadRepository(location, monitor, false);
+ return loadRepository(location, monitor, null, false);
}
/*
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 a5a9d7fb6..b351b739e 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
@@ -103,33 +103,33 @@ public class EclipseGeneratorApplication implements IApplication {
} catch (MalformedURLException e) {
throw new IllegalArgumentException(NLS.bind(Messages.exception_artifactRepoLocationURL, artifactLocation));
}
- try {
- IArtifactRepository repository = manager.loadRepository(location, null);
- if (!repository.isModifiable())
- throw new IllegalArgumentException(NLS.bind(Messages.exception_artifactRepoNotWritable, location));
- provider.setArtifactRepository(repository);
- if (provider.reuseExistingPack200Files())
- repository.setProperty(PUBLISH_PACK_FILES_AS_SIBLINGS, "true"); //$NON-NLS-1$
- if (!provider.append())
- repository.removeAll();
- return;
- } catch (ProvisionException e) {
- //fall through and create a new repository
- }
- // the given repo location is not an existing repo so we have to create something
- // TODO for now create a Simple repo by default.
String repositoryName = artifactRepoName != null ? artifactRepoName : artifactLocation + " - artifacts"; //$NON-NLS-1$
Map properties = new HashMap(1);
properties.put(IRepository.PROP_COMPRESSED, compress);
if (provider.reuseExistingPack200Files())
properties.put(PUBLISH_PACK_FILES_AS_SIBLINGS, Boolean.TRUE.toString());
- IArtifactRepository result = manager.createRepository(location, repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
- manager.addRepository(result.getLocation());
- provider.setArtifactRepository(result);
- // TODO is this needed?
- if (artifactRepoName != null)
- result.setName(artifactRepoName);
+ IArtifactRepository result = null;
+ try {
+ result = manager.createRepository(location, repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
+ provider.setArtifactRepository(result);
+ // TODO is this needed?
+ if (artifactRepoName != null)
+ result.setName(artifactRepoName);
+ return;
+ } catch (ProvisionException e) {
+ //fall through a load existing repo
+ }
+
+ IArtifactRepository repository = manager.loadRepository(location, null);
+ if (!repository.isModifiable())
+ throw new IllegalArgumentException(NLS.bind(Messages.exception_artifactRepoNotWritable, location));
+ provider.setArtifactRepository(repository);
+ if (provider.reuseExistingPack200Files())
+ repository.setProperty(PUBLISH_PACK_FILES_AS_SIBLINGS, "true"); //$NON-NLS-1$
+ if (!provider.append())
+ repository.removeAll();
+ return;
}
public void initializeForInplace(EclipseInstallGeneratorInfoProvider provider) {
@@ -154,34 +154,39 @@ public class EclipseGeneratorApplication implements IApplication {
} catch (MalformedURLException e) {
throw new IllegalArgumentException(NLS.bind(Messages.exception_metadataRepoLocationURL, artifactLocation));
}
+
+ // First try to create a simple repo, this will fail if one already exists
+ // We try creating a repo first instead of just loading what is there because we don't want a repo based
+ // on a site.xml if there is one there.
+
+ String repositoryName = metadataRepoName == null ? metadataLocation + " - metadata" : metadataRepoName; //$NON-NLS-1$
+ Map properties = new HashMap(1);
+ properties.put(IRepository.PROP_COMPRESSED, compress);
+
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.context, IMetadataRepositoryManager.class.getName());
try {
- IMetadataRepository repository = manager.loadRepository(location, null);
- if (repository != null) {
- // don't set the compress flag here because we don't want to change the format
- // of an already existing repository
- if (!repository.isModifiable())
- throw new IllegalArgumentException(NLS.bind(Messages.exception_metadataRepoNotWritable, location));
- provider.setMetadataRepository(repository);
- if (!provider.append())
- repository.removeAll();
- return;
- }
+ IMetadataRepository result = manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null);
+ manager.addRepository(result.getLocation());
+ // TODO is this needed?
+ if (metadataRepoName != null)
+ result.setName(metadataRepoName);
+ provider.setMetadataRepository(result);
+ return;
} catch (ProvisionException e) {
- //fall through and create a new repository
+ //fall through and load the existing repo
}
- // the given repo location is not an existing repo so we have to create something
- // TODO for now create a random repo by default.
- String repositoryName = metadataRepoName == null ? metadataLocation + " - metadata" : metadataRepoName; //$NON-NLS-1$
- Map properties = new HashMap(1);
- properties.put(IRepository.PROP_COMPRESSED, compress);
- IMetadataRepository result = manager.createRepository(location, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null);
- manager.addRepository(result.getLocation());
- // TODO is this needed?
- if (metadataRepoName != null)
- result.setName(metadataRepoName);
- provider.setMetadataRepository(result);
+ IMetadataRepository repository = manager.loadRepository(location, null);
+ if (repository != null) {
+ // don't set the compress flag here because we don't want to change the format
+ // of an already existing repository
+ if (!repository.isModifiable())
+ throw new IllegalArgumentException(NLS.bind(Messages.exception_metadataRepoNotWritable, location));
+ provider.setMetadataRepository(repository);
+ if (!provider.append())
+ repository.removeAll();
+ return;
+ }
}
private void initializeRepositories(EclipseInstallGeneratorInfoProvider provider) throws ProvisionException {
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java
index 4be3b91b1..c8739941c 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/EclipseInstallGeneratorInfoProvider.java
@@ -275,7 +275,8 @@ public class EclipseInstallGeneratorInfoProvider implements IGeneratorInfo {
}
public String getFlavor() {
- return flavor;
+ //use 'tooling' as default flavor since we are not actively using flavors yet
+ return flavor == null ? "tooling" : flavor; //$NON-NLS-1$
}
private FrameworkAdmin getFrameworkAdmin() {
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 aa606efa7..0d8754663 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
@@ -191,13 +191,17 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
Assert.isNotNull(location);
Assert.isNotNull(name);
Assert.isNotNull(type);
+ boolean loaded = false;
try {
//repository should not already exist
- loadRepository(location, (IProgressMonitor) null);
- fail(location, ProvisionException.REPOSITORY_EXISTS);
+ loadRepository(location, (IProgressMonitor) null, type, true);
+ loaded = true;
} catch (ProvisionException e) {
//expected - fall through and create the new repository
}
+ if (loaded)
+ fail(location, ProvisionException.REPOSITORY_EXISTS);
+
IExtension extension = RegistryFactory.getRegistry().getExtension(Activator.REPO_PROVIDER_XPT, type);
if (extension == null)
fail(location, ProvisionException.REPOSITORY_UNKNOWN_TYPE);
@@ -239,8 +243,15 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
return new Status(IStatus.ERROR, Activator.ID, code, msg, null);
}
- private IExtension[] findMatchingRepositoryExtensions(String suffix) {
- IConfigurationElement[] elt = RegistryFactory.getRegistry().getConfigurationElementsFor(Activator.REPO_PROVIDER_XPT);
+ private IExtension[] findMatchingRepositoryExtensions(String suffix, String type) {
+ IConfigurationElement[] elt = null;
+ if (type != null && type.length() > 0) {
+ IExtension ext = RegistryFactory.getRegistry().getExtension(Activator.REPO_PROVIDER_XPT, type);
+ elt = (ext != null) ? ext.getConfigurationElements() : new IConfigurationElement[0];
+ } else {
+ elt = RegistryFactory.getRegistry().getConfigurationElementsFor(Activator.REPO_PROVIDER_XPT);
+ }
+
int count = 0;
for (int i = 0; i < elt.length; i++) {
if (elt[i].getName().equals("filter")) { //$NON-NLS-1$
@@ -377,10 +388,10 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
}
public IMetadataRepository loadRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
- return loadRepository(location, monitor, true);
+ return loadRepository(location, monitor, null, true);
}
- private IMetadataRepository loadRepository(URL location, IProgressMonitor monitor, boolean signalAdd) throws ProvisionException {
+ private IMetadataRepository loadRepository(URL location, IProgressMonitor monitor, String type, boolean signalAdd) throws ProvisionException {
Assert.isNotNull(location);
IMetadataRepository result = getRepository(location);
if (result != null)
@@ -392,7 +403,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
SubMonitor sub = SubMonitor.convert(monitor, Messages.repoMan_adding, suffixes.length * 100);
try {
for (int i = 0; i < suffixes.length; i++) {
- result = loadRepository(location, suffixes[i], sub.newChild(100), notFoundStatus);
+ result = loadRepository(location, suffixes[i], type, sub.newChild(100), notFoundStatus);
if (result != null) {
addRepository(result, signalAdd);
return result;
@@ -408,8 +419,8 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
/**
* Try to load a pre-existing repo at the given location
*/
- private IMetadataRepository loadRepository(URL location, String suffix, SubMonitor monitor, MultiStatus failures) {
- IExtension[] providers = findMatchingRepositoryExtensions(suffix);
+ private IMetadataRepository loadRepository(URL location, String suffix, String type, SubMonitor monitor, MultiStatus failures) {
+ IExtension[] providers = findMatchingRepositoryExtensions(suffix, type);
// Loop over the candidates and return the first one that successfully loads
monitor.beginTask("", providers.length * 10); //$NON-NLS-1$
for (int i = 0; i < providers.length; i++) {
@@ -514,7 +525,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
clearNotFound(location);
if (!removeRepository(location))
fail(location, ProvisionException.REPOSITORY_NOT_FOUND);
- return loadRepository(location, monitor, false);
+ return loadRepository(location, monitor, null, false);
}
/*
@@ -685,7 +696,7 @@ public class MetadataRepositoryManager implements IMetadataRepositoryManager, Pr
IStatus status = new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, NLS.bind(Messages.repoMan_notExists, location.toExternalForm()), null);
for (int i = 0; i < suffixes.length; i++) {
SubMonitor loopMonitor = sub.newChild(100);
- IExtension[] providers = findMatchingRepositoryExtensions(suffixes[i]);
+ IExtension[] providers = findMatchingRepositoryExtensions(suffixes[i], null);
// Loop over the candidates and return the first one that successfully loads
loopMonitor.beginTask("", providers.length * 10); //$NON-NLS-1$
for (int j = 0; j < providers.length; j++) {

Back to the top