use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException in project smarthome by eclipse.
the class AutomationExtensionHandler method install.
@Override
public void install(MarketplaceExtension ext) throws MarketplaceHandlerException {
String url = ext.getDownloadUrl();
try {
String template = getTemplate(url);
marketplaceRuleTemplateProvider.addTemplateAsJSON(ext.getId(), template);
} catch (IOException e) {
logger.error("Rule template from marketplace cannot be downloaded: {}", e.getMessage());
throw new MarketplaceHandlerException("Template cannot be downloaded.");
} catch (Exception e) {
logger.error("Rule template from marketplace is invalid: {}", e.getMessage());
throw new MarketplaceHandlerException("Template is not valid.");
}
}
use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException in project smarthome by eclipse.
the class BindingExtensionHandler method install.
@Override
public void install(MarketplaceExtension ext) throws MarketplaceHandlerException {
String url = ext.getDownloadUrl();
try {
Bundle bundle = bundleContext.installBundle(url);
try {
bundle.start();
} catch (BundleException e) {
logger.warn("Installed bundle, but failed to start it: {}", e.getMessage());
}
installedBindings.put(ext.getId(), bundle.getBundleId());
persistInstalledBindingsMap(installedBindings);
} catch (BundleException e) {
logger.debug("Failed to install binding from marketplace.", e);
throw new MarketplaceHandlerException("Binding cannot be installed: " + e.getMessage());
}
}
use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException in project smarthome by eclipse.
the class BindingExtensionHandler method uninstall.
@Override
public void uninstall(MarketplaceExtension ext) throws MarketplaceHandlerException {
Long id = installedBindings.get(ext.getId());
if (id != null) {
Bundle bundle = bundleContext.getBundle(id);
if (bundle != null) {
try {
bundle.stop();
bundle.uninstall();
installedBindings.remove(ext.getId());
persistInstalledBindingsMap(installedBindings);
} catch (BundleException e) {
throw new MarketplaceHandlerException("Failed deinstalling binding: " + e.getMessage());
}
} else {
// we do not have such a bundle, so let's remove it from our internal map
installedBindings.remove(ext.getId());
persistInstalledBindingsMap(installedBindings);
throw new MarketplaceHandlerException("Id not known.");
}
} else {
throw new MarketplaceHandlerException("Id not known.");
}
}
use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException 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.MarketplaceHandlerException 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