Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-03-02 16:09:25 -0500
committerThomas Hallgren2010-03-02 16:09:25 -0500
commitd02045a478a379725db884d66b5f049d37b8c82e (patch)
treed048a352176d738b6435ee6d1d49cf540e1137b2 /bundles/org.eclipse.equinox.p2.repository
parent3d366edaf31add79bee83aff0d7d14c980a200f7 (diff)
downloadrt.equinox.p2-d02045a478a379725db884d66b5f049d37b8c82e.tar.gz
rt.equinox.p2-d02045a478a379725db884d66b5f049d37b8c82e.tar.xz
rt.equinox.p2-d02045a478a379725db884d66b5f049d37b8c82e.zip
275800 : It is impossible to mirror repository references.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository')
-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
4 files changed, 114 insertions, 43 deletions
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;
}

Back to the top