Search in sources :

Example 1 with DevicePackageManagementService

use of org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService in project kapua by eclipse.

the class GwtDeviceManagementServiceImpl method uninstallPackage.

@Override
public void uninstallPackage(GwtXSRFToken xsrfToken, GwtPackageUninstallRequest gwtPackageUninstallRequest) throws GwtKapuaException {
    // 
    // Check token
    checkXSRFToken(xsrfToken);
    // Do install
    try {
        KapuaId scopeId = KapuaEid.parseShortId(gwtPackageUninstallRequest.getScopeId());
        KapuaId deviceId = KapuaEid.parseShortId(gwtPackageUninstallRequest.getDeviceId());
        KapuaLocator locator = KapuaLocator.getInstance();
        DevicePackageFactory devicePackageFactory = locator.getFactory(DevicePackageFactory.class);
        DevicePackageUninstallRequest packageUninstallRequest = devicePackageFactory.newPackageUninstallRequest();
        packageUninstallRequest.setName(gwtPackageUninstallRequest.getPackageName());
        packageUninstallRequest.setVersion(gwtPackageUninstallRequest.getPackageVersion());
        packageUninstallRequest.setReboot(gwtPackageUninstallRequest.isReboot());
        packageUninstallRequest.setRebootDelay(gwtPackageUninstallRequest.getRebootDelay());
        DevicePackageManagementService packageManagementService = locator.getService(DevicePackageManagementService.class);
        packageManagementService.uninstallExec(scopeId, deviceId, packageUninstallRequest, null);
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
}
Also used : DevicePackageManagementService(org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) DevicePackageFactory(org.eclipse.kapua.service.device.management.packages.DevicePackageFactory) DevicePackageUninstallRequest(org.eclipse.kapua.service.device.management.packages.model.uninstall.DevicePackageUninstallRequest) KapuaId(org.eclipse.kapua.model.id.KapuaId)

Example 2 with DevicePackageManagementService

use of org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService in project kapua by eclipse.

the class GwtDeviceManagementServiceImpl method getDownloadOperations.

public ListLoadResult<GwtPackageOperation> getDownloadOperations(String scopeShortId, String deviceShortId) throws GwtKapuaException {
    List<GwtPackageOperation> gwtDeviceOperations = new ArrayList<GwtPackageOperation>();
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        DevicePackageManagementService deviceManagementService = locator.getService(DevicePackageManagementService.class);
        KapuaId scopeId = KapuaEid.parseShortId(scopeShortId);
        KapuaId deviceId = KapuaEid.parseShortId(deviceShortId);
        DevicePackageDownloadOperation downloadOperation = deviceManagementService.downloadStatus(scopeId, deviceId, null);
        GwtPackageDownloadOperation gwtDownloadOperation = new GwtPackageDownloadOperation();
        gwtDownloadOperation.setId(downloadOperation.getId().getShortId());
        gwtDownloadOperation.setStatus(downloadOperation.getStatus().name());
        gwtDownloadOperation.setSize(downloadOperation.getSize());
        gwtDownloadOperation.setProgress(downloadOperation.getProgress());
        gwtDeviceOperations.add(gwtDownloadOperation);
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return new BaseListLoadResult<>(gwtDeviceOperations);
}
Also used : GwtPackageOperation(org.eclipse.kapua.app.console.shared.model.device.management.packages.GwtPackageOperation) DevicePackageManagementService(org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService) BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) DevicePackageDownloadOperation(org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadOperation) GwtPackageDownloadOperation(org.eclipse.kapua.app.console.shared.model.device.management.packages.GwtPackageDownloadOperation) ArrayList(java.util.ArrayList) KapuaId(org.eclipse.kapua.model.id.KapuaId)

Example 3 with DevicePackageManagementService

use of org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService in project kapua by eclipse.

the class GwtDeviceManagementServiceImpl method installPackage.

