Search in sources :

Example 1 with MarketplaceExtensionHandler

use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtensionHandler 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.");
}
Also used : Extension(org.eclipse.smarthome.core.extension.Extension) MarketplaceExtension(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension) MarketplaceExtension(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension) MarketplaceHandlerException(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException) MarketplaceExtensionHandler(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtensionHandler)

Example 2 with MarketplaceExtensionHandler

use of org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtensionHandler 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.");
}
Also used : Extension(org.eclipse.smarthome.core.extension.Extension) MarketplaceExtension(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension) MarketplaceExtension(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension) MarketplaceHandlerException(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException) MarketplaceExtensionHandler(org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtensionHandler)

Aggregations

Extension (org.eclipse.smarthome.core.extension.Extension)2 MarketplaceExtension (org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtension)2 MarketplaceExtensionHandler (org.eclipse.smarthome.extensionservice.marketplace.MarketplaceExtensionHandler)2 MarketplaceHandlerException (org.eclipse.smarthome.extensionservice.marketplace.MarketplaceHandlerException)2