added esh repos for online mode ()

Signed-off-by: Kai Kreuzer <kai@openhab.org>
pull/42/head
Kai Kreuzer 2016-04-25 20:57:18 +02:00
parent 07e75b7e96
commit 235c82b023
2 changed files with 26 additions and 24 deletions
bundles/org.openhab.core.karaf
META-INF
src/main/java/org/openhab/core/karaf/internal

View File

@ -7,7 +7,8 @@ Bundle-Vendor: openHAB.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Karaf-Commands: org.openhab.core.karaf.internal.command Karaf-Commands: org.openhab.core.karaf.internal.command
Service-Component: OSGI-INF/*.xml Service-Component: OSGI-INF/*.xml
Import-Package: org.apache.commons.lang, Import-Package: com.google.common.collect,
org.apache.commons.lang,
org.apache.karaf.features, org.apache.karaf.features,
org.apache.karaf.shell.api.action, org.apache.karaf.shell.api.action,
org.apache.karaf.shell.api.action.lifecycle, org.apache.karaf.shell.api.action.lifecycle,

View File

@ -16,6 +16,7 @@ import java.util.Dictionary;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -29,6 +30,8 @@ import org.osgi.service.cm.ConfigurationListener;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.common.collect.Sets;
/** /**
* This service reads addons.cfg and installs listed addons (= Karaf features) and the selected package. * This service reads addons.cfg and installs listed addons (= Karaf features) and the selected package.
* It furthermore allows configuration of the base package through the Paper UI as well as administrating Karaf to * It furthermore allows configuration of the base package through the Paper UI as well as administrating Karaf to
@ -38,32 +41,28 @@ import org.slf4j.LoggerFactory;
*/ */
public class FeatureInstaller implements ConfigurationListener { public class FeatureInstaller implements ConfigurationListener {
private static final String CFG_REMOTE = "remote";
private static final String CFG_EXPERIMENTAL = "experimental"; private static final String CFG_EXPERIMENTAL = "experimental";
private static final String CFG_LEGACY = "legacy"; private static final String CFG_LEGACY = "legacy";
private static final String ADDONS_SERVICE_PID = "org.openhab.addons"; private static final String ADDONS_SERVICE_PID = "org.openhab.addons";
private static final String CFG_REMOTE = "remote";
private static final String PAX_URL_PID = "org.ops4j.pax.url.mvn"; private static final String PAX_URL_PID = "org.ops4j.pax.url.mvn";
private static final String PROPERTY_MVN_REPOS = "org.ops4j.pax.url.mvn.repositories"; private static final String PROPERTY_MVN_REPOS = "org.ops4j.pax.url.mvn.repositories";
private static final String OH_SNAPSHOT_REPO = "http://oss.jfrog.org/libs-snapshot@id=oh-snapshot-repo@snapshots@noreleases"; private static final String OH_SNAPSHOT_REPO = "http://oss.jfrog.org/libs-snapshot@id=oh-snapshot-repo@snapshots@noreleases";
private static final String OH_RELEASES_REPO = "https://jcenter.bintray.com@id=oh-releases-repo"; private static final String OH_RELEASES_REPO = "https://jcenter.bintray.com@id=oh-releases-repo";
private static final String ESH_SNAPSHOT_REPO = "https://repo.eclipse.org/content/repositories/snapshots@id=esh-snapshot-repo@snapshots@noreleases";
private static final String ESH_RELEASES_REPO = "https://repo.eclipse.org/content/repositories/releases@id=esh-release-repo";
private static final Set<String> ONLINE_REPOS = Sets.newHashSet(OH_RELEASES_REPO, OH_SNAPSHOT_REPO,
ESH_RELEASES_REPO, ESH_SNAPSHOT_REPO);
private static final URI LEGACY_FEATURES_URI = URI private static final URI LEGACY_FEATURES_URI = URI
.create("mvn:org.openhab.addons/openhab-addons-legacy/LATEST/xml/features"); .create("mvn:org.openhab.addons/openhab-addons-legacy/LATEST/xml/features");
private static final URI EXPERIMENTAL_FEATURES_URI = URI private static final URI EXPERIMENTAL_FEATURES_URI = URI
.create("mvn:org.openhab.addons/openhab-addons-experimental/LATEST/xml/features"); .create("mvn:org.openhab.addons/openhab-addons-experimental/LATEST/xml/features");
public static final String STANDARD_PACKAGE = "standard"; public static final String STANDARD_PACKAGE = "standard";
public static final String PREFIX = "openhab-"; public static final String PREFIX = "openhab-";
public static final String PREFIX_PACKAGE = "package-"; public static final String PREFIX_PACKAGE = "package-";
public static final String[] addonTypes = new String[] { "binding", "ui", "persistence", "action", "tts", public static final String[] addonTypes = new String[] { "binding", "ui", "persistence", "action", "tts",
@ -176,9 +175,12 @@ public class FeatureInstaller implements ConfigurationListener {
List<String> repoCfg; List<String> repoCfg;
if (repos instanceof String) { if (repos instanceof String) {
repoCfg = Arrays.asList(((String) repos).split(",")); repoCfg = Arrays.asList(((String) repos).split(","));
if (repoCfg.contains(OH_RELEASES_REPO) && repoCfg.contains(OH_SNAPSHOT_REPO)) { for (String r : ONLINE_REPOS) {
return true; if (!repoCfg.contains(r)) {
return false;
}
} }
return true;
} }
} catch (IOException e) { } catch (IOException e) {
logger.error("Failed setting the extension management online/offline mode: {}", e.toString()); logger.error("Failed setting the extension management online/offline mode: {}", e.toString());
@ -202,22 +204,21 @@ public class FeatureInstaller implements ConfigurationListener {
repoCfg.remove(""); repoCfg.remove("");
} }
if (status) { if (status) {
if (!(repoCfg.contains(OH_RELEASES_REPO) && repoCfg.contains(OH_SNAPSHOT_REPO))) { for (String r : ONLINE_REPOS) {
repoCfg.add(OH_RELEASES_REPO); if (!repoCfg.contains(r)) {
repoCfg.add(OH_SNAPSHOT_REPO); repoCfg.add(r);
properties.put(PROPERTY_MVN_REPOS, StringUtils.join(repoCfg.toArray(), ",")); }
paxCfgUpdated = false;
paxCfg.update(properties);
} }
} else { } else {
if (repoCfg.contains(OH_RELEASES_REPO) || repoCfg.contains(OH_SNAPSHOT_REPO)) { for (String r : ONLINE_REPOS) {
repoCfg.remove(OH_RELEASES_REPO); if (repoCfg.contains(r)) {
repoCfg.remove(OH_SNAPSHOT_REPO); repoCfg.remove(r);
properties.put(PROPERTY_MVN_REPOS, StringUtils.join(repoCfg.toArray(), ",")); }
paxCfgUpdated = false;
paxCfg.update(properties);
} }
} }
properties.put(PROPERTY_MVN_REPOS, StringUtils.join(repoCfg.toArray(), ","));
paxCfgUpdated = false;
paxCfg.update(properties);
} catch (IOException e) { } catch (IOException e) {
logger.error("Failed setting the extension management online/offline mode: {}", e.toString()); logger.error("Failed setting the extension management online/offline mode: {}", e.toString());
} }