use of org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService in project kapua by eclipse.
the class GwtDeviceManagementServiceImpl method findBundles.
//
// Bundles
//
@Override
public ListLoadResult<GwtGroupedNVPair> findBundles(GwtDevice device) throws GwtKapuaException {
List<GwtGroupedNVPair> pairs = new ArrayList<GwtGroupedNVPair>();
try {
// get the configuration
KapuaLocator locator = KapuaLocator.getInstance();
DeviceBundleManagementService deviceBundleManagementService = locator.getService(DeviceBundleManagementService.class);
KapuaId scopeId = KapuaEid.parseShortId(device.getScopeId());
KapuaId id = KapuaEid.parseShortId(device.getId());
DeviceBundles bundles = deviceBundleManagementService.get(scopeId, id, null);
for (DeviceBundle bundle : bundles.getBundles()) {
GwtGroupedNVPair pair = new GwtGroupedNVPair();
pair.setId(String.valueOf(bundle.getId()));
pair.setName(bundle.getName());
pair.setStatus(toStateString(bundle));
pair.setVersion(bundle.getVersion());
pairs.add(pair);
}
} catch (Throwable t) {
KapuaExceptionHandler.handle(t);
}
return new BaseListLoadResult<GwtGroupedNVPair>(pairs);
}
use of org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService in project kapua by eclipse.
the class GwtDeviceManagementServiceImpl method startBundle.
@Override
public void startBundle(GwtXSRFToken xsrfToken, GwtDevice device, GwtGroupedNVPair pair) throws GwtKapuaException {
//
// Checking validity of the given XSRF Token
checkXSRFToken(xsrfToken);
try {
KapuaLocator locator = KapuaLocator.getInstance();
DeviceBundleManagementService deviceBundleManagementService = locator.getService(DeviceBundleManagementService.class);
KapuaId scopeId = KapuaEid.parseShortId(device.getScopeId());
KapuaId deviceId = KapuaEid.parseShortId(device.getId());
deviceBundleManagementService.start(scopeId, deviceId, String.valueOf(pair.getId()), null);
} catch (Throwable t) {
KapuaExceptionHandler.handle(t);
}
}
use of org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService in project kapua by eclipse.
the class GwtDeviceManagementServiceImpl method stopBundle.
@Override
public void stopBundle(GwtXSRFToken xsrfToken, GwtDevice device, GwtGroupedNVPair pair) throws GwtKapuaException {
//
// Checking validity of the given XSRF Token
checkXSRFToken(xsrfToken);
try {
KapuaLocator locator = KapuaLocator.getInstance();
DeviceBundleManagementService deviceBundleManagementService = locator.getService(DeviceBundleManagementService.class);
KapuaId scopeId = KapuaEid.parseShortId(device.getScopeId());
KapuaId deviceId = KapuaEid.parseShortId(device.getId());
deviceBundleManagementService.stop(scopeId, deviceId, String.valueOf(pair.getId()), null);
} catch (Throwable t) {
KapuaExceptionHandler.handle(t);
}
}
Aggregations