use of org.eclipse.kapua.message.KapuaPayload in project kapua by eclipse.
the class DeviceLifeCycleServiceImpl method death.
@Override
public void death(KapuaId connectionId, KapuaDisconnectMessage message) throws KapuaException {
KapuaPayload payload = message.getPayload();
KapuaId scopeId = message.getScopeId();
KapuaId deviceId = message.getDeviceId();
//
// Device update
KapuaLocator locator = KapuaLocator.getInstance();
DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
Device device = deviceRegistryService.find(scopeId, deviceId);
//
// Event create
DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, deviceId, message.getReceivedOn(), "DEATH");
deviceEventCreator.setReceivedOn(message.getReceivedOn());
// TODO check this change
deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
deviceEventCreator.setSentOn(message.getSentOn());
KapuaPosition position = message.getPosition();
if (position != null) {
deviceEventCreator.setPosition(position);
}
deviceEventService.create(deviceEventCreator);
}
use of org.eclipse.kapua.message.KapuaPayload in project kapua by eclipse.
the class DeviceLifeCycleServiceImpl method missing.
@Override
public void missing(KapuaId connectionId, KapuaMissingMessage message) throws KapuaException {
KapuaPayload payload = message.getPayload();
KapuaId scopeId = message.getScopeId();
KapuaId deviceId = message.getDeviceId();
//
// Device update
KapuaLocator locator = KapuaLocator.getInstance();
DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
Device device = deviceRegistryService.find(scopeId, deviceId);
//
// Event create
DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, device.getId(), message.getReceivedOn(), "MISSING");
deviceEventCreator.setEventMessage(payload.toDisplayString());
// TODO check this change
deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
deviceEventCreator.setSentOn(message.getReceivedOn());
KapuaPosition position = message.getPosition();
if (position != null) {
deviceEventCreator.setPosition(position);
}
deviceEventService.create(deviceEventCreator);
}
use of org.eclipse.kapua.message.KapuaPayload in project kapua by eclipse.
the class DeviceLifeCycleServiceImpl method applications.
@Override
public void applications(KapuaId connectionId, KapuaAppsMessage message) throws KapuaException {
KapuaPayload payload = message.getPayload();
KapuaId scopeId = message.getScopeId();
KapuaId deviceId = message.getDeviceId();
//
// Device update
KapuaLocator locator = KapuaLocator.getInstance();
DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class);
Device device = deviceRegistryService.find(scopeId, deviceId);
//
// Event create
DeviceEventService deviceEventService = locator.getService(DeviceEventService.class);
DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class);
DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(scopeId, device.getId(), message.getReceivedOn(), "APPLICATION");
deviceEventCreator.setEventMessage(payload.toDisplayString());
// TODO check this change
deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED);
deviceEventCreator.setSentOn(message.getReceivedOn());
KapuaPosition position = message.getPosition();
if (position != null) {
deviceEventCreator.setPosition(position);
}
deviceEventService.create(deviceEventCreator);
}
Aggregations