aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Schmidt2011-11-06 17:49:49 (EST)
committerSebastian Schmidt2011-11-06 17:49:49 (EST)
commita36355b91cbcfea097740fc169149a5762a341ab (patch)
tree6875f362e1cdac015717f8aacf8e86741e19367e
parent89e9296adf270482042d3e7a69546d64c2655a28 (diff)
downloadorg.eclipse.rtp-a36355b91cbcfea097740fc169149a5762a341ab.zip
org.eclipse.rtp-a36355b91cbcfea097740fc169149a5762a341ab.tar.gz
org.eclipse.rtp-a36355b91cbcfea097740fc169149a5762a341ab.tar.bz2
NEW - bug 362877 - [Core] Extend RTPService with addRepository and remoRepository APIs
-rw-r--r--bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/SourceVersion.java11
-rw-r--r--bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java21
-rw-r--r--bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/IRTPService.java7
-rw-r--r--tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java20
4 files changed, 53 insertions, 6 deletions
diff --git a/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/SourceVersion.java b/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/SourceVersion.java
index 48656b1..2864e21 100644
--- a/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/SourceVersion.java
+++ b/bundles/org.eclipse.rtp.core.model/src/org/eclipse/rtp/core/model/SourceVersion.java
@@ -7,23 +7,22 @@
*******************************************************************************/
package org.eclipse.rtp.core.model;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
public class SourceVersion {
private String version;
private String repositoryUrl;
- private List<Feature> features;
+ private List<Feature> features = new ArrayList<Feature>();
- SourceVersion() {
+ public SourceVersion() {
// only for Gson
}
public SourceVersion( String version, String repositoryUrl, String description, String infoUrl ) {
this.version = version;
this.repositoryUrl = repositoryUrl;
- this.features = Collections.emptyList();
}
public String getVersion() {
@@ -38,6 +37,10 @@ public class SourceVersion {
return features;
}
+ public void addFeature( Feature feature ) {
+ this.features.add( feature );
+ }
+
@Override
public String toString() {
StringBuilder result = new StringBuilder();
diff --git a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
index 16c8e73..8ec737c 100644
--- a/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
+++ b/bundles/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/RTPDefaultService.java
@@ -75,8 +75,10 @@ public class RTPDefaultService implements IRTPService {
}
private void loadRepository( SourceVersion sourceVersion ) throws URISyntaxException {
- RepositoryManager repositoryManager = p2Util.getRepositoryManager();
- repositoryManager.addRepository( new URI( sourceVersion.getRepositoryUrl() ) );
+ if( sourceVersion.getRepositoryUrl() != null ) {
+ RepositoryManager repositoryManager = p2Util.getRepositoryManager();
+ repositoryManager.addRepository( new URI( sourceVersion.getRepositoryUrl() ) );
+ }
}
@Override
@@ -137,6 +139,16 @@ public class RTPDefaultService implements IRTPService {
}
@Override
+ public void addRepository( URI repository ) {
+ p2Util.getRepositoryManager().addRepository( repository );
+ }
+
+ @Override
+ public void removeRepository( URI repository ) {
+ p2Util.getRepositoryManager().removeRepository( repository );
+ }
+
+ @Override
public IStatus update( List<String> anyListOf ) {
List<Source> sources = ModelUtil.getSourceProvider().getSources();
System.out.println( "Searching for updates" );
@@ -147,6 +159,11 @@ public class RTPDefaultService implements IRTPService {
return result;
}
+ @Override
+ public URI[] getRepositories() {
+ return p2Util.getRepositoryManager().getRepositories();
+ }
+
protected List<Source> searchSources( List<Source> sources, List<String> showSource ) {
List<Source> result = new ModelUtil().searchSources( showSource, sources );
return result;
diff --git a/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/IRTPService.java b/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/IRTPService.java
index 43d8d7e..ea10609 100644
--- a/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/IRTPService.java
+++ b/bundles/org.eclipse.rtp.core/src/org/eclipse/rtp/core/IRTPService.java
@@ -7,6 +7,7 @@
*******************************************************************************/
package org.eclipse.rtp.core;
+import java.net.URI;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -28,4 +29,10 @@ public interface IRTPService {
List<String> list() throws CoreException;
IStatus updateWorld();
+
+ void addRepository(URI repository);
+
+ void removeRepository(URI repository);
+
+ URI[] getRepositories();
}
diff --git a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
index 379f64b..46c8965 100644
--- a/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
+++ b/tests/org.eclipse.rtp.core.service.provider.test/src/org/eclipse/rtp/configurator/service/provider/internal/ConfiguratorServiceTest.java
@@ -200,6 +200,26 @@ public class ConfiguratorServiceTest {
assertTrue( status.isOK() );
}
+ @Test
+ public void testAddRepository() throws URISyntaxException {
+ URI testRepository = new URI( "file:/tmp" );
+ repositoryManager = mock( RepositoryManager.class );
+ when( p2UtilMock.getRepositoryManager() ).thenReturn( repositoryManager );
+ configuratorService.addRepository( testRepository );
+ verify( repositoryManager ).addRepository( testRepository );
+ verify( p2UtilMock ).getRepositoryManager();
+ }
+
+ @Test
+ public void testRemoveRepository() throws URISyntaxException {
+ URI testRepository = new URI( "file:/tmp" );
+ repositoryManager = mock( RepositoryManager.class );
+ when( p2UtilMock.getRepositoryManager() ).thenReturn( repositoryManager );
+ configuratorService.removeRepository( testRepository );
+ verify( repositoryManager ).removeRepository( testRepository );
+ verify( p2UtilMock ).getRepositoryManager();
+ }
+
private Comparator<SourceVersion> getSourceVersionComparator() {
Comparator<SourceVersion> comparator = new Comparator<SourceVersion>() {