aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-09-26 02:28:16 (EDT)
committerbveliev2011-09-26 02:28:16 (EDT)
commit00b392d7c9ef1e26492c6383a7a7c4cd88b523e4 (patch)
treee774d36b3d640288eddd178815193fca02d2299a
parent3f690b4ceefd243fa3a7115b85bdda94ab5ecb26 (diff)
downloadorg.eclipse.rtp-00b392d7c9ef1e26492c6383a7a7c4cd88b523e4.zip
org.eclipse.rtp-00b392d7c9ef1e26492c6383a7a7c4cd88b523e4.tar.gz
org.eclipse.rtp-00b392d7c9ef1e26492c6383a7a7c4cd88b523e4.tar.bz2
* search APIs of configuration services implemented
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF3
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json30
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java (renamed from configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceMarshallerTest.java)18
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/test/AllModelTestSuite.java4
-rw-r--r--configurator/org.eclipse.rtp.configurator.console/RT Configurator Console.launch50
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/META-INF/MANIFEST.MF3
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/OSGI-INF/sourceUnMarshaler.xml (renamed from configurator/org.eclipse.rtp.configurator.model/OSGI-INF/SourceMarshaller.xml)14
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/build.properties12
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Source.java14
-rw-r--r--configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java8
-rw-r--r--core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java105
-rw-r--r--core/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml2
-rw-r--r--core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml5
-rw-r--r--core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml2
-rw-r--r--core/org.eclipse.rtp.core.service.provider/build.properties4
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java169
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java32
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java4
19 files changed, 361 insertions, 123 deletions
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF b/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF
index 92d72e7..dc1488d 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/META-INF/MANIFEST.MF
@@ -6,4 +6,5 @@ Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.eclipse.rtp.configurator.model;bundle-version="1.0.0"
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)"
+ org.mockito;bundle-version="[1.8.0,1.9.0)",
+ org.eclipse.core.runtime;bundle-version="3.7.0"
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json b/configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json
new file mode 100644
index 0000000..c6ec22f
--- /dev/null
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/data/example-sources.json
@@ -0,0 +1,30 @@
+{
+ "sources": [
+ {
+ "name": "rap",
+ "description": "Some text",
+ "infoUrl": "http://foo.bar/info",
+ "versions": [
+ {
+ "version": "1.4",
+ "repositoryUrl": "http://foo.bar"
+ },
+ {
+ "version": "1.5",
+ "repositoryUrl": "http://foo.bar2"
+ }
+ ]
+ },
+ {
+ "name": "equinox",
+ "description": "Some text3",
+ "infoUrl": "http://foo.bar/info3",
+ "versions": [
+ {
+ "version": "3.8.1",
+ "repositoryUrl": "http://foo.bar3"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceMarshallerTest.java b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java
index 891f16a..44b60b8 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceMarshallerTest.java
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceUnMarshallerTest.java
@@ -11,14 +11,21 @@ package org.eclipse.rtp.configurator.model;
import static org.junit.Assert.assertEquals;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.rtp.configurator.model.internal.SourceUnMarshallerImpl;
import org.junit.Test;
+import org.osgi.framework.Bundle;
-public class SourceMarshallerTest {
+public class SourceUnMarshallerTest {
@Test
public void first() throws IOException {
@@ -66,9 +73,12 @@ public class SourceMarshallerTest {
assertEquals( "http://foo.bar3", source1.getRepositoryUrl() );
}
- private InputStream readExampleSources() {
- String path = "example-sources.json";
- return getClass().getResourceAsStream( path );
+ private InputStream readExampleSources() throws IOException {
+ Bundle bundle = Platform.getBundle( "org.eclipse.rtp.configurator.model.test" );
+ URL unResolvedUrl = FileLocator.find( bundle, new Path("data/example-sources.json"), null );
+ URL testDataUrl = FileLocator.resolve( unResolvedUrl );
+ File testDataFile = new Path( testDataUrl.getFile() ).toFile();
+ return new FileInputStream( testDataFile );
}
}
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/test/AllModelTestSuite.java b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/test/AllModelTestSuite.java
index efb685a..095970b 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/test/AllModelTestSuite.java
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/test/AllModelTestSuite.java
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.rtp.configurator.model.test;
-import org.eclipse.rtp.configurator.model.SourceMarshallerTest;
+import org.eclipse.rtp.configurator.model.SourceUnMarshallerTest;
import org.eclipse.rtp.configurator.model.SourceProviderTest;
import org.eclipse.rtp.configurator.model.SourceTest;
import org.eclipse.rtp.configurator.model.SourceVersionTest;
@@ -22,7 +22,7 @@ import org.junit.runners.Suite.SuiteClasses;
SourceProviderTest.class,
SourceTest.class,
SourceVersionTest.class,
- SourceMarshallerTest.class
+ SourceUnMarshallerTest.class
} )
public class AllModelTestSuite {
// no content
diff --git a/configurator/org.eclipse.rtp.configurator.console/RT Configurator Console.launch b/configurator/org.eclipse.rtp.configurator.console/RT Configurator Console.launch
index b3d19a8..e7c59b6 100644
--- a/configurator/org.eclipse.rtp.configurator.console/RT Configurator Console.launch
+++ b/configurator/org.eclipse.rtp.configurator.console/RT Configurator Console.launch
@@ -1,25 +1,25 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.pde.ui.EquinoxLauncher">
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/RTP Console"/>
-<booleanAttribute key="default" value="true"/>
-<booleanAttribute key="default_auto_start" value="true"/>
-<intAttribute key="default_start_level" value="4"/>
-<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.rtp.configurator.test"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Declipse.ignoreApp=true -Dosgi.noShutdown=true"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="org.eclipse.equinox.ds@default:true,org.eclipse.osgi.services@default:default,org.eclipse.equinox.util@default:default,org.eclipse.osgi@-1:true"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useCustomFeatures" value="false"/>
-<booleanAttribute key="useDefaultConfigArea" value="true"/>
-<stringAttribute key="workspace_bundles" value="org.eclipse.rtp.configurator.console@default:default"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.EquinoxLauncher">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/RTP Console"/>
+<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="default_auto_start" value="true"/>
+<intAttribute key="default_start_level" value="4"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.rtp.configurator.test"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Declipse.ignoreApp=true -Dosgi.noShutdown=true"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="target_bundles" value="org.eclipse.equinox.ds@default:true,org.eclipse.equinox.util@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<stringAttribute key="workspace_bundles" value="org.eclipes.rtp.core@default:default,org.eclipse.rtp.configurator.console@default:default,org.eclipse.rtp.configurator.model.test@default:false,org.eclipse.rtp.configurator.model@default:default,org.eclipse.rtp.core.service.provider.test@default:false,org.eclipse.rtp.core.service.provider@default:default,org.eclipse.rtp.core.test@default:default"/>
+</launchConfiguration>
diff --git a/configurator/org.eclipse.rtp.configurator.model/META-INF/MANIFEST.MF b/configurator/org.eclipse.rtp.configurator.model/META-INF/MANIFEST.MF
index de92953..4bf826a 100644
--- a/configurator/org.eclipse.rtp.configurator.model/META-INF/MANIFEST.MF
+++ b/configurator/org.eclipse.rtp.configurator.model/META-INF/MANIFEST.MF
@@ -7,4 +7,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.google.gson;version="[1.6.0,2.0.0)",
com.google.gson.stream;version="[1.6.0,2.0.0)"
Export-Package: org.eclipse.rtp.configurator.model;version="1.0.0"
-Service-Component: OSGI-INF/SourceMarshaller.xml
+Service-Component: OSGI-INF/sourceUnMarshaler.xml
+Bundle-ActivationPolicy: lazy
diff --git a/configurator/org.eclipse.rtp.configurator.model/OSGI-INF/SourceMarshaller.xml b/configurator/org.eclipse.rtp.configurator.model/OSGI-INF/sourceUnMarshaler.xml
index b84b2dc..c91b94e 100644
--- a/configurator/org.eclipse.rtp.configurator.model/OSGI-INF/SourceMarshaller.xml
+++ b/configurator/org.eclipse.rtp.configurator.model/OSGI-INF/sourceUnMarshaler.xml
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="SourceMarshaller">
- <implementation class="org.eclipse.rtp.configurator.model.internal.SourceMarshallerImpl"/>
- <service>
- <provide interface="org.eclipse.rtp.configurator.model.SourceMarshaller"/>
- </service>
-</scr:component>
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.configurator.model">
+ <implementation class="org.eclipse.rtp.configurator.model.internal.SourceUnMarshallerImpl"/>
+ <service>
+ <provide interface="org.eclipse.rtp.configurator.model.SourceUnMarshaller"/>
+ </service>
+</scr:component>
diff --git a/configurator/org.eclipse.rtp.configurator.model/build.properties b/configurator/org.eclipse.rtp.configurator.model/build.properties
index 6210e84..a9f567d 100644
--- a/configurator/org.eclipse.rtp.configurator.model/build.properties
+++ b/configurator/org.eclipse.rtp.configurator.model/build.properties
@@ -1,5 +1,7 @@
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- OSGI-INF/
-source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ OSGI-INF/sourceMarshaller.xml,\
+ OSGI-INF/sourceUnMarshaler.xml
+source.. = src/
diff --git a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Source.java b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Source.java
index 3332d0b..04976e9 100644
--- a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Source.java
+++ b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/Source.java
@@ -17,9 +17,9 @@ import java.util.List;
public class Source {
private String name;
- private List<SourceVersion> versions;
private String description;
private String infoUrl;
+ private List<SourceVersion> versions;
Source() {
@@ -52,4 +52,16 @@ public class Source {
public String getInfoUrl() {
return infoUrl;
}
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ result.append( "Name: " + name + "\n");
+ result.append( "Description: " + description + "\n");
+ result.append( "Information URL: " + infoUrl + "\n");
+ for( SourceVersion version : versions ) {
+ result.append( version.toString() + "\n" );
+ }
+ return result.toString();
+ }
}
diff --git a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java
index 99701d9..389b02f 100644
--- a/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java
+++ b/configurator/org.eclipse.rtp.configurator.model/src/org/eclipse/rtp/configurator/model/SourceVersion.java
@@ -31,4 +31,12 @@ public class SourceVersion {
public String getRepositoryUrl() {
return repositoryUrl;
}
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ result.append( "Version: " + version + "\n" );
+ result.append( "Repository URL: " + repositoryUrl + "\n" );
+ return result.toString();
+ }
}
diff --git a/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java
new file mode 100644
index 0000000..399f603
--- /dev/null
+++ b/core.test/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceSearchTest.java
@@ -0,0 +1,105 @@
+package org.eclipse.rtp.configurator.service.provider.internal;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.rtp.configurator.model.Source;
+import org.eclipse.rtp.configurator.model.SourceProvider;
+import org.eclipse.rtp.configurator.model.SourceUnMarshaller;
+import org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+
+public class ConfiguratorServiceSearchTest {
+
+ private SourceProvider provider;
+ private DefaultConfiguratorService configuratorService;
+
+ @Before
+ public void setUp() throws IOException{
+ configuratorService = new DefaultConfiguratorService();
+ InputStream stream = readExampleSources();
+ SourceUnMarshaller marshaller = ConfiguratorModelUtil.getSourceUnMarshaller();
+ provider = marshaller.marshal( stream );
+ ConfiguratorModelUtil.setSourceProvider( provider );
+ }
+
+ @Test
+ public void testList() throws CoreException
+ {
+ List<String> listExpected = getSortedTestData();
+
+ List<String> list = configuratorService.list();
+
+ assertTrue( Arrays.equals( listExpected.toArray( ), list.toArray( ) ) );
+ }
+
+ @Test
+ public void testShow() throws CoreException
+ {
+ List<String> listExpected = getSortedTestData();
+ List<String> showParameters = new ArrayList<String>();
+ showParameters.add( "equinox" );
+
+ List<String> list = configuratorService.show( showParameters );
+
+ assertTrue( Arrays.equals( new String[]{ listExpected.get( 0 ) }, list.toArray( ) ) );
+ }
+
+ @Test
+ public void testShowManyParameters() throws CoreException
+ {
+ List<String> listExpected = getSortedTestData();
+ List<String> showParameters = new ArrayList<String>();
+ showParameters.add( "equinox" );
+
+ List<String> list = configuratorService.show( showParameters );
+
+ assertTrue( Arrays.equals( new String[]{ listExpected.get( 0 ) }, list.toArray( ) ) );
+ }
+
+ @Test
+ public void testSearch() throws CoreException
+ {
+ List<String> listExpected = getSortedTestData();
+ List<String> searchParameters = new ArrayList<String>();
+ searchParameters.add( "ra" );
+
+ List<String> list = configuratorService.search( searchParameters );
+
+ assertTrue( Arrays.equals( new String[]{ listExpected.get( 1 ) }, list.toArray( ) ) );
+ }
+
+ private List<String> getSortedTestData() {
+ List<String> listExpected = new ArrayList<String>();
+ for( Source source : provider.getSources() ) {
+ listExpected.add( source.toString() );
+ }
+ Collections.sort( listExpected );
+ return listExpected;
+ }
+
+ private InputStream readExampleSources() throws IOException {
+ Bundle bundle = Platform.getBundle( "org.eclipse.rtp.configurator.model.test" );
+ URL unResolvedUrl = FileLocator.find( bundle, new Path("data/example-sources.json"), null );
+ URL testDataUrl = FileLocator.resolve( unResolvedUrl );
+ File testDataFile = new Path( testDataUrl.getFile() ).toFile();
+ return new FileInputStream( testDataFile );
+ }
+
+}
diff --git a/core/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF b/core/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF
index bc14d4f..4f6029d 100644
--- a/core/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.rtp.core.service.provider/META-INF/MANIFEST.MF
@@ -5,10 +5,11 @@ 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.core;bundle-version="1.0.0"
+ org.eclipes.rtp.core;bundle-version="1.0.0",
+ org.eclipse.rtp.configurator.model;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Service-Component: OSGI-INF/rtpConfiguratorServiceProvider.xml, OSGI-INF/rtpConfigurator.xml
+Service-Component: OSGI-INF/rtpConfiguratorServiceProvider.xml, OSGI-INF/rtpConfigurator.xml, OSGI-INF/rtpConfiguratorModel.xml
Bundle-Activator: org.eclipse.rtp.configurator.service.provider.internal.ProviderActivator
Import-Package: org.apache.commons.io;version="2.0.1",
org.eclipse.equinox.internal.provisional.configurator,
diff --git a/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml b/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml
index 8489ce9..3a62658 100644
--- a/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml
+++ b/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfigurator.xml
@@ -1,5 +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">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="startService" deactivate="shutdown" name="org.eclipse.rtp.core.service.provider.configuration">
<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/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml b/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.xml
new file mode 100644
index 0000000..ce787ec
--- /dev/null
+++ b/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorModel.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" name="org.eclipse.rtp.core.service.provider.model">
+ <implementation class="org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil"/>
+ <reference bind="setUnMarshaller" cardinality="1..1" interface="org.eclipse.rtp.configurator.model.SourceUnMarshaller" name="SourceUnMarshaller" policy="static" unbind="unsetUnMarshaller"/>
+</scr:component>
diff --git a/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml b/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml
index b8167c0..281af20 100644
--- a/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml
+++ b/core/org.eclipse.rtp.core.service.provider/OSGI-INF/rtpConfiguratorServiceProvider.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.configurator.service.provider">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.rtp.core.service.provider">
<implementation class="org.eclipse.rtp.configurator.service.provider.internal.DefaultConfiguratorService"/>
<service>
<provide interface="org.eclipse.rtp.configurator.core.IConfiguratorService"/>
diff --git a/core/org.eclipse.rtp.core.service.provider/build.properties b/core/org.eclipse.rtp.core.service.provider/build.properties
index 8a5fab1..90f25d9 100644
--- a/core/org.eclipse.rtp.core.service.provider/build.properties
+++ b/core/org.eclipse.rtp.core.service.provider/build.properties
@@ -2,5 +2,7 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/rtpConfiguratorServiceProvider.xml,\
- OSGI-INF/rtpConfigurator.xml
+ OSGI-INF/rtpConfigurator.xml,\
+ OSGI-INF/rtpConfiguratorModel.xml,\
+ OSGI-INF/rtpConfiguratorModel.xml
source.. = src/
diff --git a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
index 1ea9988..4fdb8da 100644
--- a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
+++ b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/DefaultConfiguratorService.java
@@ -1,82 +1,113 @@
-/*******************************************************************************
- * 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
+/*******************************************************************************
+ * 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;
+import java.util.ArrayList;
+import java.util.Collections;
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.configurator.model.Source;
+import org.eclipse.rtp.configurator.model.SourceProvider;
+import org.eclipse.rtp.configurator.service.provider.internal.util.ConfiguratorModelUtil;
import org.eclipse.rtp.configurator.service.provider.internal.util.P2Util;
public class DefaultConfiguratorService implements IConfiguratorService {
- private P2Util p2Util;
-
- public void setUp() {
- setP2Util(new P2Util());
- }
-
- public void shutDown() {
- setP2Util(null);
- }
-
- public void setP2Util(P2Util p2Util) {
- this.p2Util = p2Util;
- }
-
- @Override
- public IStatus install(List<String> parameter) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IStatus update(List<String> anyListOf) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IStatus remove(List<String> anyListOf) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List<String> search(List<String> anyListOf) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List<String> show(List<String> anyListOf) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List<String> list() throws CoreException {
- return null;
- }
-
- @Override
- public IStatus updateWorld() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IStatus refresh() {
- // TODO Auto-generated method stub
- return null;
- }
-
+ private P2Util p2Util;
+
+ public void setUp() {
+ setP2Util( new P2Util() );
+ }
+
+ public void shutDown() {
+ setP2Util( null );
+ }
+
+ public void setP2Util( P2Util p2Util ) {
+ this.p2Util = p2Util;
+ }
+
+ @Override
+ public IStatus install( List<String> parameter ) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IStatus update( List<String> anyListOf ) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IStatus remove( List<String> anyListOf ) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> search( List<String> anyListOf ) {
+ List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<String> result = new ArrayList<String>();
+ for( Source source : sources ) {
+ String name = source.getName();
+ for( String term : anyListOf ) {
+ if( name.contains( term ) ) {
+ result.add( source.toString() );
+ }
+ }
+ }
+ Collections.sort( result );
+ return result;
+ }
+
+ @Override
+ public List<String> show( List<String> anyListOf ) {
+ List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<String> result = new ArrayList<String>();
+ String showName = anyListOf.get( 0 );
+ for( Source source : sources ) {
+ if( source.getName().contains( showName ) ) {
+ result.add( source.toString() );
+ }
+ }
+ Collections.sort( result );
+ return result;
+ }
+
+ @Override
+ public List<String> list() throws CoreException {
+ List<Source> sources = ConfiguratorModelUtil.getSourceProvider().getSources();
+ List<String> sourcesAsString = getSourtedSources( sources );
+ return sourcesAsString;
+ }
+
+ private List<String> getSourtedSources( List<Source> sources ) {
+ List<String> sourcesAsString = new ArrayList<String>();
+ for( Source source : sources ) {
+ sourcesAsString.add( source.toString() );
+ }
+ Collections.sort( sourcesAsString );
+ return sourcesAsString;
+ }
+
+ @Override
+ public IStatus updateWorld() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IStatus refresh() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java
new file mode 100644
index 0000000..1f52861
--- /dev/null
+++ b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java
@@ -0,0 +1,32 @@
+package org.eclipse.rtp.configurator.service.provider.internal.util;
+
+import org.eclipse.rtp.configurator.model.SourceProvider;
+import org.eclipse.rtp.configurator.model.SourceUnMarshaller;
+
+public class ConfiguratorModelUtil {
+
+ private static SourceUnMarshaller sourceUnMarshaller;
+ private static SourceProvider sourceProvider;
+
+ public static void setUnMarshaller( SourceUnMarshaller sourceUnMarshaller ) {
+ ConfiguratorModelUtil.sourceUnMarshaller = sourceUnMarshaller;
+ }
+
+ public static void unsetUnMarshaller( SourceUnMarshaller sourceUnMarshaller ) {
+ ConfiguratorModelUtil.sourceUnMarshaller = null;
+ }
+
+ public static SourceUnMarshaller getSourceUnMarshaller() {
+ return sourceUnMarshaller;
+ }
+
+ public static void setSourceProvider(SourceProvider sourceProvider){
+ ConfiguratorModelUtil.sourceProvider = sourceProvider;
+ }
+
+ public static SourceProvider getSourceProvider(){
+ return ConfiguratorModelUtil.sourceProvider;
+ }
+
+
+}
diff --git a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
index 053baa0..ac62bb6 100644
--- a/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
+++ b/core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/P2Util.java
@@ -62,11 +62,9 @@ public class P2Util {
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);
+ return agentProvider.createAgent(null);
}
private static void checkAgentAvailable(IProvisioningAgentProvider agentProvider) throws CoreException {