use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension in project smarthome by eclipse.
the class MarketplaceExtensionService method convertToExtension.
private MarketplaceExtension convertToExtension(Node node) {
String extId = getExtensionId(node);
String name = node.name;
String desc = node.shortdescription;
String version = StringUtils.isNotEmpty(node.version) ? node.version : "1.0";
if (!validName(name) || !validDescription(desc)) {
logger.debug("Ignoring node {} due to invalid content.", node.id);
return null;
}
if (MP_PACKAGETYPE_BINDING.equals(node.packagetypes)) {
MarketplaceExtension ext = new MarketplaceExtension(extId, MarketplaceExtension.EXT_TYPE_BINDING, name, version, node.supporturl, false, desc, null, node.image, node.updateurl, node.packageformat);
return ext;
} else if (MP_PACKAGETYPE_RULE_TEMPLATE.equals(node.packagetypes)) {
MarketplaceExtension ext = new MarketplaceExtension(extId, MarketplaceExtension.EXT_TYPE_RULE_TEMPLATE, name, version, node.supporturl, false, desc, null, node.image, node.updateurl, node.packageformat);
return ext;
} else {
return null;
}
}
use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension in project smarthome by eclipse.
the class MarketplaceExtensionService method getExtensions.
@Override
public List<Extension> getExtensions(Locale locale) {
List<Node> nodes = proxy.getNodes();
List<Extension> exts = new ArrayList<>(nodes.size());
for (Node node : nodes) {
if (node.id == null) {
// workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=512493
continue;
}
if (toMaturityLevel(node.status) < this.maturityLevel) {
continue;
}
if (!includeBindings && node.packagetypes.equals(MP_PACKAGETYPE_BINDING)) {
continue;
}
if (!includeRuleTemplates && node.packagetypes.equals(MP_PACKAGETYPE_RULE_TEMPLATE)) {
continue;
}
MarketplaceExtension ext = convertToExtension(node);
if (ext != null) {
if (setInstalledFlag(ext)) {
exts.add(ext);
}
}
}
return exts;
}
use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension in project smarthome by eclipse.
the class MarketplaceExtensionService method install.
@Override
public void install(String extensionId) {
Extension ext = getExtension(extensionId, null);
if (ext instanceof MarketplaceExtension) {
MarketplaceExtension mpExt = (MarketplaceExtension) ext;
for (MarketplaceExtensionHandler handler : extensionHandlers) {
if (handler.supports(mpExt)) {
if (!handler.isInstalled(mpExt)) {
try {
handler.install(mpExt);
postInstalledEvent(extensionId);
} catch (MarketplaceHandlerException e) {
postFailureEvent(extensionId, e.getMessage());
}
} else {
postFailureEvent(extensionId, "Extension is already installed.");
}
return;
}
}
}
postFailureEvent(extensionId, "Extension not known.");
}
use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension in project smarthome by eclipse.
the class MarketplaceExtensionService method uninstall.
@Override
public void uninstall(String extensionId) {
Extension ext = getExtension(extensionId, null);
if (ext instanceof MarketplaceExtension) {
MarketplaceExtension mpExt = (MarketplaceExtension) ext;
for (MarketplaceExtensionHandler handler : extensionHandlers) {
if (handler.supports(mpExt)) {
if (handler.isInstalled(mpExt)) {
try {
handler.uninstall(mpExt);
postUninstalledEvent(extensionId);
} catch (MarketplaceHandlerException e) {
postFailureEvent(extensionId, e.getMessage());
}
} else {
postFailureEvent(extensionId, "Extension is not installed.");
}
return;
}
}
}
postFailureEvent(extensionId, "Extension not known.");
}
Aggregations