aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbveliev2011-10-03 08:38:38 (EDT)
committerbveliev2011-10-03 08:38:38 (EDT)
commit2435bc3e22198acb3171fac376751a4e0c552489 (patch)
tree48ed3314c1de475e8cbf755d358423841403ccfd
parent82945e2e711e2b440123a2cbe2b065bd2ddd87b7 (diff)
downloadorg.eclipse.rtp-2435bc3e22198acb3171fac376751a4e0c552489.zip
org.eclipse.rtp-2435bc3e22198acb3171fac376751a4e0c552489.tar.gz
org.eclipse.rtp-2435bc3e22198acb3171fac376751a4e0c552489.tar.bz2
* local source model file added
-rw-r--r--configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java30
-rw-r--r--core/org.eclipse.rtp.core.service.provider/data/real-sources.json33
-rw-r--r--core/org.eclipse.rtp.core.service.provider/src/org/eclipse/rtp/configurator/service/provider/internal/util/ConfiguratorModelUtil.java38
3 files changed, 79 insertions, 22 deletions
diff --git a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java
index a751baa..3ddd6ed 100644
--- a/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java
+++ b/configurator.test/org.eclipse.rtp.configurator.model.test/src/org/eclipse/rtp/configurator/model/SourceVersionTest.java
@@ -1,31 +1,27 @@
-/*******************************************************************************
-* 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.model;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
-
public class SourceVersionTest {
-
+
@Test
public void testGetValues() {
- SourceVersion version = new SourceVersion( "1.4",
- "http://foo.bar",
- "description",
+ SourceVersion version = new SourceVersion( "1.4",
+ "http://foo.bar",
+ "description",
"http://info.bar" );
-
assertEquals( "1.4", version.getVersion() );
assertEquals( "http://foo.bar", version.getRepositoryUrl() );
- assertNull( version.getFeatures() );
+ assertTrue( version.getFeatures().isEmpty() );
}
}
diff --git a/core/org.eclipse.rtp.core.service.provider/data/real-sources.json b/core/org.eclipse.rtp.core.service.provider/data/real-sources.json
new file mode 100644
index 0000000..3887b8e
--- /dev/null
+++ b/core/org.eclipse.rtp.core.service.provider/data/real-sources.json
@@ -0,0 +1,33 @@
+{
+ "sources": [
+ {
+ "name": "rap",
+ "description": "RAP",
+ "infoUrl": "http://www.eclipse.org/rap/",
+ "versions": [
+ {
+ "features": [ { id : "org.eclipse.rap.tooling.feature.group", version : "1.4.1.20110914-1945" }],
+ "version": "1.4.1",
+ "repositoryUrl": "http://download.eclipse.org/rt/rap/1.4/tooling"
+ },
+ {
+ "features": [ { id : "org.eclipse.rap.tooling.feature.group", version : "1.4.0" }],
+ "version": "1.4.0",
+ "repositoryUrl": "http://download.eclipse.org/rt/rap/1.4/tooling"
+ }
+ ]
+ },
+ {
+ "name": "equinox",
+ "description": "Some text3",
+ "infoUrl": "http://foo.bar/info3",
+ "versions": [
+ {
+ "features": [ { id : "org.eclipse.rap.feature.group", version : "2.5.0" }, { id : "org.eclipse.rap.feature.group.ext", version : "1.5.0" } ],
+ "version": "3.8.1",
+ "repositoryUrl": "http://foo.bar3"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
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
index 3e874ac..e3ee2cf 100644
--- 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
@@ -1,15 +1,25 @@
+/*******************************************************************************
+ * 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.URL;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
import org.eclipse.rtp.configurator.model.SourceProvider;
import org.eclipse.rtp.configurator.model.SourceUnMarshaller;
+import org.eclipse.rtp.configurator.service.provider.internal.ProviderActivator;
public class ConfiguratorModelUtil {
private static SourceUnMarshaller sourceUnMarshaller;
private static SourceProvider sourceProvider;
- private static String defaultModeURL = "file:///C:/Users/bveliev/org.eclipse.rtp/core/org.eclipse.rtp.core.service.provider/data/real-sources.json";
+ private static String defaultModeURL = "http://foo";
public static void setUnMarshaller( SourceUnMarshaller sourceUnMarshaller ) {
ConfiguratorModelUtil.sourceUnMarshaller = sourceUnMarshaller;
@@ -36,12 +46,30 @@ public class ConfiguratorModelUtil {
private static SourceProvider getDefaultModel() {
SourceProvider result = null;
+ String[] modelURLs = new String[]{
+ defaultModeURL, getLocalURL()
+ };
+ for( int i = 0; i < modelURLs.length && result == null; i++ ) {
+ try {
+ URL url = new URL( modelURLs[ i ] );
+ result = sourceUnMarshaller.marshal( url.openStream() );
+ } catch( Exception e ) {
+ System.out.println( "Failed to load model" );
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ private static String getLocalURL() {
+ String result = "";
try {
- URL url = new URL( defaultModeURL );
- result = sourceUnMarshaller.marshal( url.openStream() );
+ URL unresolvedURL = FileLocator.find( ProviderActivator.getBundleContext().getBundle(),
+ new Path( "data/real-sources.json" ),
+ null );
+ result = FileLocator.resolve( unresolvedURL ).toExternalForm();
} catch( Exception e ) {
- System.out.println( "Failed to load model" );
- e.printStackTrace();
+ // Ignore
}
return result;
}