aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-09-22 13:38:08 (EDT)
committerbveliev2011-09-22 13:38:08 (EDT)
commit157c754ce036c1792335e0a198f91dae244c7e10 (patch)
treec030a5322b7b97d5850eca058708ba1ec90af2b9
parentf8598dab7b0a4916ff97a4b55e92e214c90e5b09 (diff)
downloadorg.eclipse.rtp-157c754ce036c1792335e0a198f91dae244c7e10.zip
org.eclipse.rtp-157c754ce036c1792335e0a198f91dae244c7e10.tar.gz
org.eclipse.rtp-157c754ce036c1792335e0a198f91dae244c7e10.tar.bz2
* o.e.rtp.configurator.core renamed to o.e.rtp.core
* o.e.rtp.configurator.core.test renamed to o.e.rtp.core.test * o.e.rtp.configurator.service.providor renamed to o.e.rtp.core.service.provider * o.e.rtp.configurator.service.providor.test renamed to o.e.rtp.core.service.provider.test *install and uninstall implemented
-rw-r--r--configurator/org.eclipes.rtp.core/.classpath (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/.classpath)0
-rw-r--r--configurator/org.eclipes.rtp.core/.project (renamed from configurator/org.eclipes.rtp.configurator.core/.project)2
-rw-r--r--configurator/org.eclipes.rtp.core/.settings/org.eclipse.jdt.core.prefs (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.jdt.core.prefs)0
-rw-r--r--configurator/org.eclipes.rtp.core/.settings/org.eclipse.jdt.ui.prefs (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.jdt.ui.prefs)0
-rw-r--r--configurator/org.eclipes.rtp.core/.settings/org.eclipse.pde.core.prefs (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.pde.core.prefs)0
-rw-r--r--configurator/org.eclipes.rtp.core/META-INF/MANIFEST.MF (renamed from configurator/org.eclipes.rtp.configurator.core/META-INF/MANIFEST.MF)2
-rw-r--r--configurator/org.eclipes.rtp.core/build.properties (renamed from configurator/org.eclipes.rtp.configurator.core/build.properties)0
-rw-r--r--configurator/org.eclipes.rtp.core/src/org/eclipse/rtp/configurator/core/IConfiguratorService.java (renamed from configurator/org.eclipes.rtp.configurator.core/src/org/eclipse/rtp/configurator/core/IConfiguratorService.java)0
-rw-r--r--configurator/org.eclipse.rtp.configurator.console/META-INF/MANIFEST.MF2
-rw-r--r--configurator/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java2
-rw-r--r--configurator/org.eclipse.rtp.configurator.service.provider/build.properties5
-rw-r--r--configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java55
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/.classpath (renamed from configurator/org.eclipes.rtp.configurator.core/.classpath)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/.project (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/.project)2
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.jdt.core.prefs (renamed from configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.jdt.core.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.jdt.ui.prefs (renamed from configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.jdt.ui.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.pde.core.prefs (renamed from configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.pde.core.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/META-INF/MANIFEST.MF (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/META-INF/MANIFEST.MF)4
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/build.properties (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/build.properties)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceInstallCommandTest.java164
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceListCommandTest.java (renamed from configurator.test/org.eclipse.rtp.configurator.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceListCommandTest.java)1
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/.classpath (renamed from configurator/org.eclipse.rtp.configurator.service.provider/.classpath)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/.project (renamed from configurator/org.eclipse.rtp.configurator.service.provider/.project)2
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.jdt.core.prefs (renamed from configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.jdt.core.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.jdt.ui.prefs (renamed from configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.jdt.ui.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.pde.core.prefs (renamed from configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.pde.core.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF (renamed from configurator/org.eclipse.rtp.configurator.service.provider/META-INF/MANIFEST.MF)13
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml5
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml (renamed from configurator/org.eclipse.rtp.configurator.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/build.properties6
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java (renamed from configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java)31
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/ProviderActivator.java (renamed from configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/ProviderActivator.java)0
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureInstallException.java24
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java137
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/InvalidRepositoryException.java19
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/RepositoryManager.java176
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java92
-rw-r--r--configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/StatusUtil.java (renamed from configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/StatusUtil.java)0
-rw-r--r--configurator/org.eclipse.rtp.core.test/.classpath (renamed from configurator.test/org.eclipse.rtp.configurator.core.test/.classpath)0
-rw-r--r--configurator/org.eclipse.rtp.core.test/.project (renamed from configurator.test/org.eclipse.rtp.configurator.core.test/.project)2
-rw-r--r--configurator/org.eclipse.rtp.core.test/.settings/org.eclipse.jdt.core.prefs (renamed from configurator.test/org.eclipse.rtp.configurator.core.test/.settings/org.eclipse.jdt.core.prefs)0
-rw-r--r--configurator/org.eclipse.rtp.core.test/META-INF/MANIFEST.MF (renamed from configurator.test/org.eclipse.rtp.configurator.core.test/META-INF/MANIFEST.MF)2
-rw-r--r--configurator/org.eclipse.rtp.core.test/build.properties (renamed from configurator.test/org.eclipse.rtp.configurator.core.test/build.properties)0
43 files changed, 643 insertions, 105 deletions
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.classpath b/configurator/org.eclipes.rtp.core/.classpath
index 8a8f166..8a8f166 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.classpath
+++ b/configurator/org.eclipes.rtp.core/.classpath
diff --git a/configurator/org.eclipes.rtp.configurator.core/.project b/configurator/org.eclipes.rtp.core/.project
index 48d917a..e2022ac 100644
--- a/configurator/org.eclipes.rtp.configurator.core/.project
+++ b/configurator/org.eclipes.rtp.core/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.eclipes.rtp.configurator.core</name>
+ <name>org.eclipes.rtp.core</name>
<comment></comment>
<projects>
</projects>
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.jdt.core.prefs b/configurator/org.eclipes.rtp.core/.settings/org.eclipse.jdt.core.prefs
index 3dd9ba6..3dd9ba6 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.jdt.core.prefs
+++ b/configurator/org.eclipes.rtp.core/.settings/org.eclipse.jdt.core.prefs
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.jdt.ui.prefs b/configurator/org.eclipes.rtp.core/.settings/org.eclipse.jdt.ui.prefs
index dacffb7..dacffb7 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.jdt.ui.prefs
+++ b/configurator/org.eclipes.rtp.core/.settings/org.eclipse.jdt.ui.prefs
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.pde.core.prefs b/configurator/org.eclipes.rtp.core/.settings/org.eclipse.pde.core.prefs
index 7d61edf..7d61edf 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.settings/org.eclipse.pde.core.prefs
+++ b/configurator/org.eclipes.rtp.core/.settings/org.eclipse.pde.core.prefs
diff --git a/configurator/org.eclipes.rtp.configurator.core/META-INF/MANIFEST.MF b/configurator/org.eclipes.rtp.core/META-INF/MANIFEST.MF
index 2574479..4a269f3 100644
--- a/configurator/org.eclipes.rtp.configurator.core/META-INF/MANIFEST.MF
+++ b/configurator/org.eclipes.rtp.core/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Configurator Core
-Bundle-SymbolicName: org.eclipes.rtp.configurator.core
+Bundle-SymbolicName: org.eclipes.rtp.core
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EclipseSource
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/configurator/org.eclipes.rtp.configurator.core/build.properties b/configurator/org.eclipes.rtp.core/build.properties
index e256c3f..e256c3f 100644
--- a/configurator/org.eclipes.rtp.configurator.core/build.properties
+++ b/configurator/org.eclipes.rtp.core/build.properties
diff --git a/configurator/org.eclipes.rtp.configurator.core/src/org/eclipse/rtp/configurator/core/IConfiguratorService.java b/configurator/org.eclipes.rtp.core/src/org/eclipse/rtp/configurator/core/IConfiguratorService.java
index 3890089..3890089 100644
--- a/configurator/org.eclipes.rtp.configurator.core/src/org/eclipse/rtp/configurator/core/IConfiguratorService.java
+++ b/configurator/org.eclipes.rtp.core/src/org/eclipse/rtp/configurator/core/IConfiguratorService.java
diff --git a/configurator/org.eclipse.rtp.configurator.console/META-INF/MANIFEST.MF b/configurator/org.eclipse.rtp.configurator.console/META-INF/MANIFEST.MF
index b85b557..65b8016 100644
--- a/configurator/org.eclipse.rtp.configurator.console/META-INF/MANIFEST.MF
+++ b/configurator/org.eclipse.rtp.configurator.console/META-INF/MANIFEST.MF
@@ -8,4 +8,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.core.runtime;version="3.4.0",
org.eclipse.osgi.framework.console;version="1.1.0"
Service-Component: OSGI-INF/rtpCommandProviderComponent.xml, OSGI-INF/rtpConfiguratorServiceReference.xml
-Require-Bundle: org.eclipes.rtp.configurator.core;bundle-version="1.0.0"
+Require-Bundle: org.eclipes.rtp.core;bundle-version="1.0.0"
diff --git a/configurator/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java b/configurator/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java
index ae61154..a84e100 100644
--- a/configurator/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java
+++ b/configurator/org.eclipse.rtp.configurator.console/src/org/eclipse/rtp/configurator/console/CommandDelegateImpl.java
@@ -13,7 +13,7 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.rtp.configurator.core.IConfiguratorService;
+import org.eclipse.rtp.core.IConfiguratorService;
public class CommandDelegateImpl implements CommandDelegate {
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/build.properties b/configurator/org.eclipse.rtp.configurator.service.provider/build.properties
deleted file mode 100644
index a70e9f2..0000000
--- a/configurator/org.eclipse.rtp.configurator.service.provider/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- OSGI-INF/rtpConfiguratorServiceProvider.xml
-source.. = src/
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java b/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
deleted file mode 100644
index b59a926..0000000
--- a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2011 EclipseSource 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:
-* EclipseSource - initial API and implementation
-*******************************************************************************/
-package org.eclipse.rtp.configurator.service.provider.internal.util;
-
-import java.net.URI;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
-import org.eclipse.rtp.configurator.service.provider.internal.ProviderActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-public class P2Util {
-
- public IProvisioningAgent getAgent() throws CoreException {
- BundleContext bundleContext = ProviderActivator.getBundleContext();
- String packageLocation = bundleContext.getProperty("package.location");
- URI packageLocationURI = new Path(packageLocation).append("p2").toFile().toURI();
- IProvisioningAgentProvider agentProvider = (IProvisioningAgentProvider) getService(bundleContext, IProvisioningAgentProvider.SERVICE_NAME);
- checkAgentAvailable(agentProvider);
- return agentProvider.createAgent(packageLocationURI);
- }
-
- private void checkAgentAvailable(IProvisioningAgentProvider agentProvider) throws CoreException {
- if (agentProvider == null) {
- String message = "Agent provider service not available"; //$NON-NLS-1$
- IStatus status = StatusUtil.createStatus(IStatus.ERROR, message, null);
- throw new CoreException(status);
- }
- }
-
- public Object getService(BundleContext context, String name) {
- if (context == null || name == null) {
- throw new IllegalArgumentException();
- }
- ServiceReference reference = context.getServiceReference(name);
- Object result = null;
- if (reference != null) {
- result = context.getService(reference);
- context.ungetService(reference);
- }
- return result;
- }
-
-}
diff --git a/configurator/org.eclipes.rtp.configurator.core/.classpath b/configurator/org.eclipse.rtp.core.service.provider.test/.classpath
index 8a8f166..8a8f166 100644
--- a/configurator/org.eclipes.rtp.configurator.core/.classpath
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/.classpath
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.project b/configurator/org.eclipse.rtp.core.service.provider.test/.project
index b4e150e..e4d4b29 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/.project
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.eclipse.rtp.configurator.service.provider.test</name>
+ <name>org.eclipse.rtp.core.service.provider.test</name>
<comment></comment>
<projects>
</projects>
diff --git a/configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.jdt.core.prefs b/configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.jdt.core.prefs
index 3dd9ba6..3dd9ba6 100644
--- a/configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.jdt.core.prefs
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.jdt.core.prefs
diff --git a/configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.jdt.ui.prefs b/configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.jdt.ui.prefs
index dacffb7..dacffb7 100644
--- a/configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.jdt.ui.prefs
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.jdt.ui.prefs
diff --git a/configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.pde.core.prefs b/configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.pde.core.prefs
index 7d61edf..7d61edf 100644
--- a/configurator/org.eclipes.rtp.configurator.core/.settings/org.eclipse.pde.core.prefs
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/.settings/org.eclipse.pde.core.prefs
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/META-INF/MANIFEST.MF b/configurator/org.eclipse.rtp.core.service.provider.test/META-INF/MANIFEST.MF
index 8b9bc63..87ee934 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/META-INF/MANIFEST.MF
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/META-INF/MANIFEST.MF
@@ -1,9 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
-Bundle-SymbolicName: org.eclipse.rtp.configurator.service.provider.test
+Bundle-SymbolicName: org.eclipse.rtp.core.service.provider.test
Bundle-Version: 1.0.0.qualifier
-Fragment-Host: org.eclipse.rtp.configurator.service.provider;bundle-version="1.0.0"
+Fragment-Host: org.eclipse.rtp.core.service.provider;bundle-version="1.0.0.qualifier"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="[4.8.2,4.9.0)",
org.mockito;bundle-version="[1.8.0,1.9.0)"
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/build.properties b/configurator/org.eclipse.rtp.core.service.provider.test/build.properties
index 41eb6ad..41eb6ad 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/build.properties
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/build.properties
diff --git a/configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceInstallCommandTest.java b/configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceInstallCommandTest.java
new file mode 100644
index 0000000..8ded208
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceInstallCommandTest.java
@@ -0,0 +1,164 @@
+package org.eclipse.rtp.configurator.service.provider.internal;
+/*******************************************************************************
+* Copyright (c) 2011 EclipseSource 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:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+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.IQueryResult;
+import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.rtp.configurator.service.provider.internal.util.P2Util;
+import org.junit.Before;
+import org.junit.Test;
+
+@SuppressWarnings("rawtypes")
+public class ConfiguratorServiceInstallCommandTest {
+
+ private DefaultConfiguratorService configuratorService;
+ private P2Util p2UtilMock;
+
+ @Before
+ public void setUp() {
+ configuratorService = new DefaultConfiguratorService();
+ p2UtilMock = mock(P2Util.class);
+ configuratorService.setP2Util(p2UtilMock);
+ }
+
+ @Test
+ public void testListNoRepositoryLoaded() throws CoreException {
+ URI[] knownRepositories = new URI[] { };
+ IMetadataRepository[] metadataRepositories = new IMetadataRepository[] { };
+ IMetadataRepositoryManager metadataRepositoryManagerMock = createMetadataRepositoryManagerMock(metadataRepositories, knownRepositories);
+ createAgentMock(metadataRepositoryManagerMock);
+
+ List<String> list = configuratorService.list();
+
+ assertTrue(list.isEmpty());
+ }
+
+ @Test
+ public void testListFromEmptyRepository() throws CoreException {
+ Iterator iteratorMock = mock(Iterator.class);
+ when(iteratorMock.hasNext()).thenReturn(false);
+ IQueryResult queryResultMock = createQueryResultMock(iteratorMock);
+ IMetadataRepository metadataRepositoryMock = createMetadataRepositoryMock(queryResultMock);
+ URI[] knownRepositories = new URI[] { URI.create("http://test.repository") };
+ IMetadataRepository[] metadataRepositories = new IMetadataRepository[] { metadataRepositoryMock };
+ IMetadataRepositoryManager metadataRepositoryManagerMock = createMetadataRepositoryManagerMock(metadataRepositories, knownRepositories);
+ createAgentMock(metadataRepositoryManagerMock);
+
+ List<String> list = configuratorService.list();
+
+ assertTrue(list.isEmpty());
+ }
+
+ @Test
+ public void testListFromOneRepository() throws CoreException {
+ String expectedIuId = "org.eclipse.test.bundle";
+ String expectedIuId2 = "org.eclipse.test.bundle2";
+ IInstallableUnit installableUnitMock = createIuMock(expectedIuId);
+ IInstallableUnit installableUnitMock2 = createIuMock(expectedIuId2);
+ Iterator iteratorMock = mock(Iterator.class);
+ when(iteratorMock.hasNext()).thenReturn(true, true, false);
+ when(iteratorMock.next()).thenReturn(installableUnitMock, installableUnitMock2);
+ IQueryResult queryResultMock = createQueryResultMock(iteratorMock);
+ IMetadataRepository metadataRepositoryMock = createMetadataRepositoryMock(queryResultMock);
+ URI[] knownRepositories = new URI[] { URI.create("http://test.repository") };
+ IMetadataRepository[] metadataRepositories = new IMetadataRepository[] { metadataRepositoryMock };
+ IMetadataRepositoryManager metadataRepositoryManagerMock = createMetadataRepositoryManagerMock(metadataRepositories, knownRepositories);
+ createAgentMock(metadataRepositoryManagerMock);
+
+ List<String> list = configuratorService.list();
+
+ assertTrue(list.size() == 2);
+ assertTrue(list.contains(expectedIuId));
+ assertTrue(list.contains(expectedIuId2));
+ }
+
+ @Test
+ public void testListFromTwoRepositories() throws CoreException {
+ String expectedIuId = "org.eclipse.test.bundle";
+ String expectedIuId2 = "org.eclipse.test.bundle2";
+ IInstallableUnit installableUnitMock = createIuMock(expectedIuId);
+ IInstallableUnit installableUnitMock2 = createIuMock(expectedIuId2);
+ Iterator iteratorMock = createIteratorMoc(installableUnitMock);
+ Iterator iteratorMock2 = createIteratorMoc(installableUnitMock2);
+ IQueryResult queryResultMock = createQueryResultMock(iteratorMock);
+ IQueryResult queryResultMock2 = createQueryResultMock(iteratorMock2);
+ IMetadataRepository metadataRepositoryMock = createMetadataRepositoryMock(queryResultMock);
+ IMetadataRepository metadataRepositoryMock2 = createMetadataRepositoryMock(queryResultMock2);
+ URI[] knownRepositories = new URI[] { URI.create("http://test.repository"), URI.create("http://test.repository2") };
+ IMetadataRepository[] metadataRepositories = new IMetadataRepository[] { metadataRepositoryMock, metadataRepositoryMock2 };
+ IMetadataRepositoryManager metadataRepositoryManagerMock =
+ createMetadataRepositoryManagerMock(metadataRepositories, knownRepositories);
+ createAgentMock(metadataRepositoryManagerMock);
+
+ List<String> list = configuratorService.list();
+
+ assertTrue(list.size() == 2);
+ assertTrue(list.contains(expectedIuId));
+ assertTrue(list.contains(expectedIuId2));
+ }
+
+ private void createAgentMock(
+ IMetadataRepositoryManager metadataRepositoryManagerMock)
+ throws CoreException {
+ IProvisioningAgent provisioningAgent = mock(IProvisioningAgent.class);
+ when(provisioningAgent.getService(IMetadataRepositoryManager.class.getName())).thenReturn(metadataRepositoryManagerMock);
+ }
+
+ private IMetadataRepositoryManager createMetadataRepositoryManagerMock(
+ IMetadataRepository[] metadataRepositories, URI[] knownRepositories)
+ throws ProvisionException {
+ IMetadataRepositoryManager metadataRepositoryManagerMock = mock(IMetadataRepositoryManager.class);
+ when(metadataRepositoryManagerMock.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL)).thenReturn(knownRepositories);
+ for (int i = 0; i < metadataRepositories.length; i++) {
+ when(metadataRepositoryManagerMock.loadRepository(knownRepositories[i], null)).thenReturn(metadataRepositories[i]);
+ }
+ return metadataRepositoryManagerMock;
+ }
+
+ private IMetadataRepository createMetadataRepositoryMock(IQueryResult queryResultMock) {
+ IMetadataRepository metadataRepositoryMock = mock(IMetadataRepository.class);
+ when(metadataRepositoryMock.query(QueryUtil.createIUAnyQuery(), null)).thenReturn(queryResultMock);
+ return metadataRepositoryMock;
+ }
+
+ private IQueryResult createQueryResultMock(Iterator iteratorMock) {
+ IQueryResult queryResultMock = mock(IQueryResult.class);
+ when(queryResultMock.iterator()).thenReturn(iteratorMock);
+ return queryResultMock;
+ }
+
+ private Iterator createIteratorMoc(IInstallableUnit installableUnitMock) {
+ Iterator iteratorMock = mock(Iterator.class);
+ when(iteratorMock.hasNext()).thenReturn(true, false);
+ when(iteratorMock.next()).thenReturn(installableUnitMock);
+ return iteratorMock;
+ }
+
+ private IInstallableUnit createIuMock(String expectedIuId) {
+ IInstallableUnit installableUnitMock = mock(IInstallableUnit.class);
+ when(installableUnitMock.getId()).thenReturn(expectedIuId);
+ return installableUnitMock;
+ }
+
+}
diff --git a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceListCommandTest.java b/configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceListCommandTest.java
index 3b87ddb..4e4ccd7 100644
--- a/configurator.test/org.eclipse.rtp.configurator.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceListCommandTest.java
+++ b/configurator/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceListCommandTest.java
@@ -123,7 +123,6 @@ public class ConfiguratorServiceListCommandTest {
throws CoreException {
IProvisioningAgent provisioningAgent = mock(IProvisioningAgent.class);
when(provisioningAgent.getService(IMetadataRepositoryManager.class.getName())).thenReturn(metadataRepositoryManagerMock);
- when(p2UtilMock.getAgent()).thenReturn(provisioningAgent);
}
private IMetadataRepositoryManager createMetadataRepositoryManagerMock(
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/.classpath b/configurator/org.eclipse.rtp.core.service.provider/.classpath
index 8a8f166..8a8f166 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/.classpath
+++ b/configurator/org.eclipse.rtp.core.service.provider/.classpath
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/.project b/configurator/org.eclipse.rtp.core.service.provider/.project
index b6b8a8e..18928c0 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/.project
+++ b/configurator/org.eclipse.rtp.core.service.provider/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.eclipse.rtp.configurator.service.provider</name>
+ <name>org.eclipse.rtp.core.service.provider</name>
<comment></comment>
<projects>
</projects>
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.jdt.core.prefs b/configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.jdt.core.prefs
index 3dd9ba6..3dd9ba6 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.jdt.core.prefs
+++ b/configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.jdt.core.prefs
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.jdt.ui.prefs b/configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.jdt.ui.prefs
index dacffb7..dacffb7 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.jdt.ui.prefs
+++ b/configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.jdt.ui.prefs
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.pde.core.prefs b/configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.pde.core.prefs
index 7d61edf..7d61edf 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/.settings/org.eclipse.pde.core.prefs
+++ b/configurator/org.eclipse.rtp.core.service.provider/.settings/org.eclipse.pde.core.prefs
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/META-INF/MANIFEST.MF b/configurator/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF
index 5a50d9e..bc14d4f 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/META-INF/MANIFEST.MF
+++ b/configurator/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF
@@ -1,17 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Configurator Service Provider
-Bundle-SymbolicName: org.eclipse.rtp.configurator.service.provider
+Bundle-SymbolicName: org.eclipse.rtp.core.service.provider
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EclipseSource
Require-Bundle: org.eclipse.core.runtime,
- org.eclipes.rtp.configurator.core;bundle-version="1.0.0"
+ org.eclipes.rtp.core;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Service-Component: OSGI-INF/rtpConfiguratorServiceProvider.xml
+Service-Component: OSGI-INF/rtpConfiguratorServiceProvider.xml, OSGI-INF/rtpConfigurator.xml
Bundle-Activator: org.eclipse.rtp.configurator.service.provider.internal.ProviderActivator
-Import-Package: org.eclipse.equinox.p2.core,
+Import-Package: org.apache.commons.io;version="2.0.1",
+ org.eclipse.equinox.internal.provisional.configurator,
+ org.eclipse.equinox.p2.core,
+ org.eclipse.equinox.p2.engine;version="2.0.0",
org.eclipse.equinox.p2.metadata;version="2.1.0",
+ org.eclipse.equinox.p2.operations;version="2.0.0",
org.eclipse.equinox.p2.query;version="2.0.0",
org.eclipse.equinox.p2.repository;version="2.0.0",
+ org.eclipse.equinox.p2.repository.artifact;version="2.0.0",
org.eclipse.equinox.p2.repository.metadata;version="2.0.0"
diff --git a/configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml b/configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml
new file mode 100644
index 0000000..8489ce9
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="setUp" name="org.eclipse.rtp.configurator.service.provider">
+ <implementation class="org.eclipse.rtp.configurator.service.provider.internal.util.P2Util"/>
+ <reference bind="setConfigurator" cardinality="1..1" interface="org.eclipse.equinox.internal.provisional.configurator.Configurator" name="Configurator" policy="static" unbind="unsetConfigurator"/>
+</scr:component>
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml b/configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml
index b8167c0..b8167c0 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml
+++ b/configurator/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml
diff --git a/configurator/org.eclipse.rtp.core.service.provider/build.properties b/configurator/org.eclipse.rtp.core.service.provider/build.properties
new file mode 100644
index 0000000..8a5fab1
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/build.properties
@@ -0,0 +1,6 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/rtpConfiguratorServiceProvider.xml,\
+ OSGI-INF/rtpConfigurator.xml
+source.. = src/
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
index e5db933..1ea9988 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
@@ -9,19 +9,10 @@
*******************************************************************************/
package org.eclipse.rtp.configurator.service.provider.internal;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-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.metadata.IMetadataRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.rtp.configurator.core.IConfiguratorService;
import org.eclipse.rtp.configurator.service.provider.internal.util.P2Util;
@@ -73,27 +64,7 @@ public class DefaultConfiguratorService implements IConfiguratorService {
@Override
public List<String> list() throws CoreException {
- List<String> resutl = new ArrayList<String>();
- IProvisioningAgent agent = p2Util.getAgent();
- IMetadataRepositoryManager metadataRepositoryManager = (IMetadataRepositoryManager) agent
- .getService(IMetadataRepositoryManager.class.getName());
- URI [] knownRepositories = metadataRepositoryManager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
- for (URI repositoryURI : knownRepositories) {
- IMetadataRepository repository = metadataRepositoryManager.loadRepository(repositoryURI, null);
- IQueryResult<IInstallableUnit> queryResult = repository.query(QueryUtil.createIUAnyQuery(), null);
- addResult(resutl, queryResult);
- }
- return resutl;
- }
-
- private void addResult(List<String> resutl, IQueryResult<IInstallableUnit> queryResult) {
- Iterator<IInstallableUnit> iterator = queryResult.iterator();
- while (iterator.hasNext()) {
- IInstallableUnit installableUnit = (IInstallableUnit) iterator.next();
- if(!resutl.contains(installableUnit)){
- resutl.add(installableUnit.getId());
- }
- }
+ return null;
}
@Override
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/ProviderActivator.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/ProviderActivator.java
index beec000..beec000 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/ProviderActivator.java
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/ProviderActivator.java
diff --git a/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureInstallException.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureInstallException.java
new file mode 100644
index 0000000..56fe8e9
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureInstallException.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+* Copyright (c) 2011 EclipseSource 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:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.rtp.configurator.service.provider.internal.deploy;
+
+public class FeatureInstallException extends Exception {
+
+ private static final long serialVersionUID = 7654279780139556052L;
+
+ public FeatureInstallException(Exception e) {
+ // TODO: Not tested
+ super(e);
+ }
+
+ public FeatureInstallException(String message) {
+ super(message);
+ }
+}
diff --git a/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
new file mode 100644
index 0000000..2e751e5
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/FeatureManager.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+* Copyright (c) 2011 EclipseSource 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:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.rtp.configurator.service.provider.internal.deploy;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.provisional.configurator.Configurator;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.operations.InstallOperation;
+import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
+import org.eclipse.equinox.p2.operations.ProvisioningJob;
+import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.p2.operations.UninstallOperation;
+import org.eclipse.equinox.p2.query.QueryUtil;
+
+@SuppressWarnings("restriction")
+public class FeatureManager {
+
+ public enum Action {
+ UNINSTALL, INSTALL
+ }
+
+ private final IProvisioningAgent provisioningAgent;
+ private final RepositoryManager repositoryManager;
+ private final Configurator configurator;
+
+ public FeatureManager(IProvisioningAgent provisioningAgent, RepositoryManager repositoryManager, Configurator configurator) {
+ this.provisioningAgent = provisioningAgent;
+ this.repositoryManager = repositoryManager;
+ this.configurator = configurator;
+ }
+
+ // TODO: Not tested
+ public void installFeature(String featureId, String version) throws FeatureInstallException {
+ ProfileChangeOperation operation = resolveProfileChangeOperation(featureId, version, Action.INSTALL);
+ executeProfileChangeOperation(operation);
+ applyChanges();
+ }
+
+ // TODO: Not tested
+ public void uninstallFeature(String featureId, String version) throws FeatureInstallException {
+ ProfileChangeOperation operation = resolveProfileChangeOperation(featureId, version, Action.UNINSTALL);
+ executeProfileChangeOperation(operation);
+ applyChanges();
+ }
+
+ // TODO: Not tested
+ private ProfileChangeOperation resolveProfileChangeOperation(String featureId, String version, Action action)
+ throws FeatureInstallException {
+ ProvisioningSession session = new ProvisioningSession(provisioningAgent);
+ ProvisioningContext context = createProvisioningContext();
+
+ Collection<IInstallableUnit> units = getInstallableUnits(context, featureId, version);
+ ProfileChangeOperation operation = getOperation(session, units, action);
+ operation.setProvisioningContext(context);
+ resolveOperation(operation);
+
+ return operation;
+ }
+
+ private ProfileChangeOperation getOperation(ProvisioningSession session, Collection<IInstallableUnit> units, Action action)
+ throws FeatureInstallException {
+ ProfileChangeOperation operation;
+ if (action.equals(Action.UNINSTALL)) {
+ operation = new UninstallOperation(session, units);
+ } else {
+ operation = new InstallOperation(session, units);
+ }
+
+ return operation;
+ }
+
+ private void resolveOperation(ProfileChangeOperation operation) throws FeatureInstallException {
+ IStatus result = operation.resolveModal(null);
+
+ if (!result.isOK()) {
+ String errorMessage = generateErrorMessage(result);
+ throw new FeatureInstallException(errorMessage);
+ }
+ }
+
+ private void applyChanges() throws FeatureInstallException {
+ try {
+ configurator.applyConfiguration();
+ } catch (IOException e) {
+ throw new FeatureInstallException(e);
+ }
+ }
+
+ protected ProvisioningContext createProvisioningContext() {
+ ProvisioningContext context = new ProvisioningContext(provisioningAgent);
+ context.setArtifactRepositories(repositoryManager.getRepositories());
+ context.setArtifactRepositories(repositoryManager.getRepositories());
+ return context;
+ }
+
+ protected void executeProfileChangeOperation(ProfileChangeOperation operation) throws FeatureInstallException {
+ ProvisioningJob provisioningJob = operation.getProvisioningJob(new NullProgressMonitor());
+ if (provisioningJob == null) {
+ return;
+ }
+
+ IStatus result = provisioningJob.runModal(new NullProgressMonitor());
+
+ if (!result.isOK()) {
+ throw new FeatureInstallException(result.getMessage());
+ }
+ }
+
+ private String generateErrorMessage(IStatus result) {
+ IStatus[] children = result.getChildren();
+ String message = "";
+ for (int i = 0; i < children.length; i++) {
+ message = children[i].getMessage() + "\n";
+ }
+ return message;
+ }
+
+ protected Collection<IInstallableUnit> getInstallableUnits(ProvisioningContext context, String id, String version) {
+ Collection<IInstallableUnit> toInstall = context.getMetadata(null)
+ .query(QueryUtil.createIUQuery(id, Version.create(version)), null).toUnmodifiableSet();
+ return toInstall;
+ }
+} \ No newline at end of file
diff --git a/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/InvalidRepositoryException.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/InvalidRepositoryException.java
new file mode 100644
index 0000000..507ea79
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/InvalidRepositoryException.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+* Copyright (c) 2011 EclipseSource 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:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.rtp.configurator.service.provider.internal.deploy;
+
+public class InvalidRepositoryException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public InvalidRepositoryException(String string) {
+ super(string);
+ }
+}
diff --git a/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/RepositoryManager.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/RepositoryManager.java
new file mode 100644
index 0000000..004b259
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/deploy/RepositoryManager.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+* Copyright (c) 2011 EclipseSource 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:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.rtp.configurator.service.provider.internal.deploy;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.commons.io.FileUtils;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+
+public class RepositoryManager {
+
+ private static final String LOCAL_REPOSITORY_PREFIX = "repo_"; //$NON-NLS-N$
+ private static final String FILENAME_CONTENT = "content.jar"; //$NON-NLS-N$
+ private static final String FILENAME_ARTIFACTS = "artifacts.jar"; //$NON-NLS-N$
+ private static final int FILE_BUFFER = 8192;
+ private final IProvisioningAgent provisioningAgent;
+
+ public RepositoryManager(IProvisioningAgent provisioningAgent) {
+ this.provisioningAgent = provisioningAgent;
+ }
+
+ public URI[] getRepositories() {
+ IMetadataRepositoryManager metaRepoManager = getMetadataRepositoryManager();
+
+ return metaRepoManager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
+ }
+
+ public List<IMetadataRepository> getMetadataRepositories() throws ProvisionException, OperationCanceledException {
+ List<IMetadataRepository> result = new ArrayList<IMetadataRepository>();
+ IMetadataRepositoryManager metaRepoManager = getMetadataRepositoryManager();
+ URI[] knownRepositories = metaRepoManager.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL);
+ for (URI uri : knownRepositories) {
+ IMetadataRepository repository = metaRepoManager.loadRepository(uri, null);
+ result.add(repository);
+ }
+ return result;
+ }
+
+
+ public void addRepository(URI repository) {
+ IMetadataRepositoryManager metaRepoManager = getMetadataRepositoryManager();
+ IArtifactRepositoryManager artiRepoManager = getArtifactRepositoryManager();
+
+ metaRepoManager.addRepository(repository);
+ artiRepoManager.addRepository(repository);
+ }
+
+ public URI addRepository(InputStream inputStream) throws InvalidRepositoryException, FileNotFoundException, IOException {
+ ZipInputStream zis = new ZipInputStream(inputStream);
+ File repository = createLocalRepository(zis);
+ URI repositoryURI = repository.toURI();
+ addRepository(repositoryURI);
+
+ return repositoryURI;
+ }
+
+ private File createLocalRepository(ZipInputStream zis) throws InvalidRepositoryException, IOException, FileNotFoundException {
+ File repository = new File(System.getProperty("java.io.tmpdir") + File.separator + LOCAL_REPOSITORY_PREFIX
+ + Long.toString(System.nanoTime()));
+ repository.mkdirs();
+ createLocalRepositoryStructure(zis, repository);
+
+ try {
+ validateLocalRepository(repository);
+ } catch (InvalidRepositoryException e) {
+ FileUtils.deleteDirectory(repository);
+ throw e;
+ }
+
+ return repository;
+ }
+
+ public void removeRepository(URI repository) {
+ IMetadataRepositoryManager metaRepoManager = getMetadataRepositoryManager();
+ IArtifactRepositoryManager artiRepoManager = getArtifactRepositoryManager();
+
+ metaRepoManager.removeRepository(repository);
+ artiRepoManager.removeRepository(repository);
+ }
+
+ private void createLocalRepositoryStructure(ZipInputStream zis, File repository) throws IOException, FileNotFoundException {
+ ZipEntry currentFile;
+ while ((currentFile = zis.getNextEntry()) != null) {
+ if (currentFile.isDirectory()) {
+ createLocalDirectory(repository, currentFile);
+ } else {
+ createLocalFile(zis, repository, currentFile);
+ }
+ }
+ }
+
+ private void createLocalDirectory(File repository, ZipEntry currentFile) {
+ File file = new File(repository.getAbsolutePath() + File.separator + currentFile.getName());
+ file.mkdirs();
+ }
+
+ private void createLocalFile(ZipInputStream zis, File repository, ZipEntry currentFile) throws IOException,
+ FileNotFoundException {
+ File file = new File(repository.getAbsolutePath() + File.separator + currentFile.getName());
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ FileOutputStream fos = new FileOutputStream(file);
+ BufferedOutputStream bfos = new BufferedOutputStream(fos, FILE_BUFFER);
+ saveFileData(zis, bfos);
+ }
+
+ private void saveFileData(ZipInputStream zis, BufferedOutputStream bfos) throws IOException {
+ int resultLength;
+ byte[] data = new byte[FILE_BUFFER];
+ while ((resultLength = zis.read(data, 0, FILE_BUFFER)) != -1) {
+ bfos.write(data, 0, resultLength);
+ }
+ bfos.flush();
+ bfos.close();
+ }
+
+ public void validateLocalRepository(File repository) throws InvalidRepositoryException {
+ File[] files = repository.listFiles();
+ boolean artifactsFound = false;
+ boolean contentFound = false;
+
+ for (File file : files) {
+ if (file.getName().equals(FILENAME_ARTIFACTS)) {
+ artifactsFound = true;
+ } else if (file.getName().equals(FILENAME_CONTENT)) {
+ contentFound = true;
+ }
+ }
+
+ if (!artifactsFound || !contentFound) {
+ throw new InvalidRepositoryException("invalid repository: required files not found");
+ }
+ }
+
+ public IMetadataRepositoryManager getMetadataRepositoryManager() {
+ IMetadataRepositoryManager service = (IMetadataRepositoryManager) provisioningAgent
+ .getService(IMetadataRepositoryManager.SERVICE_NAME);
+
+ return service;
+ }
+
+ public IArtifactRepositoryManager getArtifactRepositoryManager() {
+ IArtifactRepositoryManager service = (IArtifactRepositoryManager) provisioningAgent
+ .getService(IArtifactRepositoryManager.SERVICE_NAME);
+
+ return service;
+ }
+
+ public void removeLocalRepository(URI repository) throws IOException {
+ FileUtils.deleteDirectory(new File(repository));
+ removeRepository(repository);
+ }
+} \ No newline at end of file
diff --git a/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
new file mode 100644
index 0000000..053baa0
--- /dev/null
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+* Copyright (c) 2011 EclipseSource 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:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.rtp.configurator.service.provider.internal.util;
+
+import java.net.URI;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.equinox.internal.provisional.configurator.Configurator;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
+import org.eclipse.rtp.configurator.service.provider.internal.ProviderActivator;
+import org.eclipse.rtp.configurator.service.provider.internal.deploy.FeatureManager;
+import org.eclipse.rtp.configurator.service.provider.internal.deploy.RepositoryManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class P2Util {
+
+ private static Configurator configurator;
+ private static RepositoryManager repositoryManager;
+ private static IProvisioningAgent provisioningAgent;
+ private static FeatureManager featureManager;
+
+ public static FeatureManager getFeatureManager(){
+ return featureManager;
+ }
+
+ public static RepositoryManager getRepositoryManager(){
+ return repositoryManager;
+ }
+
+ public static void setConfigurator(Configurator configuratorService){
+ P2Util.configurator = configuratorService;
+ }
+
+ public static void unsetConfigurator(Configurator configuratorService){
+ P2Util.configurator = null;
+ }
+
+ protected static void startService() throws CoreException {
+ provisioningAgent = getAgent();
+ repositoryManager = new RepositoryManager(provisioningAgent);
+ featureManager = new FeatureManager(provisioningAgent, repositoryManager, configurator);
+ }
+
+ protected static void shutdown() {
+ featureManager = null;
+ repositoryManager = null;
+ provisioningAgent.stop();
+ provisioningAgent = null;
+ configurator = null;
+ }
+
+ private static IProvisioningAgent getAgent() throws CoreException {
+ BundleContext bundleContext = ProviderActivator.getBundleContext();
+ String packageLocation = bundleContext.getProperty("package.location");
+ URI packageLocationURI = new Path(packageLocation).append("p2").toFile().toURI();
+ IProvisioningAgentProvider agentProvider = getService(bundleContext, IProvisioningAgentProvider.class, IProvisioningAgentProvider.SERVICE_NAME);
+ checkAgentAvailable(agentProvider);
+ return agentProvider.createAgent(packageLocationURI);
+ }
+
+ private static void checkAgentAvailable(IProvisioningAgentProvider agentProvider) throws CoreException {
+ if (agentProvider == null) {
+ String message = "Agent provider service not available"; //$NON-NLS-1$
+ IStatus status = StatusUtil.createStatus(IStatus.ERROR, message, null);
+ throw new CoreException(status);
+ }
+ }
+
+ private static <T> T getService(BundleContext context, Class<T> type, String name) {
+ if (context == null || name == null) {
+ throw new IllegalArgumentException();
+ }
+ ServiceReference<?> reference = context.getServiceReference(name);
+ T result = null;
+ if (reference != null) {
+ result = (T) context.getService(reference);
+ context.ungetService(reference);
+ }
+ return result;
+ }
+}
diff --git a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/StatusUtil.java b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/StatusUtil.java
index 8376c16..8376c16 100644
--- a/configurator/org.eclipse.rtp.configurator.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/StatusUtil.java
+++ b/configurator/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/StatusUtil.java
diff --git a/configurator.test/org.eclipse.rtp.configurator.core.test/.classpath b/configurator/org.eclipse.rtp.core.test/.classpath
index 78d5ded..78d5ded 100644
--- a/configurator.test/org.eclipse.rtp.configurator.core.test/.classpath
+++ b/configurator/org.eclipse.rtp.core.test/.classpath
diff --git a/configurator.test/org.eclipse.rtp.configurator.core.test/.project b/configurator/org.eclipse.rtp.core.test/.project
index e1aba3b..b1a93c0 100644
--- a/configurator.test/org.eclipse.rtp.configurator.core.test/.project
+++ b/configurator/org.eclipse.rtp.core.test/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.eclipse.rtp.configurator.core.test</name>
+ <name>org.eclipse.rtp.core.test</name>
<comment></comment>
<projects>
</projects>
diff --git a/configurator.test/org.eclipse.rtp.configurator.core.test/.settings/org.eclipse.jdt.core.prefs b/configurator/org.eclipse.rtp.core.test/.settings/org.eclipse.jdt.core.prefs
index 3160500..3160500 100644
--- a/configurator.test/org.eclipse.rtp.configurator.core.test/.settings/org.eclipse.jdt.core.prefs
+++ b/configurator/org.eclipse.rtp.core.test/.settings/org.eclipse.jdt.core.prefs
diff --git a/configurator.test/org.eclipse.rtp.configurator.core.test/META-INF/MANIFEST.MF b/configurator/org.eclipse.rtp.core.test/META-INF/MANIFEST.MF
index e736dc9..83f4beb 100644
--- a/configurator.test/org.eclipse.rtp.configurator.core.test/META-INF/MANIFEST.MF
+++ b/configurator/org.eclipse.rtp.core.test/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Core Test
-Bundle-SymbolicName: org.eclipse.rtp.configurator.core.test
+Bundle-SymbolicName: org.eclipse.rtp.core.test
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EclipseSource
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/configurator.test/org.eclipse.rtp.configurator.core.test/build.properties b/configurator/org.eclipse.rtp.core.test/build.properties
index 577870e..577870e 100644
--- a/configurator.test/org.eclipse.rtp.configurator.core.test/build.properties
+++ b/configurator/org.eclipse.rtp.core.test/build.properties