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);
}
}
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);
}
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);
}
}
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;
}
Aggregations