diff --git a/console/module/api/src/main/resources/org/eclipse/kapua/app/console/module/api/client/messages/ValidationMessages.properties b/console/module/api/src/main/resources/org/eclipse/kapua/app/console/module/api/client/messages/ValidationMessages.properties index 616461fb295..eeb30aaffac 100644 --- a/console/module/api/src/main/resources/org/eclipse/kapua/app/console/module/api/client/messages/ValidationMessages.properties +++ b/console/module/api/src/main/resources/org/eclipse/kapua/app/console/module/api/client/messages/ValidationMessages.properties @@ -373,6 +373,7 @@ devEsfVersion=KURA/ESF Version devNumProc=Number of Processors devRamTot=Total RAM devRamFree=Free RAM +devTamperStatus=Tamper status netConnIface=Network Interface netConnIfaceIp=Network Interface IP Address diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java index 12d9b88f879..7644fc0c4fe 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java @@ -12,6 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.server; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Callable; + import com.extjs.gxt.ui.client.data.BaseListLoadResult; import com.extjs.gxt.ui.client.data.BasePagingLoadConfig; import com.extjs.gxt.ui.client.data.BasePagingLoadResult; @@ -72,12 +78,6 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Callable; - /** * The server side implementation of the Device RPC service. */ @@ -254,6 +254,7 @@ public User call() throws Exception { pairs.add(new GwtGroupedNVPair(DEV_HW, "devModelId", device.getModelId())); pairs.add(new GwtGroupedNVPair(DEV_HW, "devModelName", device.getModelName())); pairs.add(new GwtGroupedNVPair(DEV_HW, "devSerialNumber", device.getSerialNumber())); + pairs.add(new GwtGroupedNVPair(DEV_HW, "devTamperStatus", device.getTamperStatus())); pairs.add(new GwtGroupedNVPair(DEV_SW, "devFirmwareVersion", device.getFirmwareVersion())); pairs.add(new GwtGroupedNVPair(DEV_SW, "devBiosVersion", device.getBiosVersion())); diff --git a/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayload.java b/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayload.java index 849ec5e7b8c..dcf66d77ca8 100644 --- a/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayload.java +++ b/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayload.java @@ -498,4 +498,20 @@ public interface KapuaBirthPayload extends KapuaLifecyclePayload { * @since 1.5.0 */ void setExtendedProperties(String extendedProperties); + + /** + * Gets the tamper status + * + * @return The tamper status. + * @since 2.0.0 + */ + String getTamperStatus(); + + /** + * Sets the tamper status. + * + * @param tamperStatus The tamper status. + * @since 1.5.0 + */ + void setTamperStatus(String tamperStatus); } diff --git a/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayloadAttibutes.java b/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayloadAttibutes.java index 430f8b207c4..4a1f1deab0a 100644 --- a/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayloadAttibutes.java +++ b/message/api/src/main/java/org/eclipse/kapua/message/device/lifecycle/KapuaBirthPayloadAttibutes.java @@ -173,4 +173,9 @@ private KapuaBirthPayloadAttibutes() { * @since 1.5.0 */ public static final String EXTENDED_PROPERTIES = "extendedProperties"; + + /** + * @since 2.0.0 + */ + public static final String TAMPER_STATUS = "tamperStatus"; } diff --git a/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsPayloadImpl.java b/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsPayloadImpl.java index 6f3e46e21eb..447b56b4199 100644 --- a/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsPayloadImpl.java +++ b/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsPayloadImpl.java @@ -66,7 +66,8 @@ public KapuaAppsPayloadImpl(String uptime, String modemImei, String modemImsi, String modemIccid, - String extendedProperties) { + String extendedProperties, + String tamperStatus) { super(uptime, displayName, modelName, @@ -96,6 +97,7 @@ public KapuaAppsPayloadImpl(String uptime, modemImei, modemImsi, modemIccid, - extendedProperties); + extendedProperties, + tamperStatus); } } diff --git a/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthPayloadImpl.java b/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthPayloadImpl.java index ad1780e11fa..79716f865c0 100644 --- a/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthPayloadImpl.java +++ b/message/internal/src/main/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthPayloadImpl.java @@ -69,6 +69,7 @@ public KapuaBirthPayloadImpl() { * @param modemImsi The {@link KapuaBirthPayloadAttibutes#MODEM_IMSI} of the {@link KapuaBirthMessage} * @param modemIccid The {@link KapuaBirthPayloadAttibutes#MODEM_ICCID} of the {@link KapuaBirthMessage} * @param extendedProperties The {@link KapuaBirthPayloadAttibutes#EXTENDED_PROPERTIES} of the {@link KapuaBirthMessage} + * @param tamperStatus The {@link KapuaBirthPayloadAttibutes#TAMPER_STATUS} of the {@link KapuaBirthMessage} * @since 1.0.0 */ public KapuaBirthPayloadImpl(String uptime, @@ -100,7 +101,8 @@ public KapuaBirthPayloadImpl(String uptime, String modemImei, String modemImsi, String modemIccid, - String extendedProperties) { + String extendedProperties, + String tamperStatus) { setUptime(uptime); setDisplayName(displayName); @@ -132,6 +134,7 @@ public KapuaBirthPayloadImpl(String uptime, setModemImsi(modemImsi); setModemIccid(modemIccid); setExtendedProperties(extendedProperties); + setTamperStatus(tamperStatus); } @Override @@ -433,4 +436,14 @@ public String getExtendedProperties() { public void setExtendedProperties(String extendedProperties) { getMetrics().put(KapuaBirthPayloadAttibutes.EXTENDED_PROPERTIES, extendedProperties); } + + @Override + public String getTamperStatus() { + return (String) getMetrics().get(KapuaBirthPayloadAttibutes.TAMPER_STATUS); + } + + @Override + public void setTamperStatus(String temperStatus) { + getMetrics().put(KapuaBirthPayloadAttibutes.TAMPER_STATUS, temperStatus); + } } diff --git a/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsMessageTest.java b/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsMessageTest.java index 7d04299de0b..b0cabd3bf8f 100644 --- a/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsMessageTest.java +++ b/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaAppsMessageTest.java @@ -56,6 +56,7 @@ public class KapuaAppsMessageTest { "~~osVersion=osV-1" + "~~partNumber=part-1" + "~~serialNumber=SN-123" + + "~~tamperStatus=NOT_TAMPERED" + "~~totalMemory=4" + "~~uptime=12"; @@ -161,7 +162,8 @@ private static KapuaAppsPayload populateKapuaAppsPayload() { " \"propertyName\": \"propertyValue\"\n" + " }\n" + " }\n" + - "}" + "}", + "NOT_TAMPERED" ); } } diff --git a/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthMessageTest.java b/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthMessageTest.java index ce867d3e34c..8c8f6eb05fb 100644 --- a/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthMessageTest.java +++ b/message/internal/src/test/java/org/eclipse/kapua/message/internal/device/lifecycle/KapuaBirthMessageTest.java @@ -52,6 +52,7 @@ public class KapuaBirthMessageTest { "~~osVersion=osV-1" + "~~partNumber=part-1" + "~~serialNumber=SN-123" + + "~~tamperStatus=NOT_TAMPERED" + "~~totalMemory=4" + "~~uptime=12"; @@ -165,7 +166,8 @@ private static KapuaBirthPayload populateKapuaBirthPayload() { " \"propertyName\": \"propertyValue\"\n" + " }\n" + " }\n" + - "}" + "}", + "NOT_TAMPERED" ); } } diff --git a/qa/common/src/main/java/org/eclipse/kapua/qa/common/BasicSteps.java b/qa/common/src/main/java/org/eclipse/kapua/qa/common/BasicSteps.java index 492e487766a..00f4aee494d 100644 --- a/qa/common/src/main/java/org/eclipse/kapua/qa/common/BasicSteps.java +++ b/qa/common/src/main/java/org/eclipse/kapua/qa/common/BasicSteps.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.kapua.qa.common; +import java.time.Duration; +import java.util.Date; +import java.util.Map; +import javax.inject.Inject; + import com.google.common.base.Strings; import com.google.inject.Singleton; import io.cucumber.java.After; @@ -57,11 +62,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import java.time.Duration; -import java.util.Date; -import java.util.Map; - @Singleton public class BasicSteps extends TestBase { diff --git a/rest-api/resources/src/main/resources/openapi/device/device-scopeId-deviceId.yaml b/rest-api/resources/src/main/resources/openapi/device/device-scopeId-deviceId.yaml index e9b76a2c3bd..03f496dea4b 100644 --- a/rest-api/resources/src/main/resources/openapi/device/device-scopeId-deviceId.yaml +++ b/rest-api/resources/src/main/resources/openapi/device/device-scopeId-deviceId.yaml @@ -73,6 +73,7 @@ paths: groupName: Hardware Info name: CPU Cores value: 4 + tamperStatus: NOT_TAMPERED tagIds: [ ] required: true responses: diff --git a/rest-api/resources/src/main/resources/openapi/device/device-scopeId.yaml b/rest-api/resources/src/main/resources/openapi/device/device-scopeId.yaml index b2d29dd3254..20aeb4b3959 100644 --- a/rest-api/resources/src/main/resources/openapi/device/device-scopeId.yaml +++ b/rest-api/resources/src/main/resources/openapi/device/device-scopeId.yaml @@ -94,6 +94,7 @@ paths: connectionIp: 127.0.0.1 applicationIdentifiers: heaterPROV-V2DEPLOY-V2VPNCLIENT-V2CONF-V1CERT-V1ASSET-V1CMD-V1 acceptEncoding: gzip + tamperStatus: NOT_TAMPERED tagIds: [] with-fetch-attributes: value: @@ -158,6 +159,7 @@ paths: connectionIp: 127.0.0.1 applicationIdentifiers: heaterPROV-V2DEPLOY-V2VPNCLIENT-V2CONF-V1CERT-V1ASSET-V1CMD-V1 acceptEncoding: gzip + tamperStatus: NOT_TAMPERED tagIds: [] 401: diff --git a/rest-api/resources/src/main/resources/openapi/device/device.yaml b/rest-api/resources/src/main/resources/openapi/device/device.yaml index 72d861f69f7..a1ab48c5b84 100644 --- a/rest-api/resources/src/main/resources/openapi/device/device.yaml +++ b/rest-api/resources/src/main/resources/openapi/device/device.yaml @@ -138,6 +138,9 @@ components: customAttribute5: description: A Custom Attribute of this Device - 5 type: string + tamperStatus: + description: The tamper status of the Device + type: string extendedProperties: type: array items: @@ -177,6 +180,7 @@ components: groupName: Hardware Info name: CPU Cores value: 4 + tamperStatus: NOT_TAMPERED tagIds: [ ] deviceCreator: allOf: @@ -264,6 +268,9 @@ components: customAttribute5: description: A Custom Attirbute of this Device - 5 type: string + tamperStatus: + description: The tamper status of the Device + type: string tagIds: description: A list of tag ID to link to the Device type: array @@ -285,6 +292,7 @@ components: osgiFrameworkVersion: 1.7.0 acceptEncoding: gzip deviceCredentialsMode: LOOSE + tamperStatus: NOT_TAMPERED tagIds: [] deviceListResult: allOf: diff --git a/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/message/kura/lifecycle/AbstractKuraAppsBirthPayload.java b/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/message/kura/lifecycle/AbstractKuraAppsBirthPayload.java index e6828517c18..5250c43210d 100644 --- a/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/message/kura/lifecycle/AbstractKuraAppsBirthPayload.java +++ b/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/message/kura/lifecycle/AbstractKuraAppsBirthPayload.java @@ -240,6 +240,14 @@ public class AbstractKuraAppsBirthPayload extends AbstractKuraLifecyclePayload i * @since 1.0.0 */ protected static final String DEFAULT_APPLICATION_FRAMEWORK = "Kura"; + + /** + * {@link Device} tamper status. + * + * @since 2.0.0 + */ + protected static final String TAMPER_STATUS = "tamper_status"; + private static final long serialVersionUID = 5490945197263668115L; @@ -283,6 +291,7 @@ public AbstractKuraAppsBirthPayload() { * @param modemImsi {@link Device} modem IMSI. * @param modemIccid {@link Device} modem ICCID. * @param extendedProperties {@link Device} extended properties. + * @param tamperStatus {@link Device} tamper status. * @since 1.0.0 */ public AbstractKuraAppsBirthPayload(String uptime, @@ -312,7 +321,8 @@ public AbstractKuraAppsBirthPayload(String uptime, String modemImei, String modemImsi, String modemIccid, - String extendedProperties) { + String extendedProperties, + String tamperStatus) { super(); if (uptime != null) { @@ -399,6 +409,9 @@ public AbstractKuraAppsBirthPayload(String uptime, if (extendedProperties != null) { getMetrics().put(EXTENDED_PROPERTIES, extendedProperties); } + if (tamperStatus != null) { + getMetrics().put(TAMPER_STATUS, tamperStatus); + } } /** @@ -713,5 +726,15 @@ public String getExtendedProperties() { return (String) getMetrics().get(EXTENDED_PROPERTIES); } + /** + * Gets the {@link Device} tamper status. + * + * @return The {@link Device} extended properties. + * @since 2.0.0 + */ + public String getTamperStatus() { + return (String) getMetrics().get(TAMPER_STATUS); + } + } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/Device.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/Device.java index e3c88d27f1f..03706cb6a49 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/Device.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/Device.java @@ -69,6 +69,7 @@ "customAttribute4", "customAttribute5", "extendedProperties", + "tamperStatus", "tagIds" }, factoryClass = DeviceXmlRegistry.class, factoryMethod = "newDevice") public interface Device extends KapuaUpdatableEntity { @@ -603,4 +604,21 @@ default String getType() { * @since 1.5.0 */ void setExtendedProperties(List extendedProperties); + + /** + * Gets the tamper status. + * + * @return The tamper status. + * @since 2.0.0 + */ + @XmlElement(name = "tamperStatus") + String getTamperStatus(); + + /** + * Sets the tamper status. + * + * @param tamperStatus The tamper status. + * @since 2.0.0 + */ + void setTamperStatus(String tamperStatus); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java index 403df7b73c3..7ce14db5eb7 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java @@ -69,7 +69,8 @@ "customAttribute4", "customAttribute5", "extendedProperties", - "tagIds" + "tagIds", + "tamperStatus" }, factoryClass = DeviceXmlRegistry.class, factoryMethod = "newDeviceCreator") public interface DeviceCreator extends KapuaUpdatableEntityCreator { @@ -560,6 +561,23 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { */ void setExtendedProperties(List extendedProperties); + /** + * Gets the tamper status. + * + * @return The application tamper status. + * @since 2.0.0 + */ + @XmlElement(name = "tamperStatus") + String getTamperStatus(); + + /** + * Sets the tamper status. + * + * @param tamperStatus The tamper status. + * @since 2.0.0 + */ + void setTamperStatus(String tamperStatus); + /** * Gets the list of tags associated with the device. diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java index 0cfb47c7fd3..746f7e2f0df 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java @@ -61,6 +61,7 @@ public class DeviceCreatorImpl extends AbstractKapuaUpdatableEntityCreator extendedProperties; + private String tamperStatus; private Set tagIds; /** @@ -362,6 +363,16 @@ public void setExtendedProperties(List extendedPropertie this.extendedProperties = extendedProperties; } + @Override + public String getTamperStatus() { + return tamperStatus; + } + + @Override + public void setTamperStatus(String tamperStatus) { + this.tamperStatus = tamperStatus; + } + @Override public Set getTagIds() { return tagIds == null ? new HashSet<>() : tagIds; diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImpl.java index d4b6f63fec9..b5df0d4bd74 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImpl.java @@ -12,20 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.internal; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntity; -import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.registry.Device; -import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; -import org.eclipse.kapua.service.device.registry.DeviceStatus; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; -import org.eclipse.kapua.service.device.registry.connection.internal.DeviceConnectionImpl; -import org.eclipse.kapua.service.device.registry.event.DeviceEvent; -import org.eclipse.kapua.service.device.registry.event.internal.DeviceEventImpl; -import org.eclipse.kapua.service.tag.Taggable; - +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Basic; @@ -40,10 +30,20 @@ import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.eclipse.kapua.KapuaException; +import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntity; +import org.eclipse.kapua.commons.model.id.KapuaEid; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.device.registry.Device; +import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; +import org.eclipse.kapua.service.device.registry.DeviceStatus; +import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; +import org.eclipse.kapua.service.device.registry.connection.internal.DeviceConnectionImpl; +import org.eclipse.kapua.service.device.registry.event.DeviceEvent; +import org.eclipse.kapua.service.device.registry.event.internal.DeviceEventImpl; +import org.eclipse.kapua.service.tag.Taggable; /** * {@link Device} implementation. @@ -197,6 +197,10 @@ public class DeviceImpl extends AbstractKapuaUpdatableEntity implements Device, @CollectionTable(name = "dvc_device_extended_properties", joinColumns = @JoinColumn(name = "device_id", referencedColumnName = "id")) private List extendedProperties; + @Basic + @Column(name = "tamper_status") + private String tamperStatus; + /** * Constructor * @@ -654,6 +658,16 @@ public void setExtendedProperties(List extendedPropertie } } + @Override + public String getTamperStatus() { + return tamperStatus; + } + + @Override + public void setTamperStatus(String tamperStatus) { + this.tamperStatus = tamperStatus; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java index f4a7ff755f8..f9ce2fdc30e 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java @@ -12,6 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.lifecycle.internal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.validation.constraints.NotNull; + import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; @@ -49,15 +58,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; - /** * {@link DeviceLifeCycleService} implementation. * @@ -126,6 +126,8 @@ public void birth(KapuaId connectionId, KapuaBirthMessage birthMessage) throws K deviceCreator.setExtendedProperties(buildDeviceExtendedPropertyFromBirth(birthPayload.getExtendedProperties())); + deviceCreator.setTamperStatus(birthPayload.getTamperStatus()); + // issue #57 deviceCreator.setConnectionId(connectionId); @@ -213,6 +215,8 @@ private Device updateDeviceInfoFromMessage(KapuaId scopeId, KapuaId deviceId, Ka device.setExtendedProperties(buildDeviceExtendedPropertyFromBirth(birthPayload.getExtendedProperties())); + device.setTamperStatus(birthPayload.getTamperStatus()); + // issue #57 device.setConnectionId(connectionId); diff --git a/service/device/registry/internal/src/main/resources/liquibase/2.0.0/changelog-device-2.0.0.xml b/service/device/registry/internal/src/main/resources/liquibase/2.0.0/changelog-device-2.0.0.xml index 8a4da6277ea..97a336ae634 100644 --- a/service/device/registry/internal/src/main/resources/liquibase/2.0.0/changelog-device-2.0.0.xml +++ b/service/device/registry/internal/src/main/resources/liquibase/2.0.0/changelog-device-2.0.0.xml @@ -20,5 +20,6 @@ + diff --git a/service/device/registry/internal/src/main/resources/liquibase/2.0.0/device_tamper-status.xml b/service/device/registry/internal/src/main/resources/liquibase/2.0.0/device_tamper-status.xml new file mode 100644 index 00000000000..2906723327e --- /dev/null +++ b/service/device/registry/internal/src/main/resources/liquibase/2.0.0/device_tamper-status.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeAppsKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeAppsKuraKapua.java index c8b93186128..c866c88f5ea 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeAppsKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeAppsKuraKapua.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.translator.kura.kapua; +import javax.inject.Inject; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.message.device.lifecycle.KapuaAppsChannel; import org.eclipse.kapua.message.device.lifecycle.KapuaAppsMessage; @@ -32,8 +34,6 @@ import org.eclipse.kapua.translator.exception.InvalidPayloadException; import org.eclipse.kapua.translator.exception.TranslateException; -import javax.inject.Inject; - /** * {@link Translator} implementation from {@link KuraAppsMessage} to {@link KapuaAppsMessage} * @@ -117,7 +117,8 @@ private KapuaAppsPayload translate(KuraAppsPayload kuraAppsPayload) { kuraAppsPayload.getModemImei(), kuraAppsPayload.getModemImsi(), kuraAppsPayload.getModemIccid(), - kuraAppsPayload.getExtendedProperties()); + kuraAppsPayload.getExtendedProperties(), + kuraAppsPayload.getTamperStatus()); } @Override diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeBirthKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeBirthKuraKapua.java index 7ddb374b609..e728a794866 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeBirthKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorLifeBirthKuraKapua.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.translator.kura.kapua; +import javax.inject.Inject; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.message.device.lifecycle.KapuaBirthChannel; import org.eclipse.kapua.message.device.lifecycle.KapuaBirthMessage; @@ -32,8 +34,6 @@ import org.eclipse.kapua.translator.exception.InvalidPayloadException; import org.eclipse.kapua.translator.exception.TranslateException; -import javax.inject.Inject; - /** * {@link Translator} implementation from {@link KuraBirthMessage} to {@link KapuaBirthMessage} * @@ -118,7 +118,8 @@ private KapuaBirthPayload translate(KuraBirthPayload kuraBirthPayload) { kuraBirthPayload.getModemImei(), kuraBirthPayload.getModemImsi(), kuraBirthPayload.getModemIccid(), - kuraBirthPayload.getExtendedProperties()); + kuraBirthPayload.getExtendedProperties(), + kuraBirthPayload.getTamperStatus()); } @Override