Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added support for INVENTORY-V1/bundles
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Mar 12, 2021
1 parent 3111b97 commit a87127b
Show file tree
Hide file tree
Showing 32 changed files with 804 additions and 97 deletions.
Expand Up @@ -51,8 +51,8 @@
import org.eclipse.kapua.service.device.call.kura.model.deploy.KuraBundleInfo;
import org.eclipse.kapua.service.device.call.kura.model.deploy.KuraDeploymentPackage;
import org.eclipse.kapua.service.device.call.kura.model.deploy.KuraDeploymentPackages;
import org.eclipse.kapua.service.device.call.kura.model.inventory.InventorySystemPackage;
import org.eclipse.kapua.service.device.call.kura.model.inventory.InventorySystemPackages;
import org.eclipse.kapua.service.device.call.kura.model.inventory.KuraInventoryPackage;
import org.eclipse.kapua.service.device.call.kura.model.inventory.KuraInventoryPackages;
import org.eclipse.kapua.service.device.call.kura.model.snapshot.KuraSnapshotIds;
import org.eclipse.kapua.service.device.management.asset.DeviceAssetXmlRegistry;
import org.eclipse.kapua.service.device.management.asset.DeviceAssets;
Expand All @@ -62,9 +62,9 @@
import org.eclipse.kapua.service.device.management.command.DeviceCommandOutput;
import org.eclipse.kapua.service.device.management.configuration.DeviceComponentConfiguration;
import org.eclipse.kapua.service.device.management.configuration.DeviceConfiguration;
import org.eclipse.kapua.service.device.management.inventory.model.DeviceInventory;
import org.eclipse.kapua.service.device.management.inventory.model.DeviceInventoryPackage;
import org.eclipse.kapua.service.device.management.inventory.model.xml.DeviceInventoryXmlRegistry;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventory;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventoryPackage;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventoryXmlRegistry;
import org.eclipse.kapua.service.device.management.packages.model.DevicePackages;
import org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadRequest;
import org.eclipse.kapua.service.device.management.packages.model.install.DevicePackageInstallRequest;
Expand Down Expand Up @@ -132,8 +132,8 @@ public JAXBContext getJAXBContext() throws KapuaException {
// Device Management Inventory
DeviceInventory.class,
DeviceInventoryPackage.class,
InventorySystemPackages.class,
InventorySystemPackage.class,
KuraInventoryPackages.class,
KuraInventoryPackage.class,
DeviceInventoryXmlRegistry.class,

DevicePackageDownloadRequest.class,
Expand Down
Expand Up @@ -19,7 +19,8 @@
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.service.KapuaService;
import org.eclipse.kapua.service.device.management.inventory.DeviceInventoryManagementService;
import org.eclipse.kapua.service.device.management.inventory.model.DeviceInventory;
import org.eclipse.kapua.service.device.management.inventory.model.bundle.inventory.DeviceInventoryBundles;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventory;
import org.eclipse.kapua.service.device.registry.Device;

import javax.ws.rs.GET;
Expand All @@ -36,21 +37,41 @@ public class DeviceManagementInventory extends AbstractKapuaResource {
private static final DeviceInventoryManagementService DEVICE_INVENTORY_MANAGEMENT_SERVICE = LOCATOR.getService(DeviceInventoryManagementService.class);

/**
* Returns the list of all the Bundles installed on the device.
* Gets the {@link DeviceInventory} present on the {@link Device}.
*
* @param scopeId The {@link ScopeId} of the {@link Device}.
* @param deviceId The id of the device
* @param scopeId The {@link Device#getScopeId()}.
* @param deviceId The {@link Device#getId()}.
* @param timeout The timeout of the operation in milliseconds
* @return The list of Bundles
* @return The {@link DeviceInventory}.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.0.0
* @since 1.5.0
*/
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public DeviceInventory get(
public DeviceInventory getInventory(
@PathParam("scopeId") ScopeId scopeId,
@PathParam("deviceId") EntityId deviceId,
@QueryParam("timeout") Long timeout) throws KapuaException {
return DEVICE_INVENTORY_MANAGEMENT_SERVICE.get(scopeId, deviceId, timeout);
return DEVICE_INVENTORY_MANAGEMENT_SERVICE.getInventory(scopeId, deviceId, timeout);
}

/**
* Gets the {@link DeviceInventoryBundles} present on the {@link Device}.
*
* @param scopeId The {@link Device#getScopeId()}.
* @param deviceId The {@link Device#getId()}.
* @param timeout The timeout of the operation in milliseconds
* @return The {@link DeviceInventory}.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.5.0
*/
@GET
@Path("bundles")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public DeviceInventoryBundles getInventoryBundles(
@PathParam("scopeId") ScopeId scopeId,
@PathParam("deviceId") EntityId deviceId,
@QueryParam("timeout") Long timeout) throws KapuaException {
return DEVICE_INVENTORY_MANAGEMENT_SERVICE.getBundles(scopeId, deviceId, timeout);
}
}
Expand Up @@ -144,8 +144,10 @@
import org.eclipse.kapua.service.device.call.kura.model.configuration.KuraDeviceConfiguration;
import org.eclipse.kapua.service.device.call.kura.model.deploy.KuraDeploymentPackage;
import org.eclipse.kapua.service.device.call.kura.model.deploy.KuraDeploymentPackages;
import org.eclipse.kapua.service.device.call.kura.model.inventory.InventorySystemPackage;
import org.eclipse.kapua.service.device.call.kura.model.inventory.InventorySystemPackages;
import org.eclipse.kapua.service.device.call.kura.model.inventory.KuraInventoryPackage;
import org.eclipse.kapua.service.device.call.kura.model.inventory.KuraInventoryPackages;
import org.eclipse.kapua.service.device.call.kura.model.inventory.bundles.inventory.KuraInventoryBundle;
import org.eclipse.kapua.service.device.call.kura.model.inventory.bundles.inventory.KuraInventoryBundles;
import org.eclipse.kapua.service.device.call.kura.model.snapshot.KuraSnapshotIds;
import org.eclipse.kapua.service.device.management.asset.DeviceAssetXmlRegistry;
import org.eclipse.kapua.service.device.management.asset.DeviceAssets;
Expand All @@ -158,9 +160,11 @@
import org.eclipse.kapua.service.device.management.configuration.DeviceComponentConfiguration;
import org.eclipse.kapua.service.device.management.configuration.DeviceConfiguration;
import org.eclipse.kapua.service.device.management.configuration.DeviceConfigurationXmlRegistry;
import org.eclipse.kapua.service.device.management.inventory.model.DeviceInventory;
import org.eclipse.kapua.service.device.management.inventory.model.DeviceInventoryPackage;
import org.eclipse.kapua.service.device.management.inventory.model.xml.DeviceInventoryXmlRegistry;
import org.eclipse.kapua.service.device.management.inventory.model.bundle.inventory.DeviceInventoryBundle;
import org.eclipse.kapua.service.device.management.inventory.model.bundle.inventory.DeviceInventoryBundles;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventory;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventoryPackage;
import org.eclipse.kapua.service.device.management.inventory.model.inventory.DeviceInventoryXmlRegistry;
import org.eclipse.kapua.service.device.management.message.notification.OperationStatus;
import org.eclipse.kapua.service.device.management.message.request.KapuaRequestChannel;
import org.eclipse.kapua.service.device.management.message.request.KapuaRequestMessage;
Expand Down Expand Up @@ -433,8 +437,12 @@ public JaxbContextResolver() {
// Device Management Inventory
DeviceInventory.class,
DeviceInventoryPackage.class,
InventorySystemPackages.class,
InventorySystemPackage.class,
KuraInventoryPackages.class,
KuraInventoryPackage.class,
DeviceInventoryBundles.class,
DeviceInventoryBundle.class,
KuraInventoryBundles.class,
KuraInventoryBundle.class,
DeviceInventoryXmlRegistry.class,

// Device Management Snapshots
Expand Down
Expand Up @@ -16,12 +16,12 @@
import com.fasterxml.jackson.annotation.JsonRootName;

/**
* {@link InventorySystemPackage} definition.
* {@link KuraInventoryPackage} definition.
*
* @since 1.5.0
*/
@JsonRootName("systemPackage")
public class InventorySystemPackage {
@JsonRootName("inventoryPackage")
public class KuraInventoryPackage {

@JsonProperty("name")
public String name;
Expand Down
Expand Up @@ -21,48 +21,48 @@
import java.util.List;

/**
* {@link InventorySystemPackages} definition.
* {@link KuraInventoryPackages} definition.
*
* @since 1.5.0
*/
@JsonRootName("inventorySystemPackages")
public class InventorySystemPackages {
@JsonRootName("inventoryPackages")
public class KuraInventoryPackages {

@JsonProperty("inventory")
public List<InventorySystemPackage> systemPackages;
public List<KuraInventoryPackage> inventoryPackages;

/**
* Gets the {@link InventorySystemPackage}s {@link List}.
* Gets the {@link KuraInventoryPackage}s {@link List}.
*
* @return The {@link InventorySystemPackage}s {@link List}.
* @return The {@link KuraInventoryPackage}s {@link List}.
* @since 1.5.0
*/
public List<InventorySystemPackage> getSystemPackages() {
if (systemPackages == null) {
systemPackages = new ArrayList<>();
public List<KuraInventoryPackage> getInventoryPackages() {
if (inventoryPackages == null) {
inventoryPackages = new ArrayList<>();
}

return systemPackages;
return inventoryPackages;
}

/**
* Adds a {@link InventorySystemPackage} to the {@link List}
* Adds a {@link KuraInventoryPackage} to the {@link List}
*
* @param kuraBundle The {@link InventorySystemPackage} to add.
* @param inventoryPackage The {@link KuraInventoryPackage} to add.
* @since 1.5.0
*/
public void addSystemPackage(@NotNull InventorySystemPackage kuraBundle) {
getSystemPackages().add(kuraBundle);
public void addInventoryPackage(@NotNull KuraInventoryPackage inventoryPackage) {
getInventoryPackages().add(inventoryPackage);
}

/**
* Sets the {@link InventorySystemPackage}s {@link List}.
* Sets the {@link KuraInventoryPackage}s {@link List}.
*
* @param systemPackages The {@link InventorySystemPackage}s {@link List}.
* @param inventoryPackages The {@link KuraInventoryPackage}s {@link List}.
* @since 1.5.0
*/
public void setSystemPackages(@Nullable List<InventorySystemPackage> systemPackages) {
this.systemPackages = systemPackages;
public void setInventoryPackages(@Nullable List<KuraInventoryPackage> inventoryPackages) {
this.inventoryPackages = inventoryPackages;
}

}
@@ -0,0 +1,117 @@
/*******************************************************************************
* Copyright (c) 2021 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.call.kura.model.inventory.bundles.inventory;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;

/**
* {@link KuraInventoryBundle} definition.
*
* @since 1.5.0
*/
@JsonRootName("systemPackage")
public class KuraInventoryBundle {

@JsonProperty("id")
public String id;

@JsonProperty("name")
public String name;

@JsonProperty("version")
public String version;

@JsonProperty("state")
public String state;

/**
* Gets the identifier.
*
* @return The identifier.
* @since 1.5.0
*/
public String getId() {
return id;
}

/**
* Sets the identifier.
*
* @param id The identifier.
* @since 1.5.0
*/
public void setId(String id) {
this.id = id;
}

/**
* Gets the name.
*
* @return The name.
* @since 1.5.0
*/
public String getName() {
return name;
}

/**
* Sets the name.
*
* @param name The name.
* @since 1.5.0
*/
public void setName(String name) {
this.name = name;
}

/**
* Gets the version.
*
* @return The version.
* @since 1.5.0
*/
public String getVersion() {
return version;
}

/**
* Gets the version.
*
* @param version The version.
* @since 1.5.0
*/
public void setVersion(String version) {
this.version = version;
}

/**
* Gets the state.
*
* @return The state.
* @since 1.5.0
*/
public String getState() {
return state;
}

/**
* Sets the state.
*
* @param state The state.
* @since 1.5.0
*/
public void setState(String state) {
this.state = state;
}
}

0 comments on commit a87127b

Please sign in to comment.