Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2009-03-05 18:58:27 +0000
committerSimon Kaegi2009-03-05 18:58:27 +0000
commit629320b0541b20395ec56fef0ac20e2e155591f8 (patch)
treef459365ce98c29e50f0a64431dac9eba65a334ce
parentf7a93f6d6307542e9bf3abdc72550279a23da88e (diff)
downloadrt.equinox.p2-629320b0541b20395ec56fef0ac20e2e155591f8.tar.gz
rt.equinox.p2-629320b0541b20395ec56fef0ac20e2e155591f8.tar.xz
rt.equinox.p2-629320b0541b20395ec56fef0ac20e2e155591f8.zip
Bug 252752 [dropins] Exported repository not recognized as p2 repo
-rw-r--r--bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationArtifactRepository.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationMetadataRepository.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/messages.properties1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java87
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java87
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java4
7 files changed, 212 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationArtifactRepository.java b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationArtifactRepository.java
index a83d60d5f..130f339b1 100644
--- a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/ExtensionLocationArtifactRepository.java
@@ -11,10 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.extensionlocation;
-import java.io.File;
-import java.io.OutputStream;
+import java.io.*;
import java.net.URI;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -27,6 +26,7 @@ public class ExtensionLocationArtifactRepository extends AbstractRepository impl
public static final String TYPE = "org.eclipse.equinox.p2.extensionlocation.artifactRepository"; //$NON-NLS-1$
public static final Integer VERSION = new Integer(1);
+ public static final List STANDARD_P2_REPOSITORY_FILE_NAMES = Arrays.asList(new Object[] {"artifacts.xml", "content.xml", "compositeArtifacts.xml", "compositeContent.xml"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
IFileArtifactRepository artifactRepository;
private File base;
@@ -80,12 +80,25 @@ public class ExtensionLocationArtifactRepository extends AbstractRepository impl
public static void validate(URI location, IProgressMonitor monitor) throws ProvisionException {
File base = getBaseDirectory(location);
- if (new File(base, EXTENSION_LOCATION).exists())
+ if (new File(base, EXTENSION_LOCATION).exists() || location.getPath().endsWith(EXTENSION_LOCATION))
return;
if (containsUpdateSiteFile(base)) {
String message = NLS.bind(Messages.error_update_site, location.toString());
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, message, null));
}
+ if (containsStandardP2Repository(base)) {
+ String message = NLS.bind(Messages.error_p2_repository, location.toString());
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, message, null));
+ }
+ }
+
+ private static boolean containsStandardP2Repository(File base) {
+ File[] foundRepos = base.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return (STANDARD_P2_REPOSITORY_FILE_NAMES.contains(name));
+ }
+ });
+ return foundRepos.length > 0;
}
private static boolean containsUpdateSiteFile(File base) {
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 bc8ceb20b..44572db3e 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
@@ -12,8 +12,9 @@
package org.eclipse.equinox.internal.p2.extensionlocation;
import java.io.File;
+import java.io.FilenameFilter;
import java.net.URI;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
@@ -28,6 +29,7 @@ public class ExtensionLocationMetadataRepository extends AbstractMetadataReposit
public static final String TYPE = "org.eclipse.equinox.p2.extensionlocation.metadataRepository"; //$NON-NLS-1$
public static final Integer VERSION = new Integer(1);
+ public static final List STANDARD_P2_REPOSITORY_FILE_NAMES = Arrays.asList(new Object[] {"artifacts.xml", "content.xml", "compositeArtifacts.xml", "compositeContent.xml"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
IMetadataRepository metadataRepository;
private File base;
@@ -108,12 +110,25 @@ public class ExtensionLocationMetadataRepository extends AbstractMetadataReposit
public static void validate(URI location, IProgressMonitor monitor) throws ProvisionException {
File base = getBaseDirectory(location);
- if (new File(base, EXTENSION_LOCATION).exists())
+ if (new File(base, EXTENSION_LOCATION).exists() || location.getPath().endsWith(EXTENSION_LOCATION))
return;
if (containsUpdateSiteFile(base)) {
String message = NLS.bind(Messages.error_update_site, location.toString());
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, message, null));
}
+ if (containsStandardP2Repository(base)) {
+ String message = NLS.bind(Messages.error_p2_repository, location.toString());
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, message, null));
+ }
+ }
+
+ private static boolean containsStandardP2Repository(File base) {
+ File[] foundRepos = base.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return (STANDARD_P2_REPOSITORY_FILE_NAMES.contains(name));
+ }
+ });
+ return foundRepos.length > 0;
}
private static boolean containsUpdateSiteFile(File base) {
@@ -164,7 +179,7 @@ public class ExtensionLocationMetadataRepository extends AbstractMetadataReposit
return metadataRepository.getProperties();
}
- public void initialize(RepositoryState state) {
+ public void initialize(RepositoryState repositoryState) {
//nothing to do
}
diff --git a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Messages.java b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Messages.java
index dd4c99cf1..b12afe943 100644
--- a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/Messages.java
@@ -20,6 +20,7 @@ public class Messages extends NLS {
public static String not_eclipse_extension;
public static String not_file_protocol;
public static String repo_already_exists;
+ public static String error_p2_repository;
static {
// initialize resource bundle
diff --git a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/messages.properties b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/messages.properties
index 78110119c..b9e78d5a5 100644
--- a/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.extensionlocation/src/org/eclipse/equinox/internal/p2/extensionlocation/messages.properties
@@ -9,6 +9,7 @@
# IBM Corporation - initial API and implementation
###############################################################################
error_update_site=Error: {0} is not a valid extension location because it contains a site.xml file.
+error_p2_repository=Error: {0} is not a valid extension location because it already contains a standard p2 repository file.
failed_create_local_artifact_repository=Failed to create local repository.
not_directory=Location: {0} not a directory.
not_eclipse_extension=Location: {0} is not a valid extension location.
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
index 40537afcd..749f74268 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
@@ -14,6 +14,7 @@ import java.io.File;
import java.io.IOException;
import java.net.*;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.equinox.internal.p2.extensionlocation.Constants;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationArtifactRepositoryFactory;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
@@ -258,4 +259,90 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv
}
fail("1.0");
}
+
+ public void testArtifactsXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File artifactsXML = new File(directory, "artifacts.xml");
+ artifactsXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testArtifactsXMLFeaturesandPluginsDirectoryWithExtensionLocation() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File artifactsXML = new File(directory, "artifacts.xml");
+ artifactsXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ File extensionLocation = new File(tempDirectory.getAbsolutePath() + Constants.EXTENSION_LOCATION);
+ URI location = extensionLocation.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testContentXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File contentXML = new File(directory, "content.xml");
+ contentXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testCompositeArtifactsXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File compositeArtifactsXML = new File(directory, "compositeArtifacts.xml");
+ compositeArtifactsXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testCompositeContentXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File compositeContentXML = new File(directory, "compositeContent.xml");
+ compositeContentXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
index bf4a0230f..9478939f1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
@@ -13,6 +13,7 @@ package org.eclipse.equinox.p2.tests.extensionlocation;
import java.io.File;
import java.io.IOException;
import java.net.*;
+import org.eclipse.equinox.internal.p2.extensionlocation.Constants;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepositoryFactory;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepositoryManager;
@@ -250,4 +251,90 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv
}
fail("1.0");
}
+
+ public void testArtifactsXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File artifactsXML = new File(directory, "artifacts.xml");
+ artifactsXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testArtifactsXMLFeaturesandPluginsDirectoryWithExtensionLocation() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File artifactsXML = new File(directory, "artifacts.xml");
+ artifactsXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ File extensionLocation = new File(tempDirectory.getAbsolutePath() + Constants.EXTENSION_LOCATION);
+ URI location = extensionLocation.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testContentXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File contentXML = new File(directory, "content.xml");
+ contentXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testCompositeArtifactsXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File compositeArtifactsXML = new File(directory, "compositeArtifacts.xml");
+ compositeArtifactsXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
+
+ public void testCompositeContentXMLFeaturesandPluginsDirectory() throws IOException {
+ File directory = new File(tempDirectory, "exists");
+ directory.mkdirs();
+ File compositeContentXML = new File(directory, "compositeContent.xml");
+ compositeContentXML.createNewFile();
+
+ copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory);
+ URI location = directory.toURI();
+ try {
+ factory.load(location, 0, getMonitor());
+ } catch (ProvisionException e) {
+ if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND)
+ return;
+ }
+ fail("1.0");
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java
index 5a6c13834..b98394ce7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java
@@ -53,9 +53,7 @@ public class BasicTests extends AbstractReconcilerTest {
suite.addTest(new BasicTests("testSingleton"));
suite.addTest(new BasicTests("testDirectoryBasedPlugin"));
suite.addTest(new BasicTests("testSimpleRepoWithSiteXMLPlaceHolder"));
- // NOTE: Enable this tests when we can handle a simple repo without the site.xml placeholder
- // see bug 252752
- //suite.addTest(new BasicTests("testSimpleRepo"));
+ suite.addTest(new BasicTests("testSimpleRepo"));
// suite.addTest(new BasicTests("test_251167"));
// suite.addTest(new BasicTests("test_p2Repo"));

Back to the top