Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileMetadataRepository.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationMetadataRepository.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRepositoryReference.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/artifacts.xml28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/content.xml337
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepository.java12
24 files changed, 668 insertions, 148 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileMetadataRepository.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileMetadataRepository.java
index d2b122232..bfa0a431d 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileMetadataRepository.java
@@ -15,6 +15,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
@@ -26,6 +27,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
import org.eclipse.osgi.util.NLS;
@@ -151,6 +153,10 @@ public class ProfileMetadataRepository extends AbstractMetadataRepository {
return p2EngineDirectory.getParentFile();
}
+ public Collection<IRepositoryReference> getReferences() {
+ return CollectionUtils.emptyList();
+ }
+
public void initialize(RepositoryState state) {
// nothing to do
}
diff --git a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationMetadataRepository.java b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationMetadataRepository.java
index d742fc6b4..5164245e9 100644
--- a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationMetadataRepository.java
@@ -16,11 +16,13 @@ import java.io.FilenameFilter;
import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
import org.eclipse.osgi.util.NLS;
@@ -89,6 +91,13 @@ public class ExtensionLocationMetadataRepository extends AbstractMetadataReposit
}
/* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#getReferences()
+ */
+ public Collection<IRepositoryReference> getReferences() {
+ return CollectionUtils.emptyList();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#addInstallableUnits(java.util.Collection)
*/
@Override
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
index 15061a752..abd3f423f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/META-INF/MANIFEST.MF
@@ -16,7 +16,8 @@ Export-Package: org.eclipse.equinox.internal.p2.metadata.generator;x-internal:=t
org.eclipse.equinox.p2.updatesite"
Require-Bundle: org.eclipse.equinox.p2.core,
org.eclipse.osgi,
- org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)"
+ org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.equinox.p2.repository
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-ActivationPolicy: lazy
Import-Package: javax.xml.parsers,
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
index 252e362b5..ded920211 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
@@ -37,6 +37,7 @@ import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.osgi.service.resolver.*;
import org.eclipse.osgi.util.NLS;
@@ -1137,8 +1138,10 @@ public class Generator {
try {
URI associateLocation = URIUtil.fromString(location);
int flags = isEnabled ? IRepository.ENABLED : IRepository.NONE;
- metadataRepo.addReference(associateLocation, name, IRepository.TYPE_METADATA, flags);
- metadataRepo.addReference(associateLocation, name, IRepository.TYPE_ARTIFACT, flags);
+ ArrayList refs = new ArrayList();
+ refs.add(new RepositoryReference(associateLocation, name, IRepository.TYPE_METADATA, flags));
+ refs.add(new RepositoryReference(associateLocation, name, IRepository.TYPE_ARTIFACT, flags));
+ metadataRepo.addReferences(refs);
} catch (URISyntaxException e) {
String message = "Invalid site reference: " + location; //$NON-NLS-1$
if (featureId != null)
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 8765d5258..53e674ba9 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
@@ -25,8 +25,7 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.*;
-import org.eclipse.equinox.p2.repository.ICompositeRepository;
-import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
@@ -262,10 +261,23 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
return getActualLocation(location, XML_EXTENSION);
}
- public synchronized void addReference(URI repositoryLocation, int repositoryType, int options) {
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository#addReferences(java.util.Collection)
+ */
+ public synchronized void addReferences(Collection<? extends IRepositoryReference> references) {
throw new UnsupportedOperationException("Cannot add References to a composite repository"); //$NON-NLS-1$
}
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#getReferences()
+ */
+ public Collection<IRepositoryReference> getReferences() {
+ HashSet<IRepositoryReference> allRefs = new HashSet<IRepositoryReference>();
+ for (IMetadataRepository child : loadedRepos)
+ allRefs.addAll(child.getReferences());
+ return allRefs;
+ }
+
// caller should be synchronized
private void save() {
if (!isModifiable())
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
index e6ee44651..335b1d44b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
@@ -32,9 +32,9 @@ import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
-import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
/**
* A metadata repository that resides in the local file system. If the repository
@@ -50,7 +50,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
static final private String XML_EXTENSION = ".xml"; //$NON-NLS-1$
protected IUMap units = new IUMap();
- protected HashSet<RepositoryReference> repositories = new HashSet<RepositoryReference>();
+ protected HashSet<IRepositoryReference> repositories = new HashSet<IRepositoryReference>();
private IIndex<IInstallableUnit> idIndex;
private IIndex<IInstallableUnit> capabilityIndex;
private TranslationSupport translationSupport;
@@ -113,12 +113,20 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
}
/* (non-Javadoc)
- * @see org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository#addReference(java.net.URI, java.lang.String, int, int)
+ * @see org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository#addReferences(java.util.Collection)
*/
@Override
- public synchronized void addReference(URI repositoryLocation, String nickname, int repositoryType, int options) {
+ public void addReferences(Collection<? extends IRepositoryReference> references) {
assertModifiable();
- repositories.add(new RepositoryReference(repositoryLocation, nickname, repositoryType, options));
+ repositories.addAll(references);
+ save();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#getReferences()
+ */
+ public Collection<IRepositoryReference> getReferences() {
+ return Collections.unmodifiableCollection(repositories);
}
/* (non-Javadoc)
@@ -178,17 +186,17 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
if (bus == null)
return;
- List<RepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot();
- for (RepositoryReference reference : repositoriesSnapshot) {
- boolean isEnabled = (reference.Options & IRepository.ENABLED) != 0;
- bus.publishEvent(new RepositoryEvent(reference.Location, reference.Type, RepositoryEvent.DISCOVERED, isEnabled));
+ List<IRepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot();
+ for (IRepositoryReference reference : repositoriesSnapshot) {
+ boolean isEnabled = (reference.getOptions() & IRepository.ENABLED) != 0;
+ bus.publishEvent(new RepositoryEvent(reference.getLocation(), reference.getType(), RepositoryEvent.DISCOVERED, isEnabled));
}
}
- private synchronized List<RepositoryReference> createRepositoriesSnapshot() {
+ private synchronized List<IRepositoryReference> createRepositoriesSnapshot() {
if (repositories.isEmpty())
return CollectionUtils.emptyList();
- return new ArrayList<RepositoryReference>(repositories);
+ return new ArrayList<IRepositoryReference>(repositories);
}
// use this method to setup any transient fields etc after the object has been restored from a stream
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
index ad449afa0..afd6a7c4f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
@@ -11,8 +11,11 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
+
import org.eclipse.equinox.p2.query.QueryUtil;
+
import java.io.*;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
@@ -32,7 +35,6 @@ import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository.RepositoryState;
-import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.xml.sax.*;
@@ -140,7 +142,7 @@ public class MetadataRepositoryIO {
writeProperties(repository.getProperties());
if (repository instanceof LocalMetadataRepository) {
- Set<RepositoryReference> references = ((LocalMetadataRepository) repository).repositories;
+ Set<IRepositoryReference> references = ((LocalMetadataRepository) repository).repositories;
writeRepositoryReferences(references.iterator(), references.size());
}
// The size attribute is a problematic since it forces the use of a collection.
@@ -152,11 +154,11 @@ public class MetadataRepositoryIO {
}
/**
- * Writes a list of {@link RepositoryReference}.
- * @param references An Iterator of {@link RepositoryReference}.
+ * Writes a list of {@link IRepositoryReference}.
+ * @param references An Iterator of {@link IRepositoryReference}.
* @param size The number of references to write
*/
- protected void writeRepositoryReferences(Iterator<RepositoryReference> references, int size) {
+ protected void writeRepositoryReferences(Iterator<IRepositoryReference> references, int size) {
if (size == 0)
return;
start(REPOSITORY_REFERENCES_ELEMENT);
@@ -166,20 +168,20 @@ public class MetadataRepositoryIO {
end(REPOSITORY_REFERENCES_ELEMENT);
}
- private void writeRepositoryReference(RepositoryReference reference) {
+ private void writeRepositoryReference(IRepositoryReference reference) {
start(REPOSITORY_REFERENCE_ELEMENT);
- attribute(URI_ATTRIBUTE, reference.Location.toString());
+ attribute(URI_ATTRIBUTE, reference.getLocation().toString());
try {
// we write the URL attribute for backwards compatibility with 3.4.x
// this attribute should be removed if we make a breaking format change.
- attribute(URL_ATTRIBUTE, URIUtil.toURL(reference.Location).toExternalForm());
+ attribute(URL_ATTRIBUTE, URIUtil.toURL(reference.getLocation()).toExternalForm());
} catch (MalformedURLException e) {
- attribute(URL_ATTRIBUTE, reference.Location.toString());
+ attribute(URL_ATTRIBUTE, reference.getLocation().toString());
}
- attribute(TYPE_ATTRIBUTE, Integer.toString(reference.Type));
- attribute(OPTIONS_ATTRIBUTE, Integer.toString(reference.Options));
+ attribute(TYPE_ATTRIBUTE, Integer.toString(reference.getType()));
+ attribute(OPTIONS_ATTRIBUTE, Integer.toString(reference.getOptions()));
end(REPOSITORY_REFERENCE_ELEMENT);
}
}
@@ -309,7 +311,7 @@ public class MetadataRepositoryIO {
: propertiesHandler.getProperties());
state.Units = (unitsHandler == null ? new IInstallableUnit[0] //
: unitsHandler.getUnits());
- state.Repositories = repositoryReferencesHandler == null ? new RepositoryReference[0] : repositoryReferencesHandler.getReferences();
+ state.Repositories = repositoryReferencesHandler == null ? new IRepositoryReference[0] : repositoryReferencesHandler.getReferences();
Object repositoryObject = null;
//can't create repository if missing type - this is already logged when parsing attributes
if (state.Type == null)
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
index 522eeb043..04cd5ee32 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
@@ -13,10 +13,10 @@
package org.eclipse.equinox.internal.p2.metadata.repository;
import java.net.URI;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.equinox.internal.p2.metadata.index.*;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
@@ -26,6 +26,7 @@ import org.eclipse.equinox.p2.metadata.index.IIndex;
import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
/**
@@ -34,6 +35,7 @@ import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository
public class URLMetadataRepository extends AbstractMetadataRepository implements IIndexProvider<IInstallableUnit> {
public static final String CONTENT_FILENAME = "content"; //$NON-NLS-1$
+ protected Collection<IRepositoryReference> references;
public static final String XML_EXTENSION = ".xml"; //$NON-NLS-1$
private static final String REPOSITORY_TYPE = URLMetadataRepository.class.getName();
private static final Integer REPOSITORY_VERSION = new Integer(1);
@@ -77,6 +79,7 @@ public class URLMetadataRepository extends AbstractMetadataRepository implements
this.location = state.Location;
this.properties = state.Properties;
this.units.addAll(state.Units);
+ this.references = CollectionUtils.unmodifiableList(state.Repositories);
}
// Use this method to setup any transient fields etc after the object has been restored from a stream
@@ -85,6 +88,10 @@ public class URLMetadataRepository extends AbstractMetadataRepository implements
content = getActualLocation(location);
}
+ public Collection<IRepositoryReference> getReferences() {
+ return references;
+ }
+
public boolean isModifiable() {
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
index 77c5b1679..2138adc1a 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
@@ -12,9 +12,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.io;
-import org.eclipse.equinox.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.*;
-
import java.net.URI;
import java.util.*;
import java.util.Map.Entry;
@@ -22,8 +19,12 @@ import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.persistence.XMLParser;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitPatchDescription;
import org.eclipse.equinox.p2.metadata.expression.ExpressionParseException;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
@@ -50,11 +51,11 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
protected class RepositoryReferencesHandler extends AbstractMetadataHandler {
- private HashSet<RepositoryReference> references;
+ private HashSet<IRepositoryReference> references;
public RepositoryReferencesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, REPOSITORY_REFERENCES_ELEMENT);
- references = new HashSet<RepositoryReference>(getOptionalSize(attributes, 4));
+ references = new HashSet<IRepositoryReference>(getOptionalSize(attributes, 4));
}
public void startElement(String name, Attributes attributes) {
@@ -65,8 +66,8 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- public RepositoryReference[] getReferences() {
- return references.toArray(new RepositoryReference[references.size()]);
+ public IRepositoryReference[] getReferences() {
+ return references.toArray(new IRepositoryReference[references.size()]);
}
}
@@ -74,7 +75,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
private final String[] required = new String[] {TYPE_ATTRIBUTE, OPTIONS_ATTRIBUTE};
- public RepositoryReferenceHandler(AbstractHandler parentHandler, Attributes attributes, Set<RepositoryReference> references) {
+ public RepositoryReferenceHandler(AbstractHandler parentHandler, Attributes attributes, Set<IRepositoryReference> references) {
super(parentHandler, REPOSITORY_REFERENCE_ELEMENT);
String[] values = parseRequiredAttributes(attributes, required);
String name = parseOptionalAttribute(attributes, NAME_ATTRIBUTE);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF
index 6e15f23e2..8146fc5ea 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.publisher/META-INF/MANIFEST.MF
@@ -54,6 +54,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.p2.repository.artifact;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact.spi;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.metadata;version="[2.0.0,3.0.0)",
+ org.eclipse.equinox.p2.repository.spi,
org.eclipse.osgi.service.datalocation;version="1.2.0",
org.eclipse.osgi.service.environment;version="1.1.0",
org.eclipse.osgi.service.pluginconversion;version="1.0.0",
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
index a6fc3933e..4bfc05ca5 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/FeaturesAction.java
@@ -10,30 +10,29 @@
******************************************************************************/
package org.eclipse.equinox.p2.publisher.eclipse;
-import org.eclipse.equinox.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitPatchDescription;
-
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.publisher.*;
+import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitPatchDescription;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.actions.IFeatureRootAdvice;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Filter;
@@ -475,7 +474,7 @@ public class FeaturesAction extends AbstractPublisherAction {
* @param featureId the identifier of the feature where the error occurred, or null
* @param metadataRepo The repo into which the references are added
*/
- private void generateSiteReference(String location, String nickname, String featureId, IMetadataRepository metadataRepo) {
+ private void generateSiteReference(String location, String nickname, String featureId, List<IRepositoryReference> collector) {
if (location == null) {
String message = featureId == null ? NLS.bind(Messages.exception_invalidSiteReference, location) : NLS.bind(Messages.exception_invalidSiteReferenceInFeature, location, featureId);
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
@@ -484,8 +483,8 @@ public class FeaturesAction extends AbstractPublisherAction {
try {
URI associateLocation = new URI(location);
- metadataRepo.addReference(associateLocation, nickname, IRepository.TYPE_METADATA, IRepository.NONE);
- metadataRepo.addReference(associateLocation, nickname, IRepository.TYPE_ARTIFACT, IRepository.NONE);
+ collector.add(new RepositoryReference(associateLocation, nickname, IRepository.TYPE_METADATA, IRepository.NONE));
+ collector.add(new RepositoryReference(associateLocation, nickname, IRepository.TYPE_ARTIFACT, IRepository.NONE));
} catch (URISyntaxException e) {
String message = featureId == null ? NLS.bind(Messages.exception_invalidSiteReference, location) : NLS.bind(Messages.exception_invalidSiteReferenceInFeature, location, featureId);
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
@@ -497,11 +496,14 @@ public class FeaturesAction extends AbstractPublisherAction {
URLEntry updateURL = feature.getUpdateSite();
//don't enable feature update sites by default since this results in too many
//extra sites being loaded and searched (Bug 234177)
+ List<IRepositoryReference> collector = new ArrayList<IRepositoryReference>();
if (updateURL != null)
- generateSiteReference(updateURL.getURL(), updateURL.getAnnotation(), feature.getId(), publisherInfo.getMetadataRepository());
+ generateSiteReference(updateURL.getURL(), updateURL.getAnnotation(), feature.getId(), collector);
URLEntry[] discoverySites = feature.getDiscoverySites();
for (int i = 0; i < discoverySites.length; i++)
- generateSiteReference(discoverySites[i].getURL(), discoverySites[i].getAnnotation(), feature.getId(), publisherInfo.getMetadataRepository());
+ generateSiteReference(discoverySites[i].getURL(), discoverySites[i].getAnnotation(), feature.getId(), collector);
+ if (!collector.isEmpty())
+ publisherInfo.getMetadataRepository().addReferences(collector);
}
protected Feature[] getFeatures(File[] featureLocations) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
index f4bb2f2eb..d4168db40 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
@@ -43,6 +43,7 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
private boolean raw = true;
private boolean verbose = false;
private boolean validate = false;
+ private boolean mirrorReferences = false;
private String metadataOrArtifacts = null;
private String[] rootIUs = null;
@@ -122,6 +123,8 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
compare = true;
else if (args[i].equalsIgnoreCase("-validate")) //$NON-NLS-1$
validate = true;
+ else if (args[i].equalsIgnoreCase("-references")) //$NON-NLS-1$
+ mirrorReferences = true;
// check for args with parameters. If we are at the last argument or
// if the next one has a '-' as the first character, then we can't have
@@ -240,6 +243,8 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
private void mirrorMetadata(IQueryable<IInstallableUnit> slice, IProgressMonitor monitor) {
IQueryResult<IInstallableUnit> allIUs = slice.query(QueryUtil.createIUAnyQuery(), monitor);
destinationMetadataRepository.addInstallableUnits(allIUs.toUnmodifiableSet());
+ if (mirrorReferences)
+ destinationMetadataRepository.addReferences(getCompositeMetadataRepository().getReferences());
}
/*
@@ -408,6 +413,13 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
validate = value;
}
+ /*
+ * Set if references should be mirrored
+ */
+ public void setReferences(boolean flag) {
+ mirrorReferences = flag;
+ }
+
public void setComparatorExclusions(IQuery<IArtifactDescriptor> exclusions) {
compareExclusions = exclusions;
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRepositoryReference.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRepositoryReference.java
new file mode 100644
index 000000000..9337391e7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/IRepositoryReference.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008 - 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Cloudsmith Inc - public API
+ *******************************************************************************/
+package org.eclipse.equinox.p2.repository;
+
+import java.net.URI;
+
+public interface IRepositoryReference {
+ /**
+ * Returns the location of the referenced repository
+ * @return the location
+ */
+ URI getLocation();
+
+ /**
+ * Returns the type of the referenced repository (currently either {@link IRepository#TYPE_METADATA}
+ * or {@link IRepository#TYPE_ARTIFACT})
+ * @return the repository type
+ */
+ int getType();
+
+ /**
+ * Returns bit-wise or of option constants (currently either
+ * {@link IRepository#ENABLED} or {@link IRepository#NONE}).
+ * @return bit-wise or of option constants
+ */
+ int getOptions();
+
+ /**
+ * Returns the optional nickname of the referenced repository
+ * @return The nickname or <code>null</code>
+ */
+ String getNickname();
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java
index afdeb3278..0c1c7837f 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.repository.metadata;
-import java.net.URI;
import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
/**
@@ -42,29 +42,22 @@ public interface IMetadataRepository extends IRepository<IInstallableUnit> {
public void addInstallableUnits(Collection<IInstallableUnit> installableUnits);
/**
- * Adds a reference to another repository to this repository. When a repository
+ * <p>Adds references to another repository to this repository. When a repository
* is loaded by {@link IMetadataRepositoryManager}, its references
- * are automatically added to the repository manager's set of known repositories.
- * <p>
- * Note that this method does not add the <b>contents</b> of the given
- * repository to this repository, but merely adds the location of another
- * repository to the metadata of this repository.
- * <p>
- * The {@link IRepository#ENABLED} option flag controls whether the
- * referenced repository should be marked as enabled when added to the repository
- * manager. If this flag is set, the repository will be marked as enabled when
- * added to the repository manager. If this flag is missing, the repository will
- * be marked as disabled.
+ * are automatically added to the repository manager's set of known repositories.</p>
+ * <p>Note that this method does not add the <b>contents</b> of the given
+ * repositories to this repository, but merely adds the location of other
+ * repositories to the metadata of this repository.</p>
*
- * @param location the location of the repository to add
- * @param nickname The nickname of the repository, or <code>null</code>
- * @param type the repository type (currently either {@link IRepository#TYPE_METADATA}
- * or {@link IRepository#TYPE_ARTIFACT}).
- * @param options bit-wise or of option constants (currently either
- * {@link IRepository#ENABLED} or {@link IRepository#NONE}).
- * @see IMetadataRepositoryManager#setEnabled(URI, boolean)
+ * @param references The references to add
*/
- public void addReference(URI location, String nickname, int type, int options);
+ void addReferences(Collection<? extends IRepositoryReference> references);
+
+ /**
+ * Returns the repositories that this repository is referencing.
+ * @return An immutable collection of repository references, possibly empty but never <code>null</code>.
+ */
+ Collection<IRepositoryReference> getReferences();
/**
* @deprecated use {@link #removeInstallableUnits(Collection)}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java
index c66340643..7a2693d31 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java
@@ -17,9 +17,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.spi.AbstractRepository;
-import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
/**
* The common base class for all metadata repositories.
@@ -40,7 +40,7 @@ public abstract class AbstractMetadataRepository extends AbstractRepository<IIns
public URI Location;
public Map<String, String> Properties;
public IInstallableUnit[] Units;
- public RepositoryReference[] Repositories;
+ public IRepositoryReference[] Repositories;
}
public AbstractMetadataRepository(IProvisioningAgent agent) {
@@ -69,7 +69,7 @@ public abstract class AbstractMetadataRepository extends AbstractRepository<IIns
/* (non-Javadoc)
* @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#addReference(java.net.URI, java.lang.String, int, int)
*/
- public void addReference(URI repositoryLocation, String nickname, int repositoryType, int options) {
+ public void addReferences(Collection<? extends IRepositoryReference> references) {
assertModifiable();
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java
index b50398f41..cbdb69469 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java
@@ -7,51 +7,87 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Cloudsmith Inc - public API
*******************************************************************************/
package org.eclipse.equinox.p2.repository.spi;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
+
import java.net.URI;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* Serialization helper class for repository references.
* @since 2.0
*/
-public class RepositoryReference {
- public URI Location;
- public int Type;
- public int Options;
- public String Nickname;
+public class RepositoryReference implements IRepositoryReference {
+ private final URI location;
+ private final int type;
+ private final int options;
+ private final String nickname;
+ /**
+ * Creates a reference to another repository.
+ *
+ * The {@link IRepository#ENABLED} option flag controls whether the
+ * referenced repository should be marked as enabled when added to the repository
+ * manager. If this flag is set, the repository will be marked as enabled when
+ * added to the repository manager. If this flag is missing, the repository will
+ * be marked as disabled.
+ *
+ * @param location the location of the repository to add
+ * @param nickname The nickname of the repository, or <code>null</code>
+ * @param type the repository type (currently either {@link IRepository#TYPE_METADATA}
+ * or {@link IRepository#TYPE_ARTIFACT}).
+ * @param options bit-wise or of option constants (currently either
+ * {@link IRepository#ENABLED} or {@link IRepository#NONE}).
+ * @see IMetadataRepositoryManager#setEnabled(URI, boolean)
+ */
public RepositoryReference(URI location, String nickname, int type, int options) {
- this.Location = location;
- this.Type = type;
- this.Options = options;
- this.Nickname = nickname;
+ this.location = location;
+ this.type = type;
+ this.options = options;
+ this.nickname = nickname;
}
public boolean equals(Object obj) {
if (this == obj)
return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
+ if (!(obj instanceof IRepositoryReference))
return false;
- RepositoryReference other = (RepositoryReference) obj;
- if (Location == null) {
- if (other.Location != null)
+ IRepositoryReference other = (IRepositoryReference) obj;
+ if (location == null) {
+ if (other.getLocation() != null)
return false;
- } else if (!Location.equals(other.Location))
+ } else if (!location.equals(other.getLocation()))
return false;
- if (Type != other.Type)
+ if (type != other.getType())
return false;
return true;
}
+ public URI getLocation() {
+ return location;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public int getOptions() {
+ return options;
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((Location == null) ? 0 : Location.hashCode());
- result = prime * result + Type;
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + type;
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java
index 1d4e8c7a8..6fc875472 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
+
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
@@ -22,7 +24,6 @@ import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
-import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
/**
* A simple metadata repository used for testing purposes. All metadata
@@ -36,7 +37,7 @@ public class TestMetadataRepository extends AbstractMetadataRepository {
private static final String TYPE = "testmetadatarepo"; //$NON-NLS-1$
private static final String VERSION = "1"; //$NON-NLS-1$
private final List units = new ArrayList();
- protected HashSet repositories = new HashSet();
+ protected HashSet<IRepositoryReference> repositories = new HashSet<IRepositoryReference>();
private static URI createLocation() {
try {
@@ -116,15 +117,15 @@ public class TestMetadataRepository extends AbstractMetadataRepository {
this.repositories.addAll(Arrays.asList(state.Repositories));
}
- public synchronized void addReference(URI repositoryLocation, String nickname, int repositoryType, int options) {
+ public synchronized void addReferences(Collection<? extends IRepositoryReference> references) {
assertModifiable();
- repositories.add(new RepositoryReference(repositoryLocation, nickname, repositoryType, options));
+ repositories.addAll(references);
}
/**
* Returns a collection of {@link RepositoryReference}.
*/
- public Collection getReferences() {
+ public Collection<IRepositoryReference> getReferences() {
return repositories;
}
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 872ff4dbc..bd40fe9b9 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
@@ -27,6 +27,7 @@ import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -185,9 +186,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest {
properties.put(IRepository.PROP_COMPRESSED, "false");
final URI repoURI = repoLocation.toURI();
IMetadataRepository repo = manager.createRepository(repoURI, "testLoadSelfReference", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
- repo.addReference(repoURI, "testNick", IRepository.TYPE_METADATA, IRepository.NONE);
- //adding a reference doesn't save the repository, but setting a property does
- repo.setProperty("changed", "false");
+ repo.addReferences(Collections.singletonList(new RepositoryReference(repoURI, "testNick", IRepository.TYPE_METADATA, IRepository.NONE)));
final int[] callCount = new int[] {0};
final boolean[] wasEnabled = new boolean[] {false};
@@ -226,9 +225,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest {
properties.put(IRepository.PROP_COMPRESSED, "false");
final URI repoURL = repoLocation.toURI();
IMetadataRepository repo = manager.createRepository(repoURL, "testRefreshSelfReference", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
- repo.addReference(repoURL, "testNick", IRepository.TYPE_METADATA, IRepository.NONE);
- //adding a reference doesn't save the repository, but setting a property does
- repo.setProperty("changed", "false");
+ repo.addReferences(Collections.singletonList(new RepositoryReference(repoURL, "testNick", IRepository.TYPE_METADATA, IRepository.NONE)));
final int[] callCount = new int[] {0};
final boolean[] wasEnabled = new boolean[] {false};
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
index 26f12d015..9305febe1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
@@ -10,10 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.mirror;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
+
import java.io.File;
import java.net.*;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
import org.eclipse.equinox.internal.simpleconfigurator.utils.URIUtil;
import org.eclipse.equinox.p2.core.ProvisionException;
@@ -23,8 +24,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.osgi.util.NLS;
@@ -37,6 +37,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
protected File sourceRepo2Location; //anotherfeature
protected File sourceRepo3Location; //helloworldfeature + yetanotherfeature
protected File sourceRepo4Location; //helloworldfeature v1.0.1
+ protected File sourceRepoWithRefs; //helloworldfeature v1.0.1 and references
protected Exception exception = null;
@@ -50,6 +51,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
sourceRepo2Location = getTestData("0.1", "/testData/mirror/mirrorSourceRepo2");
sourceRepo3Location = getTestData("0.2", "/testData/mirror/mirrorSourceRepo3");
sourceRepo4Location = getTestData("0.3", "/testData/mirror/mirrorSourceRepo4");
+ sourceRepoWithRefs = getTestData("0.4", "/testData/mirror/mirrorSourceRepoWithRefs");
//create destination location
destRepoLocation = new File(getTempFolder(), "BasicMirrorApplicationTest");
@@ -66,6 +68,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
getMetadataRepositoryManager().removeRepository(sourceRepo2Location.toURI());
getMetadataRepositoryManager().removeRepository(sourceRepo3Location.toURI());
getMetadataRepositoryManager().removeRepository(sourceRepo4Location.toURI());
+ getMetadataRepositoryManager().removeRepository(sourceRepoWithRefs.toURI());
exception = null;
//delete the destination location (no left over files for the next test)
delete(destRepoLocation);
@@ -964,4 +967,24 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
fail("Could not load destination", e);
}
}
+
+ public void testMirrorReferences() throws Exception {
+ MirrorApplication app = new MirrorApplication();
+ RepositoryDescriptor dest = new RepositoryDescriptor();
+ dest.setLocation(destRepoLocation.toURI());
+ dest.setAppend(false);
+ dest.setKind("metadata");
+ app.addDestination(dest);
+
+ RepositoryDescriptor src = new RepositoryDescriptor();
+ src.setLocation(sourceRepoWithRefs.toURI());
+ src.setKind("metadata");
+ app.addSource(src);
+ app.setReferences(true);
+ app.run(null);
+
+ IMetadataRepository destRepo = getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null);
+ Collection<IRepositoryReference> destRefs = destRepo.getReferences();
+ assertEquals(destRefs.size(), 4);
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java
index 3364b0c7c..a401bf1ca 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java
@@ -24,7 +24,7 @@ import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.tests.*;
/**
@@ -74,14 +74,14 @@ public class SiteXMLActionTest extends AbstractProvisioningTest {
assertEquals("1.0", 2, references.size());
boolean metadataFound = false, artifactFound = false;
for (Iterator it = references.iterator(); it.hasNext();) {
- RepositoryReference ref = (RepositoryReference) it.next();
- assertEquals("1.1", "http://download.eclipse.org/eclipse/updates/3.5", ref.Location.toString());
- assertEquals("1.2", IRepository.ENABLED, ref.Options);
- assertEquals("1.3", "Eclipse Project Update Site", ref.Nickname);
+ IRepositoryReference ref = (IRepositoryReference) it.next();
+ assertEquals("1.1", "http://download.eclipse.org/eclipse/updates/3.5", ref.getLocation().toString());
+ assertEquals("1.2", IRepository.ENABLED, ref.getOptions());
+ assertEquals("1.3", "Eclipse Project Update Site", ref.getNickname());
- if (ref.Type == IRepository.TYPE_METADATA)
+ if (ref.getType() == IRepository.TYPE_METADATA)
metadataFound = true;
- else if (ref.Type == IRepository.TYPE_ARTIFACT)
+ else if (ref.getType() == IRepository.TYPE_ARTIFACT)
artifactFound = true;
}
assertTrue("1.3", metadataFound);
@@ -89,7 +89,7 @@ public class SiteXMLActionTest extends AbstractProvisioningTest {
}
public void testMirrorsURL() {
- String mirrorsURL = (String) metadataRepository.getProperties().get(IRepository.PROP_MIRRORS_URL);
+ String mirrorsURL = metadataRepository.getProperties().get(IRepository.PROP_MIRRORS_URL);
assertEquals("1.0", "http://www.eclipse.org/downloads/download.php?file=/eclipse/updates/3.4&format=xml", mirrorsURL);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/artifacts.xml b/bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/artifacts.xml
new file mode 100644
index 000000000..cebb6e6c1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/artifacts.xml
@@ -0,0 +1,28 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?artifactRepository class='org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository' version='1.0.0'?>
+<repository name='file:/C:/Documents and Settings/agcattle/workspace/mirrorSourceRepo4/ - artifacts' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1222693511921'/>
+ </properties>
+ <mappings size='3'>
+ <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
+ <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
+ </mappings>
+ <artifacts size='2'>
+ <artifact classifier='osgi.bundle' id='helloworld' version='1.0.1'>
+ <properties size='3'>
+ <property name='artifact.size' value='3491'/>
+ <property name='download.size' value='3491'/>
+ <property name='download.contentType' value='application/zip'/>
+ </properties>
+ </artifact>
+ <artifact classifier='org.eclipse.update.feature' id='helloworldfeature' version='1.0.1'>
+ <properties size='2'>
+ <property name='artifact.size' value='687'/>
+ <property name='download.size' value='687'/>
+ </properties>
+ </artifact>
+ </artifacts>
+</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/content.xml b/bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/content.xml
new file mode 100644
index 000000000..3a3575af8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/mirror/mirrorSourceRepoWithRefs/content.xml
@@ -0,0 +1,337 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?metadataRepository class='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1.0.0'?>
+<repository name='file:/C:/Documents and Settings/agcattle/workspace/mirrorSourceRepo4/ - metadata' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1222693511921'/>
+ </properties>
+ <references size='4'>
+ <repository uri='http://download.eclipse.org/eclipse/updates/3.5/' url='http://download.eclipse.org/eclipse/updates/3.5/' type='0' options='0'/>
+ <repository uri='http://download.eclipse.org/eclipse/updates/3.5/' url='http://download.eclipse.org/eclipse/updates/3.5/' type='1' options='0'/>
+ <repository uri='http://download.eclipse.org/eclipse/updates/3.6/' url='http://download.eclipse.org/eclipse/updates/3.6/' type='0' options='0'/>
+ <repository uri='http://download.eclipse.org/eclipse/updates/3.6/' url='http://download.eclipse.org/eclipse/updates/3.6/' type='1' options='0'/>
+ </references>
+ <units size='8'>
+ <unit id='helloworldfeature.feature.jar' version='1.0.1'>
+ <update id='helloworldfeature.feature.jar' range='[0.0.0,1.0.1)' severity='0'/>
+ <properties size='3'>
+ <property name='org.eclipse.equinox.p2.name' value='Helloworldfeature Feature'/>
+ <property name='org.eclipse.equinox.p2.description' value='[Enter Feature Description here.]'/>
+ <property name='org.eclipse.equinox.p2.description.url' value='http://www.example.com/description'/>
+ </properties>
+ <provides size='3'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='helloworldfeature.feature.jar' version='1.0.1'/>
+ <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='feature' version='1.0.0'/>
+ <provided namespace='org.eclipse.update.feature' name='helloworldfeature' version='1.0.1'/>
+ </provides>
+ <filter>
+ (org.eclipse.update.install.features=true)
+ </filter>
+ <artifacts size='1'>
+ <artifact classifier='org.eclipse.update.feature' id='helloworldfeature' version='1.0.1'/>
+ </artifacts>
+ <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='1'>
+ <instruction key='zipped'>
+ true
+ </instruction>
+ </instructions>
+ </touchpointData>
+ <licenses size='1'>
+ <license url='http://www.example.com/license'>
+ [Enter License Description here.]
+ </license>
+ </licenses>
+ <copyright url='http://www.example.com/copyright'>
+ [Enter Copyright Description here.]
+ </copyright>
+ </unit>
+ <unit id='helloworld' version='1.0.1'>
+ <update id='helloworld' range='[0.0.0,1.0.1)' severity='0'/>
+ <properties size='1'>
+ <property name='org.eclipse.equinox.p2.name' value='1 Plug-in'/>
+ </properties>
+ <provides size='3'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='helloworld' version='1.0.1'/>
+ <provided namespace='osgi.bundle' name='helloworld' version='1.0.1'/>
+ <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
+ </provides>
+ <requires size='2'>
+ <required namespace='osgi.bundle' name='org.eclipse.ui' range='0.0.0'/>
+ <required namespace='osgi.bundle' name='org.eclipse.core.runtime' range='0.0.0'/>
+ </requires>
+ <artifacts size='1'>
+ <artifact classifier='osgi.bundle' id='helloworld' version='1.0.1'/>
+ </artifacts>
+ <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='1'>
+ <instruction key='manifest'>
+ Bundle-ManifestVersion: 2&#xA;Bundle-ActivationPolicy: lazy&#xA;Bundle-Name: 1 Plug-in&#xA;Bundle-Version: 1.0.1&#xA;Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime&#xA;Bundle-RequiredExecutionEnvironment: J2SE-1.5&#xA;Bundle-SymbolicName: helloworld; singleton:=true&#xA;Manifest-Version: 1.0&#xA;Bundle-Activator: helloworld101.Activator&#xA;
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ <unit id='config.a.jre' version='1.6.0' singleton='false'>
+ <hostRequirements size='1'>
+ <required namespace='org.eclipse.equinox.p2.iu' name='a.jre' range='1.6.0'/>
+ </hostRequirements>
+ <properties size='1'>
+ <property name='org.eclipse.equinox.p2.type.fragment' value='true'/>
+ </properties>
+ <provides size='1'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='config.a.jre' version='1.6.0'/>
+ </provides>
+ <requires size='1'>
+ <required namespace='org.eclipse.equinox.p2.iu' name='a.jre' range='1.6.0'/>
+ </requires>
+ <touchpoint id='org.eclipse.equinox.p2.native' version='1.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='1'>
+ <instruction key='install'>
+
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ <unit id='tooling.osgi.bundle.default' version='1.0.0' singleton='false'>
+ <hostRequirements size='1'>
+ <required namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' range='0.0.0' multiple='true' greedy='false'/>
+ </hostRequirements>
+ <properties size='1'>
+ <property name='org.eclipse.equinox.p2.type.fragment' value='true'/>
+ </properties>
+ <provides size='2'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='tooling.osgi.bundle.default' version='1.0.0'/>
+ <provided namespace='org.eclipse.equinox.p2.flavor' name='tooling' version='1.0.0'/>
+ </provides>
+ <requires size='1'>
+ <required namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' range='0.0.0' multiple='true' greedy='false'/>
+ </requires>
+ <touchpoint id='null' version='0.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='4'>
+ <instruction key='uninstall'>
+ uninstallBundle(bundle:${artifact})
+ </instruction>
+ <instruction key='configure'>
+ setStartLevel(startLevel:4);
+ </instruction>
+ <instruction key='install'>
+ installBundle(bundle:${artifact})
+ </instruction>
+ <instruction key='unconfigure'>
+
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ <unit id='tooling.source.default' version='1.0.0' singleton='false'>
+ <hostRequirements size='1'>
+ <required namespace='org.eclipse.equinox.p2.eclipse.type' name='source' range='0.0.0' optional='true' multiple='true' greedy='false'/>
+ </hostRequirements>
+ <properties size='1'>
+ <property name='org.eclipse.equinox.p2.type.fragment' value='true'/>
+ </properties>
+ <provides size='2'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='tooling.source.default' version='1.0.0'/>
+ <provided namespace='org.eclipse.equinox.p2.flavor' name='tooling' version='1.0.0'/>
+ </provides>
+ <requires size='1'>
+ <required namespace='org.eclipse.equinox.p2.eclipse.type' name='source' range='0.0.0' optional='true' multiple='true' greedy='false'/>
+ </requires>
+ <touchpoint id='null' version='0.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='2'>
+ <instruction key='uninstall'>
+ removeSourceBundle(bundle:${artifact})
+ </instruction>
+ <instruction key='install'>
+ addSourceBundle(bundle:${artifact})
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ <unit id='helloworldfeature.feature.group' version='1.0.1' singleton='false'>
+ <update id='helloworldfeature.feature.group' range='[0.0.0,1.0.1)' severity='0'/>
+ <properties size='4'>
+ <property name='org.eclipse.equinox.p2.name' value='Helloworldfeature Feature'/>
+ <property name='org.eclipse.equinox.p2.description' value='[Enter Feature Description here.]'/>
+ <property name='org.eclipse.equinox.p2.description.url' value='http://www.example.com/description'/>
+ <property name='org.eclipse.equinox.p2.type.group' value='true'/>
+ </properties>
+ <provides size='1'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='helloworldfeature.feature.group' version='1.0.1'/>
+ </provides>
+ <requires size='2'>
+ <required namespace='org.eclipse.equinox.p2.iu' name='helloworld' range='[1.0.1,1.0.1]'/>
+ <required namespace='org.eclipse.equinox.p2.iu' name='helloworldfeature.feature.jar' range='[1.0.1,1.0.1]'>
+ <filter>
+ (org.eclipse.update.install.features=true)
+ </filter>
+ </required>
+ </requires>
+ <touchpoint id='null' version='0.0.0'/>
+ <licenses size='1'>
+ <license url='http://www.example.com/license'>
+ [Enter License Description here.]
+ </license>
+ </licenses>
+ <copyright url='http://www.example.com/copyright'>
+ [Enter Copyright Description here.]
+ </copyright>
+ </unit>
+ <unit id='a.jre' version='1.6.0' singleton='false'>
+ <provides size='117'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='a.jre' version='1.6.0'/>
+ <provided namespace='java.package' name='javax.accessibility' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.activity' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.crypto' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.crypto.interfaces' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.crypto.spec' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio.event' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio.metadata' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio.plugins.bmp' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio.plugins.jpeg' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio.spi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.imageio.stream' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.loading' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.modelmbean' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.monitor' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.openmbean' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.relation' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.remote' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.remote.rmi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.management.timer' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.naming' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.naming.directory' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.naming.event' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.naming.ldap' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.naming.spi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.net' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.net.ssl' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.print' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.print.attribute' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.print.attribute.standard' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.print.event' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.rmi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.rmi.CORBA' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.rmi.ssl' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.auth' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.auth.callback' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.auth.kerberos' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.auth.login' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.auth.spi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.auth.x500' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.cert' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.security.sasl' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sound.midi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sound.midi.spi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sound.sampled' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sound.sampled.spi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sql' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sql.rowset' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sql.rowset.serial' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.sql.rowset.spi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.border' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.colorchooser' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.event' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.filechooser' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.plaf' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.plaf.basic' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.plaf.metal' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.plaf.multi' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.plaf.synth' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.table' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.text' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.text.html' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.text.html.parser' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.text.rtf' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.tree' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.swing.undo' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.transaction' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.transaction.xa' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.datatype' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.namespace' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.parsers' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.transform' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.transform.dom' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.transform.sax' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.transform.stream' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.validation' version='0.0.0'/>
+ <provided namespace='java.package' name='javax.xml.xpath' version='0.0.0'/>
+ <provided namespace='java.package' name='org.ietf.jgss' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA_2_3' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA_2_3.portable' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA.DynAnyPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA.ORBPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA.portable' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CORBA.TypeCodePackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CosNaming' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CosNaming.NamingContextExtPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.CosNaming.NamingContextPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.Dynamic' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.DynamicAny' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.DynamicAny.DynAnyFactoryPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.DynamicAny.DynAnyPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.IOP' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.IOP.CodecFactoryPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.IOP.CodecPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.Messaging' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableInterceptor' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableInterceptor.ORBInitInfoPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableServer' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableServer.CurrentPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableServer.POAManagerPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableServer.POAPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableServer.portable' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.PortableServer.ServantLocatorPackage' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.SendingContext' version='0.0.0'/>
+ <provided namespace='java.package' name='org.omg.stub.java.rmi' version='0.0.0'/>
+ <provided namespace='java.package' name='org.w3c.dom' version='0.0.0'/>
+ <provided namespace='java.package' name='org.w3c.dom.bootstrap' version='0.0.0'/>
+ <provided namespace='java.package' name='org.w3c.dom.events' version='0.0.0'/>
+ <provided namespace='java.package' name='org.w3c.dom.ls' version='0.0.0'/>
+ <provided namespace='java.package' name='org.xml.sax' version='0.0.0'/>
+ <provided namespace='java.package' name='org.xml.sax.ext' version='0.0.0'/>
+ <provided namespace='java.package' name='org.xml.sax.helpers' version='0.0.0'/>
+ </provides>
+ <touchpoint id='org.eclipse.equinox.p2.native' version='1.0.0'/>
+ </unit>
+ <unit id='tooling.org.eclipse.update.feature.default' version='1.0.0' singleton='false'>
+ <hostRequirements size='1'>
+ <required namespace='org.eclipse.equinox.p2.eclipse.type' name='feature' range='0.0.0' optional='true' multiple='true' greedy='false'/>
+ </hostRequirements>
+ <properties size='1'>
+ <property name='org.eclipse.equinox.p2.type.fragment' value='true'/>
+ </properties>
+ <provides size='2'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='tooling.org.eclipse.update.feature.default' version='1.0.0'/>
+ <provided namespace='org.eclipse.equinox.p2.flavor' name='tooling' version='1.0.0'/>
+ </provides>
+ <requires size='1'>
+ <required namespace='org.eclipse.equinox.p2.eclipse.type' name='feature' range='0.0.0' optional='true' multiple='true' greedy='false'/>
+ </requires>
+ <filter>
+ (org.eclipse.update.install.features=true)
+ </filter>
+ <touchpoint id='null' version='0.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='2'>
+ <instruction key='uninstall'>
+ uninstallFeature(feature:${artifact},featureId:default,featureVersion:default)
+ </instruction>
+ <instruction key='install'>
+ installFeature(feature:${artifact},featureId:default,featureVersion:default)
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ </units>
+</repository>
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index 01a3d7ade..2542bbbc9 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -10,9 +10,6 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.updatesite;
-import org.eclipse.equinox.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
@@ -23,13 +20,15 @@ import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.metadata.expression.IExpression;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.eclipse.URLEntry;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.eclipse.equinox.spi.p2.publisher.LocalizationHelper;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -273,9 +272,23 @@ public class SiteXMLAction extends AbstractPublisherAction {
//publish associate sites as repository references
URLEntry[] associatedSites = site.getAssociatedSites();
- if (associatedSites != null)
- for (int i = 0; i < associatedSites.length; i++)
- generateSiteReference(associatedSites[i].getURL(), associatedSites[i].getAnnotation(), null, publisherInfo.getMetadataRepository());
+ if (associatedSites != null) {
+ ArrayList<IRepositoryReference> refs = new ArrayList<IRepositoryReference>(associatedSites.length * 2);
+ for (int i = 0; i < associatedSites.length; i++) {
+ URLEntry associatedSite = associatedSites[i];
+ String siteLocation = associatedSite.getURL();
+ try {
+ URI associateLocation = new URI(siteLocation);
+ String label = associatedSite.getAnnotation();
+ refs.add(new RepositoryReference(associateLocation, label, IRepository.TYPE_METADATA, IRepository.ENABLED));
+ refs.add(new RepositoryReference(associateLocation, label, IRepository.TYPE_ARTIFACT, IRepository.ENABLED));
+ } catch (URISyntaxException e) {
+ String message = "Invalid site reference: " + siteLocation; //$NON-NLS-1$
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
+ }
+ }
+ publisherInfo.getMetadataRepository().addReferences(refs);
+ }
File siteFile = URIUtil.toFile(updateSite.getLocation());
if (siteFile != null && siteFile.exists()) {
@@ -306,28 +319,6 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
/**
- * Generates and publishes a reference to an update site location
- * @param siteLocation The update site location
- * @param label The update site label
- * @param featureId the identifier of the feature where the error occurred, or null
- * @param metadataRepo The repository into which the references are added
- */
- private void generateSiteReference(String siteLocation, String label, String featureId, IMetadataRepository metadataRepo) {
- if (metadataRepo == null)
- return;
- try {
- URI associateLocation = new URI(siteLocation);
- metadataRepo.addReference(associateLocation, label, IRepository.TYPE_METADATA, IRepository.ENABLED);
- metadataRepo.addReference(associateLocation, label, IRepository.TYPE_ARTIFACT, IRepository.ENABLED);
- } catch (URISyntaxException e) {
- String message = "Invalid site reference: " + siteLocation; //$NON-NLS-1$
- if (featureId != null)
- message = message + " in feature: " + featureId; //$NON-NLS-1$
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message));
- }
- }
-
- /**
* Generates IUs corresponding to update site categories.
* @param categoriesToFeatures Map of SiteCategory ->Set (Feature IUs in that category).
* @param result The generator result being built
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepository.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepository.java
index b61c4e654..17194b552 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/metadata/UpdateSiteMetadataRepository.java
@@ -18,6 +18,7 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
public class UpdateSiteMetadataRepository implements IMetadataRepository {
@@ -46,13 +47,20 @@ public class UpdateSiteMetadataRepository implements IMetadataRepository {
}
/* (non-Javadoc)
- * @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#addReference(java.net.URI, java.lang.String, int, int)
+ * @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#addReferences(java.util.Collection)
*/
- public void addReference(URI location, String nickname, int type, int options) {
+ public void addReferences(Collection<? extends IRepositoryReference> references) {
throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
}
/* (non-Javadoc)
+ * @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#getReferences()
+ */
+ public Collection<IRepositoryReference> getReferences() {
+ return delegate.getReferences();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.equinox.p2.repository.metadata.IMetadataRepository#removeAll()
*/
public void removeAll() {

Back to the top