Search in sources :

Example 1 with DeviceBundleManagementService

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);
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) DeviceBundles(org.eclipse.kapua.service.device.management.bundle.DeviceBundles) ArrayList(java.util.ArrayList) KapuaId(org.eclipse.kapua.model.id.KapuaId) DeviceBundle(org.eclipse.kapua.service.device.management.bundle.DeviceBundle) DeviceBundleManagementService(org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService) GwtGroupedNVPair(org.eclipse.kapua.app.console.shared.model.GwtGroupedNVPair)

Example 2 with DeviceBundleManagementService

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);
    }
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) KapuaId(org.eclipse.kapua.model.id.KapuaId) DeviceBundleManagementService(org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService)

Example 3 with DeviceBundleManagementService

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);
    }
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) KapuaId(org.eclipse.kapua.model.id.KapuaId) DeviceBundleManagementService(org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService)

Aggregations

KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)3 KapuaId (org.eclipse.kapua.model.id.KapuaId)3 DeviceBundleManagementService (org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService)3 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)1 ArrayList (java.util.ArrayList)1 GwtGroupedNVPair (org.eclipse.kapua.app.console.shared.model.GwtGroupedNVPair)1 DeviceBundle (org.eclipse.kapua.service.device.management.bundle.DeviceBundle)1 DeviceBundles (org.eclipse.kapua.service.device.management.bundle.DeviceBundles)1