aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeyhan@eclipsesource.com2012-02-29 07:53:44 (EST)
committerbeyhan@eclipsesource.com2012-02-29 07:53:44 (EST)
commit2ed25876f970d1d420408c1cf6bf53550474d4fb (patch)
treee9c1bbf91541ecda26a91b5151d666d1a6ffab03
parent68f769ed0a2182cd26d30eba5509fa8b469f3192 (diff)
downloadorg.eclipse.rtp-2ed25876f970d1d420408c1cf6bf53550474d4fb.zip
org.eclipse.rtp-2ed25876f970d1d420408c1cf6bf53550474d4fb.tar.gz
org.eclipse.rtp-2ed25876f970d1d420408c1cf6bf53550474d4fb.tar.bz2
369337: Provide all provisioning APIs via REST-APIs
https://bugs.eclipse.org/bugs/show_bug.cgi?id=369337
-rw-r--r--bundles/org.eclipse.rtp.configurator.rest.provider/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtil.java21
-rw-r--r--tests/org.eclipse.rtp.configurator.rest.provider.test/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtilTest.java26
2 files changed, 29 insertions, 18 deletions
diff --git a/bundles/org.eclipse.rtp.configurator.rest.provider/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtil.java b/bundles/org.eclipse.rtp.configurator.rest.provider/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtil.java
index 9ae0139..501209b 100644
--- a/bundles/org.eclipse.rtp.configurator.rest.provider/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtil.java
+++ b/bundles/org.eclipse.rtp.configurator.rest.provider/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtil.java
@@ -29,21 +29,27 @@ public class PathInfoUtil {
}
public String getSourceVersion( String pathInfo ) {
+ String result;
String[] provisioningInfo = getProvisioningInfo( pathInfo );
- return provisioningInfo[ 1 ];
+ if(provisioningInfo.length >= 3){
+ result = provisioningInfo[2];
+ }else{
+ result = "";
+ }
+ return result;
}
public String getSourceName( String pathInfo ) {
String[] provisioningInfo = getProvisioningInfo( pathInfo );
- return provisioningInfo[ 0 ];
+ return provisioningInfo[ 1 ];
}
public boolean isProvisioning( String pathInfo, ModelUtil modelUtil, List<Source> sources ) {
boolean result = false;
String[] provisioningInfo = getProvisioningInfo( pathInfo );
- if( provisioningInfo.length == 2 ) {
+ if( provisioningInfo.length != 0 && isProvisionigCommand( provisioningInfo[ 0 ] ) ) {
List<String> sourceQuery = Arrays.asList( new String[]{
- provisioningInfo[ 0 ]
+ provisioningInfo[ 1 ]
} );
List<Source> searchResult = modelUtil.searchSources( sourceQuery, sources );
result = !searchResult.isEmpty();
@@ -51,11 +57,16 @@ public class PathInfoUtil {
return result;
}
+ private boolean isProvisionigCommand( String provisioningCommand ) {
+ return "install".equalsIgnoreCase( provisioningCommand )
+ || "uninstall".equalsIgnoreCase( provisioningCommand );
+ }
+
public String[] getProvisioningInfo( String pathInfo ) {
String[] provisioningInfo = new String[ 0 ];
if( pathInfo != null && pathInfo.length() > 0 ) {
Path path = new Path( pathInfo );
- if( path.segmentCount() == 2 ) {
+ if( path.segmentCount() >= 2 ) {
provisioningInfo = path.segments();
}
}
diff --git a/tests/org.eclipse.rtp.configurator.rest.provider.test/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtilTest.java b/tests/org.eclipse.rtp.configurator.rest.provider.test/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtilTest.java
index 57575cb..6d0a4fa 100644
--- a/tests/org.eclipse.rtp.configurator.rest.provider.test/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtilTest.java
+++ b/tests/org.eclipse.rtp.configurator.rest.provider.test/src/org/eclipse/rtp/configurator/rest/provider/internal/util/PathInfoUtilTest.java
@@ -46,35 +46,35 @@ public class PathInfoUtilTest {
@Test
public void testsearchSourceVersionTest() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- SourceVersion result = pathInfoUtil.getSourceVersion( "/test/1.0.0/", new ModelUtil(), sources );
+ SourceVersion result = pathInfoUtil.getSourceVersion( "/install/test/1.0.0/", new ModelUtil(), sources );
assertEquals( sourceVersion, result );
}
@Test
public void testsearchSourceVersionTest2() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- SourceVersion result = pathInfoUtil.getSourceVersion( "/test2/1.1.0/", new ModelUtil(), sources );
+ SourceVersion result = pathInfoUtil.getSourceVersion( "/install/test2/1.1.0/", new ModelUtil(), sources );
assertEquals( sourceVersion2, result );
}
@Test
public void testsearchSourceVersionTestNotExits() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- SourceVersion result = pathInfoUtil.getSourceVersion( "/test3/1.1.0/", new ModelUtil(), sources );
+ SourceVersion result = pathInfoUtil.getSourceVersion( "/install/test3/1.1.0/", new ModelUtil(), sources );
assertNull( result );
}
@Test
public void testGetSourceVersionString() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- String result = pathInfoUtil.getSourceVersion( "foo/1.0.0" );
+ String result = pathInfoUtil.getSourceVersion( "install/foo/1.0.0" );
assertEquals( "1.0.0", result );
}
@Test
public void testGetSourceName() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- String result = pathInfoUtil.getSourceName( "foo/1.0.0" );
+ String result = pathInfoUtil.getSourceName( "install/foo/1.0.0" );
assertEquals( "foo", result );
}
@@ -95,51 +95,51 @@ public class PathInfoUtilTest {
@Test
public void testIsProvisioningPathInfoStartsAndEndsWithSlash() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- boolean result = pathInfoUtil.isProvisioning( "/test/1.0.0/", new ModelUtil(), sources );
+ boolean result = pathInfoUtil.isProvisioning( "/install/test/1.0.0/", new ModelUtil(), sources );
assertTrue( result );
}
@Test
public void testIsProvisioningPathInfoStartsWithSlash() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- boolean result = pathInfoUtil.isProvisioning( "/test/1.0.0", new ModelUtil(), sources );
+ boolean result = pathInfoUtil.isProvisioning( "/install/test/1.0.0", new ModelUtil(), sources );
assertTrue( result );
}
@Test
public void testIsProvisioningPathInfoEndsWithSlash() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- boolean result = pathInfoUtil.isProvisioning( "test/1.0.0/", new ModelUtil(), sources );
+ boolean result = pathInfoUtil.isProvisioning( "install/test/1.0.0/", new ModelUtil(), sources );
assertTrue( result );
}
@Test
public void testIsProvisioningPathInfoWithoutEndAnsStartSlash() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- boolean result = pathInfoUtil.isProvisioning( "test/1.0.0", new ModelUtil(), sources );
+ boolean result = pathInfoUtil.isProvisioning( "install/test/1.0.0", new ModelUtil(), sources );
assertTrue( result );
}
@Test
public void testIsProvisioningPathInfoSourceNotExists() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- boolean result = pathInfoUtil.isProvisioning( "test3/1.0.0", new ModelUtil(), sources );
+ boolean result = pathInfoUtil.isProvisioning( "install/test3/1.0.0", new ModelUtil(), sources );
assertFalse( result );
}
@Test
public void testIsProvisioningPathInfoSourceVersionNotExists() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- boolean result = pathInfoUtil.isProvisioning( "test3/1.2.0", new ModelUtil(), sources );
+ boolean result = pathInfoUtil.isProvisioning( "install/test3/1.2.0", new ModelUtil(), sources );
assertFalse( result );
}
@Test
public void testGetProvisioningInfo() {
PathInfoUtil pathInfoUtil = new PathInfoUtil();
- String[] result = pathInfoUtil.getProvisioningInfo( "/foo/1.0.0/" );
+ String[] result = pathInfoUtil.getProvisioningInfo( "install/foo/1.0.0/" );
assertArrayEquals( new String[]{
- "foo", "1.0.0"
+ "install", "foo", "1.0.0"
}, result );
}
}