use of org.eclipse.smarthome.core.extension.Extension 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.core.extension.Extension 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.");
}
use of org.eclipse.smarthome.core.extension.Extension in project smarthome by eclipse.
the class MarketplaceExtensionService method getTypes.
@Override
public List<ExtensionType> getTypes(Locale locale) {
ArrayList<ExtensionType> types = new ArrayList<>(2);
List<Extension> exts = getExtensions(locale);
if (includeBindings) {
for (Extension ext : exts) {
if (ext.getType().equals(MarketplaceExtension.EXT_TYPE_BINDING)) {
types.add(new ExtensionType(MarketplaceExtension.EXT_TYPE_BINDING, "Bindings"));
break;
}
}
}
if (includeRuleTemplates) {
for (Extension ext : exts) {
if (ext.getType().equals(MarketplaceExtension.EXT_TYPE_RULE_TEMPLATE)) {
types.add(new ExtensionType(MarketplaceExtension.EXT_TYPE_RULE_TEMPLATE, "Rule Templates"));
break;
}
}
}
return Collections.unmodifiableList(types);
}
Aggregations