@Override
public void installPackage(GwtXSRFToken xsrfToken, GwtPackageInstallRequest gwtPackageInstallRequest) throws GwtKapuaException {
    // 
    // Check token
    checkXSRFToken(xsrfToken);
    // Do install
    try {
        KapuaId scopeId = KapuaEid.parseShortId(gwtPackageInstallRequest.getScopeId());
        KapuaId deviceId = KapuaEid.parseShortId(gwtPackageInstallRequest.getDeviceId());
        KapuaLocator locator = KapuaLocator.getInstance();
        DevicePackageFactory devicePackageFactory = locator.getFactory(DevicePackageFactory.class);
        DevicePackageDownloadRequest packageDownloadRequest = devicePackageFactory.newPackageDownloadRequest();
        packageDownloadRequest.setURI(new URI(gwtPackageInstallRequest.getPackageURI()));
        packageDownloadRequest.setName(gwtPackageInstallRequest.getPackageName());
        packageDownloadRequest.setVersion(gwtPackageInstallRequest.getPackageVersion());
        // Always install
        packageDownloadRequest.setInstall(true);
        packageDownloadRequest.setReboot(gwtPackageInstallRequest.isReboot());
        packageDownloadRequest.setRebootDelay(gwtPackageInstallRequest.getRebootDelay());
        DevicePackageManagementService packageManagementService = locator.getService(DevicePackageManagementService.class);
        packageManagementService.downloadExec(scopeId, deviceId, packageDownloadRequest, null);
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
}
Also used : DevicePackageManagementService(org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) DevicePackageFactory(org.eclipse.kapua.service.device.management.packages.DevicePackageFactory) DevicePackageDownloadRequest(org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadRequest) KapuaId(org.eclipse.kapua.model.id.KapuaId) URI(java.net.URI)

Example 4 with DevicePackageManagementService

use of org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService in project kapua by eclipse.

the class GwtDeviceManagementServiceImpl method findDevicePackages.

// 
// Packages
// 
@Override
public List<GwtDeploymentPackage> findDevicePackages(String scopeShortId, String deviceShortId) throws GwtKapuaException {
    List<GwtDeploymentPackage> gwtPkgs = new ArrayList<GwtDeploymentPackage>();
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        DevicePackageManagementService deviceManagementService = locator.getService(DevicePackageManagementService.class);
        KapuaId scopeId = KapuaEid.parseShortId(scopeShortId);
        KapuaId deviceId = KapuaEid.parseShortId(deviceShortId);
        DevicePackages deploymentPackages = deviceManagementService.getInstalled(scopeId, deviceId, null);
        for (DevicePackage deploymentPackage : deploymentPackages.getPackages()) {
            GwtDeploymentPackage gwtPkg = new GwtDeploymentPackage();
            gwtPkg.setName(deploymentPackage.getName());
            gwtPkg.setVersion(deploymentPackage.getVersion());
            DevicePackageBundleInfos devicePackageBundleInfos = deploymentPackage.getBundleInfos();
            if (devicePackageBundleInfos != null) {
                List<GwtBundleInfo> gwtBundleInfos = new ArrayList<GwtBundleInfo>();
                for (DevicePackageBundleInfo bundleInfo : devicePackageBundleInfos.getBundlesInfos()) {
                    GwtBundleInfo gwtBundleInfo = new GwtBundleInfo();
                    gwtBundleInfo.setName(bundleInfo.getName());
                    gwtBundleInfo.setVersion(bundleInfo.getVersion());
                    gwtBundleInfos.add(gwtBundleInfo);
                }
                gwtPkg.setBundleInfos(gwtBundleInfos);
            }
            gwtPkgs.add(gwtPkg);
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return gwtPkgs;
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) ArrayList(java.util.ArrayList) DevicePackageBundleInfo(org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo) DevicePackage(org.eclipse.kapua.service.device.management.packages.model.DevicePackage) DevicePackages(org.eclipse.kapua.service.device.management.packages.model.DevicePackages) DevicePackageManagementService(org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService) DevicePackageBundleInfos(org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfos) KapuaId(org.eclipse.kapua.model.id.KapuaId) GwtBundleInfo(org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)

Aggregations

KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)4 KapuaId (org.eclipse.kapua.model.id.KapuaId)4 DevicePackageManagementService (org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService)4 ArrayList (java.util.ArrayList)2 DevicePackageFactory (org.eclipse.kapua.service.device.management.packages.DevicePackageFactory)2 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)1 URI (java.net.URI)1 GwtBundleInfo (org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)1 GwtDeploymentPackage (org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage)1 GwtPackageDownloadOperation (org.eclipse.kapua.app.console.shared.model.device.management.packages.GwtPackageDownloadOperation)1 GwtPackageOperation (org.eclipse.kapua.app.console.shared.model.device.management.packages.GwtPackageOperation)1 DevicePackage (org.eclipse.kapua.service.device.management.packages.model.DevicePackage)1 DevicePackageBundleInfo (org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo)1 DevicePackageBundleInfos (org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfos)1 DevicePackages (org.eclipse.kapua.service.device.management.packages.model.DevicePackages)1 DevicePackageDownloadOperation (org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadOperation)1 DevicePackageDownloadRequest (org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadRequest)1 DevicePackageUninstallRequest (org.eclipse.kapua.service.device.management.packages.model.uninstall.DevicePackageUninstallRequest)1