From 7ccd7c63ccf2bd20854514dde942f148020a1930 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Wed, 20 Dec 2023 14:45:23 +0100 Subject: [PATCH 1/2] feat(deviceManagement): mapped missing DeviceInventoryContainer.state property Signed-off-by: Alberto Codutti --- .../DeviceTabInventoryTabContainer.java | 6 +++ ...tDeviceInventoryManagementServiceImpl.java | 3 ++ .../inventory/GwtInventoryContainer.java | 29 +++++++++++ ...ORY-V1_GET_inventory_containers_reply.json | 30 ++++++++---- .../deviceInventory/deviceInventory.yaml | 14 +++++- .../containers/KuraInventoryContainer.java | 30 ++++++++++-- .../container/DeviceInventoryContainer.java | 17 +++++++ .../DeviceInventoryContainerState.java | 49 +++++++++++++++++++ .../DeviceInventoryManagementServiceImpl.java | 1 + .../DeviceInventoryContainerImpl.java | 13 +++++ ...torAppInventoryContainerExecKapuaKura.java | 3 ++ ...stractTranslatorAppInventoryKuraKapua.java | 12 +++++ 12 files changed, 192 insertions(+), 15 deletions(-) create mode 100644 service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainerState.java diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/client/device/inventory/DeviceTabInventoryTabContainer.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/client/device/inventory/DeviceTabInventoryTabContainer.java index c0167417a0a..b1544693967 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/client/device/inventory/DeviceTabInventoryTabContainer.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/client/device/inventory/DeviceTabInventoryTabContainer.java @@ -114,6 +114,12 @@ protected void onRender(Element parent, int index) { column.setWidth(80); configs.add(column); + column = new ColumnConfig(); + column.setId("state"); + column.setHeader("State"); + column.setWidth(80); + configs.add(column); + ColumnModel columnModel = new ColumnModel(configs); RpcProxy> proxy = new RpcProxy>() { diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceInventoryManagementServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceInventoryManagementServiceImpl.java index 31844682869..2593bdec1a9 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceInventoryManagementServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceInventoryManagementServiceImpl.java @@ -35,6 +35,7 @@ import org.eclipse.kapua.service.device.management.inventory.model.bundle.DeviceInventoryBundles; import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainer; import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainerAction; +import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainerState; import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainers; import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventory; import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventoryItem; @@ -154,6 +155,7 @@ public ListLoadResult findDeviceContainers(String scopeId gwtInventoryContainer.setName(inventoryContainer.getName()); gwtInventoryContainer.setVersion(inventoryContainer.getVersion()); gwtInventoryContainer.setType(inventoryContainer.getContainerType()); + gwtInventoryContainer.setState(inventoryContainer.getState().name()); gwtInventoryContainers.add(gwtInventoryContainer); } @@ -176,6 +178,7 @@ public void execDeviceContainer(GwtXSRFToken xsrfToken, String scopeIdString, St deviceInventoryContainer.setName(gwtInventoryContainer.getName()); deviceInventoryContainer.setVersion(gwtInventoryContainer.getVersion()); deviceInventoryContainer.setContainerType(gwtInventoryContainer.getType()); + deviceInventoryContainer.setState(DeviceInventoryContainerState.valueOf(gwtInventoryContainer.getState())); DEVICE_INVENTORY_MANAGEMENT_SERVICE.execContainer( scopeId, diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/model/management/inventory/GwtInventoryContainer.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/model/management/inventory/GwtInventoryContainer.java index 0d7d0231e80..27f0f3bc915 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/model/management/inventory/GwtInventoryContainer.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/model/management/inventory/GwtInventoryContainer.java @@ -16,6 +16,22 @@ public class GwtInventoryContainer extends KapuaBaseModel { + public enum GwtInventoryContainerState { + UNKNOWN, + INSTALLED, + UNINSTALLED, + ACTIVE + } + + @Override + public X get(String property) { + if ("stateEnum".equals(property)) { + return (X) (GwtInventoryContainer.GwtInventoryContainerState.valueOf(getState())); + } else { + return super.get(property); + } + } + private static final long serialVersionUID = -4434969168565872354L; public void setName(String name) { @@ -41,4 +57,17 @@ public void setType(String type) { public String getType() { return get("type"); } + + public String getState() { + return get("state"); + } + + public GwtInventoryContainerState getStateEnum() { + return get("stateEnum"); + } + + public void setState(String state) { + set("state", state); + } + } diff --git a/qa/integration/src/test/resources/mqtt/INVENTORY-V1_GET_inventory_containers_reply.json b/qa/integration/src/test/resources/mqtt/INVENTORY-V1_GET_inventory_containers_reply.json index 378570941c3..ab2e4b9adb6 100644 --- a/qa/integration/src/test/resources/mqtt/INVENTORY-V1_GET_inventory_containers_reply.json +++ b/qa/integration/src/test/resources/mqtt/INVENTORY-V1_GET_inventory_containers_reply.json @@ -8,52 +8,62 @@ { "name": "consumer-telemetry", "version": "kapua/kapua-consumer-telemetry:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "job-engine", "version": "kapua/kapua-job-engine:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "kapua-console", "version": "kapua/kapua-console:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "kapua-api", "version": "kapua/kapua-api:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "message-broker", "version": "kapua/kapua-broker:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "es", "version": "docker.elastic.co/elasticsearch/elasticsearch:7.8.1", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "db", "version": "kapua/kapua-sql:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "ACTIVE" }, { "name": "events-broker", "version": "kapua/kapua-events-broker:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "UNKNOWN" }, { "name": "clever_heisenberg", "version": "kura_alpine:", - "type": "DOCKER" + "type": "DOCKER", + "state": "UNINSTALLED" }, { "name": "kura", "version": "eclipse/kura:latest", - "type": "DOCKER" + "type": "DOCKER", + "state": "INSTALLED" } ] } \ No newline at end of file diff --git a/rest-api/resources/src/main/resources/openapi/deviceInventory/deviceInventory.yaml b/rest-api/resources/src/main/resources/openapi/deviceInventory/deviceInventory.yaml index ffc5ffc5ee0..643a03e14b3 100644 --- a/rest-api/resources/src/main/resources/openapi/deviceInventory/deviceInventory.yaml +++ b/rest-api/resources/src/main/resources/openapi/deviceInventory/deviceInventory.yaml @@ -11,7 +11,7 @@ info: name: Eclipse Public License 2.0 url: https://www.eclipse.org/legal/epl-2.0 -paths: { } +paths: {} components: schemas: @@ -81,6 +81,13 @@ components: name: org.eclipse.equinox.cm version: 1.4.400.v20200422-1833 status: RESOLVED + deviceInventoryContainerState: + type: string + enum: + - ACTIVE + - INSTALLED + - UNINSTALLED + - UNKNOWN deviceInventoryContainer: type: object properties: @@ -90,10 +97,13 @@ components: type: string containerType: type: string + state: + $ref: '#/components/schemas/deviceInventoryContainerState' example: name: docker_container_1 version: nginx:latest containerType: DOCKER + state: ACTIVE deviceInventoryContainers: type: object properties: @@ -107,9 +117,11 @@ components: - name: docker_container_1 version: nginx:latest containerType: DOCKER + state: ACTIVE - name: docker_container_2 version: haproxy:latest containerType: DOCKER + state: INSTALLED deviceInventorySystemPackage: type: object properties: diff --git a/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/inventory/containers/KuraInventoryContainer.java b/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/inventory/containers/KuraInventoryContainer.java index 8ac66c8f6c1..fbc4939132a 100644 --- a/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/inventory/containers/KuraInventoryContainer.java +++ b/service/device/call/kura/src/main/java/org/eclipse/kapua/service/device/call/kura/model/inventory/containers/KuraInventoryContainer.java @@ -32,6 +32,9 @@ public class KuraInventoryContainer { @JsonProperty("type") public String type; + @JsonProperty("state") + public String state; + /** * Gets the name. * @@ -73,9 +76,9 @@ public void setVersion(String version) { } /** - * Gets the state. + * Gets the type. * - * @return The state. + * @return The type. * @since 2.0.0 */ public String getType() { @@ -83,13 +86,32 @@ public String getType() { } /** - * Sets the state. + * Sets the type. * - * @param type The state. + * @param type The type. * @since 2.0.0 */ public void setType(String type) { this.type = type; } + /** + * Gets the state + * + * @return The state + * @since 2.0.0 + */ + public String getState() { + return state; + } + + /** + * Sets the state + * + * @param state The state + * @since 2.0.0 + */ + public void setState(String state) { + this.state = state; + } } diff --git a/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainer.java b/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainer.java index 87159a0e0d2..0548fd396cb 100644 --- a/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainer.java +++ b/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainer.java @@ -80,4 +80,21 @@ public interface DeviceInventoryContainer { * @since 2.0.0 */ void setContainerType(String containerType); + + /** + * Gets the {@link DeviceInventoryContainerState}. + * + * @return The {@link DeviceInventoryContainerState}. + * @since 2.0.0 + */ + DeviceInventoryContainerState getState(); + + /** + * Sets the {@link DeviceInventoryContainerState}. + * + * @param state The {@link DeviceInventoryContainerState}. + * @since 2.0.0 + */ + void setState(DeviceInventoryContainerState state); + } diff --git a/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainerState.java b/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainerState.java new file mode 100644 index 00000000000..fb5783923e1 --- /dev/null +++ b/service/device/management/inventory/api/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/DeviceInventoryContainerState.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.service.device.management.inventory.model.container; + +/** + * The {@link DeviceInventoryContainer} states. + * + * @since 2.0.0 + */ +public enum DeviceInventoryContainerState { + + /** + * The container is running. + * + * @since 2.0.0 + */ + ACTIVE, + + /** + * The container is starting + * + * @since 2.0.0 + */ + INSTALLED, + + /** + * Tontainer has failed, or is stopped + * + * @since 2.0.0 + */ + UNINSTALLED, + + /** + * The container state can not be determined + * + * @since 2.0.0 + */ + UNKNOWN, +} diff --git a/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java b/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java index 099c00d35b9..22b418ed14b 100644 --- a/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java +++ b/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java @@ -307,6 +307,7 @@ public void execContainer(KapuaId scopeId, KapuaId deviceId, DeviceInventoryCont ArgumentValidator.notNull(deviceInventoryContainer.getName(), "deviceInventoryContainer.name"); ArgumentValidator.notNull(deviceInventoryContainer.getVersion(), "deviceInventoryContainer.version"); ArgumentValidator.notNull(deviceInventoryContainer.getContainerType(), "deviceInventoryContainer.type"); + ArgumentValidator.notNull(deviceInventoryContainer.getState(), "deviceInventoryContainer.state"); ArgumentValidator.notNull(deviceInventoryContainerAction, "deviceInventoryContainerAction"); // Check Access authorizationService.checkPermission(permissionFactory.newPermission(DeviceManagementDomains.DEVICE_MANAGEMENT_DOMAIN, Actions.write, scopeId)); diff --git a/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/internal/DeviceInventoryContainerImpl.java b/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/internal/DeviceInventoryContainerImpl.java index a3c05691af7..4f942fc5150 100644 --- a/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/internal/DeviceInventoryContainerImpl.java +++ b/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/model/container/internal/DeviceInventoryContainerImpl.java @@ -13,6 +13,7 @@ package org.eclipse.kapua.service.device.management.inventory.model.container.internal; import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainer; +import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainerState; /** * {@link DeviceInventoryContainer} implementation. @@ -25,6 +26,8 @@ public class DeviceInventoryContainerImpl implements DeviceInventoryContainer { private String version; private String containerType; + private DeviceInventoryContainerState state; + /** * Constructor. * @@ -62,4 +65,14 @@ public String getContainerType() { public void setContainerType(String containerType) { this.containerType = containerType; } + + + public DeviceInventoryContainerState getState() { + return state; + } + + @Override + public void setState(DeviceInventoryContainerState state) { + this.state = state; + } } diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/inventory/TranslatorAppInventoryContainerExecKapuaKura.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/inventory/TranslatorAppInventoryContainerExecKapuaKura.java index 36f75eec4d5..933c58d4826 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/inventory/TranslatorAppInventoryContainerExecKapuaKura.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/inventory/TranslatorAppInventoryContainerExecKapuaKura.java @@ -74,6 +74,9 @@ protected KuraRequestPayload translatePayload(InventoryRequestPayload inventoryR kuraInventoryContainer.setName(deviceInventoryContainer.getName()); kuraInventoryContainer.setVersion(deviceInventoryContainer.getVersion()); kuraInventoryContainer.setType(deviceInventoryContainer.getContainerType()); + if (deviceInventoryContainer.getState() != null) { + kuraInventoryContainer.setState(deviceInventoryContainer.getState().name()); + } kuraRequestPayload.setBody(getJsonMapper().writeValueAsString(kuraInventoryContainer).getBytes(CHAR_ENCODING)); } diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java index 33dfa78cb91..6bfcc6154bb 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java @@ -28,6 +28,7 @@ import org.eclipse.kapua.service.device.management.inventory.model.bundle.DeviceInventoryBundle; import org.eclipse.kapua.service.device.management.inventory.model.bundle.DeviceInventoryBundles; import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainer; +import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainerState; import org.eclipse.kapua.service.device.management.inventory.model.container.DeviceInventoryContainers; import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventory; import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventoryItem; @@ -39,6 +40,8 @@ import org.eclipse.kapua.translator.exception.InvalidChannelException; import org.eclipse.kapua.translator.kura.kapua.AbstractSimpleTranslatorResponseKuraKapua; import org.eclipse.kapua.translator.kura.kapua.TranslatorKuraKapuaUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * {@link Translator} {@code abstract} implementation from {@link KuraResponseMessage} to {@link InventoryResponseMessage} @@ -47,6 +50,8 @@ */ public class AbstractTranslatorAppInventoryKuraKapua extends AbstractSimpleTranslatorResponseKuraKapua { + private static final Logger LOG = LoggerFactory.getLogger(AbstractTranslatorAppInventoryKuraKapua.class); + private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); /** @@ -135,6 +140,13 @@ protected DeviceInventoryContainers translate(KuraInventoryContainers kuraInvent deviceInventoryContainer.setVersion(kuraInventoryContainer.getVersion()); deviceInventoryContainer.setContainerType(kuraInventoryContainer.getType()); + try { + deviceInventoryContainer.setState(DeviceInventoryContainerState.valueOf(kuraInventoryContainer.getState())); + } catch (IllegalArgumentException iae) { + LOG.warn("Unrecognised KuraInventoryContainer.state '{}' received. Defaulting to UNKNOWN state for DeviceInventoryContainer {}", kuraInventoryContainer.getState(), deviceInventoryContainer.getName(), iae); + deviceInventoryContainer.setState(DeviceInventoryContainerState.UNKNOWN); + } + deviceInventoryContainers.addInventoryContainer(deviceInventoryContainer); }); From 1fbb07beeb5b5ba981cb1a09136f0ff034eafe91 Mon Sep 17 00:00:00 2001 From: Alberto Codutti Date: Wed, 20 Dec 2023 14:54:22 +0100 Subject: [PATCH 2/2] fix(deviceManageemnt): fixed required attributes for DeviceInventoryContainer start and stop operations Signed-off-by: Alberto Codutti --- .../DeviceInventoryManagementServiceImpl.java | 2 -- .../AbstractTranslatorAppInventoryKuraKapua.java | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java b/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java index 22b418ed14b..9930100b579 100644 --- a/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java +++ b/service/device/management/inventory/internal/src/main/java/org/eclipse/kapua/service/device/management/inventory/internal/DeviceInventoryManagementServiceImpl.java @@ -306,8 +306,6 @@ public void execContainer(KapuaId scopeId, KapuaId deviceId, DeviceInventoryCont ArgumentValidator.notNull(deviceInventoryContainer, "deviceInventoryContainer"); ArgumentValidator.notNull(deviceInventoryContainer.getName(), "deviceInventoryContainer.name"); ArgumentValidator.notNull(deviceInventoryContainer.getVersion(), "deviceInventoryContainer.version"); - ArgumentValidator.notNull(deviceInventoryContainer.getContainerType(), "deviceInventoryContainer.type"); - ArgumentValidator.notNull(deviceInventoryContainer.getState(), "deviceInventoryContainer.state"); ArgumentValidator.notNull(deviceInventoryContainerAction, "deviceInventoryContainerAction"); // Check Access authorizationService.checkPermission(permissionFactory.newPermission(DeviceManagementDomains.DEVICE_MANAGEMENT_DOMAIN, Actions.write, scopeId)); diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java index 6bfcc6154bb..1bafa211103 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/inventory/AbstractTranslatorAppInventoryKuraKapua.java @@ -140,11 +140,13 @@ protected DeviceInventoryContainers translate(KuraInventoryContainers kuraInvent deviceInventoryContainer.setVersion(kuraInventoryContainer.getVersion()); deviceInventoryContainer.setContainerType(kuraInventoryContainer.getType()); - try { - deviceInventoryContainer.setState(DeviceInventoryContainerState.valueOf(kuraInventoryContainer.getState())); - } catch (IllegalArgumentException iae) { - LOG.warn("Unrecognised KuraInventoryContainer.state '{}' received. Defaulting to UNKNOWN state for DeviceInventoryContainer {}", kuraInventoryContainer.getState(), deviceInventoryContainer.getName(), iae); - deviceInventoryContainer.setState(DeviceInventoryContainerState.UNKNOWN); + if (deviceInventoryContainer.getState() != null) { + try { + deviceInventoryContainer.setState(DeviceInventoryContainerState.valueOf(kuraInventoryContainer.getState())); + } catch (IllegalArgumentException iae) { + LOG.warn("Unrecognised KuraInventoryContainer.state '{}' received. Defaulting to UNKNOWN state for DeviceInventoryContainer {}", kuraInventoryContainer.getState(), deviceInventoryContainer.getName(), iae); + deviceInventoryContainer.setState(DeviceInventoryContainerState.UNKNOWN); + } } deviceInventoryContainers.addInventoryContainer(deviceInventoryContainer);