@Override public String marshal(KapuaAppProperties v) throws Exception { return v.getValue(); }
@Override protected KuraRequestChannel translateChannel(GenericRequestChannel kapuaChannel) throws KapuaException { KuraRequestChannel kuraRequestChannel = new KuraRequestChannel(); kuraRequestChannel.setMessageClassification(CONTROL_MESSAGE_CLASSIFIER); StringBuilder appIdSb = new StringBuilder(); appIdSb.append(kapuaChannel.getAppName().getValue()); if (kapuaChannel.getVersion() != null && StringUtils.isNotEmpty(kapuaChannel.getVersion().getValue())) { appIdSb.append("-") .append(kapuaChannel.getVersion().getValue()); } kuraRequestChannel.setAppId(appIdSb.toString()); kuraRequestChannel.setMethod(MethodDictionaryKapuaKura.get(kapuaChannel.getMethod())); kuraRequestChannel.setResources(kapuaChannel.getResources()); return kuraRequestChannel; }
@Override protected KuraRequestChannel translateChannel(GenericRequestChannel kapuaChannel) throws KapuaException { KuraRequestChannel kuraRequestChannel = new KuraRequestChannel(); kuraRequestChannel.setMessageClassification(CONTROL_MESSAGE_CLASSIFIER); StringBuilder appIdSb = new StringBuilder(); appIdSb.append(kapuaChannel.getAppName().getValue()); if (kapuaChannel.getVersion() != null && StringUtils.isNotEmpty(kapuaChannel.getVersion().getValue())) { appIdSb.append("-") .append(kapuaChannel.getVersion().getValue()); } kuraRequestChannel.setAppId(appIdSb.toString()); kuraRequestChannel.setMethod(MethodDictionaryKapuaKura.get(kapuaChannel.getMethod())); kuraRequestChannel.setResources(kapuaChannel.getResources()); return kuraRequestChannel; }
protected KapuaId createManagementOperation(KapuaId scopeId, KapuaId deviceId, KapuaId operationId, int totalCheckpoints, KapuaRequestMessage<?, ?> requestMessage) throws KapuaException { DeviceManagementOperationCreator deviceManagementOperationCreator = DEVICE_MANAGEMENT_OPERATION_FACTORY.newCreator(scopeId); deviceManagementOperationCreator.setDeviceId(deviceId); deviceManagementOperationCreator.setOperationId(operationId); deviceManagementOperationCreator.setStartedOn(new Date()); deviceManagementOperationCreator.setAppId(requestMessage.getChannel().getAppName().getValue()); deviceManagementOperationCreator.setAction(requestMessage.getChannel().getMethod()); deviceManagementOperationCreator.setResource(!requestMessage.getChannel().getSemanticParts().isEmpty() ? requestMessage.getChannel().getSemanticParts().get(0) : null); deviceManagementOperationCreator.setStatus(OperationStatus.RUNNING); deviceManagementOperationCreator.setInputProperties(extractInputProperties(requestMessage)); DeviceManagementOperation deviceManagementOperation = KapuaSecurityUtils.doPrivileged(() -> DEVICE_MANAGEMENT_OPERATION_REGISTRY_SERVICE.create(deviceManagementOperationCreator)); return deviceManagementOperation.getId(); }
/** * Creates a {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} extracting data from the given {@link KapuaRequestMessage} and {@link KapuaResponseMessage}. * <p> * This operation is performed using {@link KapuaSecurityUtils#doPrivileged(ThrowingRunnable)} since {@link org.eclipse.kapua.service.device.registry.event.DeviceEventDomain} isn't a required * permission to use any of the Device Management Services. * * @param scopeId The scopeId in which to create the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} * @param deviceId The {@link org.eclipse.kapua.service.device.registry.Device} id for which the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} is created * @param requestMessage The {@link KapuaRequestMessage} of the DeviceManagementService operation from which to extract data. * @param responseMessage The {@link KapuaResponseMessage} of the DeviceManagementService operation from which to extract data. * @throws KapuaException If the creation of the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} fails for some reasons * @since 1.0.0 */ protected void createDeviceEvent(KapuaId scopeId, KapuaId deviceId, KapuaRequestMessage<?, ?> requestMessage, KapuaResponseMessage responseMessage) throws KapuaException { DeviceEventCreator deviceEventCreator = DEVICE_EVENT_FACTORY.newCreator( scopeId, deviceId, responseMessage.getReceivedOn(), requestMessage.getChannel().getAppName().getValue()); deviceEventCreator.setPosition(responseMessage.getPosition()); deviceEventCreator.setSentOn(responseMessage.getSentOn()); deviceEventCreator.setAction(requestMessage.getChannel().getMethod()); deviceEventCreator.setResponseCode(responseMessage.getResponseCode()); deviceEventCreator.setEventMessage(responseMessage.getPayload().toDisplayString()); KapuaSecurityUtils.doPrivileged(() -> DEVICE_EVENT_SERVICE.create(deviceEventCreator)); }
.newCreator(requestInput.getScopeId(), requestInput.getDeviceId(), responseMessage.getReceivedOn(), requestInput.getChannel().getAppName().getValue()); deviceEventCreator.setPosition(responseMessage.getPosition()); deviceEventCreator.setSentOn(responseMessage.getSentOn());
.newCreator(requestInput.getScopeId(), requestInput.getDeviceId(), responseMessage.getReceivedOn(), requestInput.getChannel().getAppName().getValue()); deviceEventCreator.setPosition(responseMessage.getPosition()); deviceEventCreator.setSentOn(responseMessage.getSentOn());