Skip to content

Commit

Permalink
💥 removed DevicePackageFactory, in favour of councrete DTOs
Browse files Browse the repository at this point in the history
Signed-off-by: dseurotech <davide.salvador@eurotech.com>
  • Loading branch information
dseurotech committed Feb 5, 2025
1 parent 1d4e55d commit b5ea7ed
Show file tree
Hide file tree
Showing 44 changed files with 696 additions and 1,773 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.eclipse.kapua.service.device.management.bundle.DeviceBundle;
import org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService;
import org.eclipse.kapua.service.device.management.bundle.DeviceBundles;
import org.eclipse.kapua.service.device.management.packages.DevicePackageFactory;
import org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService;
import org.eclipse.kapua.service.device.management.packages.model.DevicePackage;
import org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo;
Expand Down Expand Up @@ -334,7 +333,7 @@ public void downloadPackage(final String packageName, final String version, fina
With.withDevice(account, currentDevice.getClientId(), device -> {
final DevicePackageManagementService service = KapuaLocator.getInstance().getService(DevicePackageManagementService.class);

final DevicePackageDownloadRequest request = KapuaLocator.getInstance().getFactory(DevicePackageFactory.class).newPackageDownloadRequest();
final DevicePackageDownloadRequest request = new DevicePackageDownloadRequest();
request.setInstall(true);
request.setName(packageName);
request.setVersion(version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
*******************************************************************************/
package org.eclipse.kapua.app.api.resources.v1.resources;

import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.app.api.core.model.EntityId;
import org.eclipse.kapua.app.api.core.model.ScopeId;
Expand All @@ -21,7 +32,6 @@
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.KapuaService;
import org.eclipse.kapua.service.device.management.packages.DevicePackageFactory;
import org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService;
import org.eclipse.kapua.service.device.management.packages.model.DevicePackages;
import org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadOptions;
Expand All @@ -32,41 +42,33 @@
import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationRegistryService;
import org.eclipse.kapua.service.device.registry.Device;

import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("{scopeId}/devices/{deviceId}/packages")
public class DeviceManagementPackages extends AbstractKapuaResource {

private final Boolean responseLegacyMode = KapuaLocator.getInstance().getComponent(KapuaApiCoreSetting.class).getBoolean(KapuaApiCoreSettingKeys.API_DEVICE_MANAGEMENT_PACKAGE_RESPONSE_LEGACY_MODE, false);
private final Boolean responseLegacyMode = KapuaLocator.getInstance().getComponent(KapuaApiCoreSetting.class)
.getBoolean(KapuaApiCoreSettingKeys.API_DEVICE_MANAGEMENT_PACKAGE_RESPONSE_LEGACY_MODE, false);

@Inject
public DevicePackageManagementService devicePackageManagementService;
@Inject
public DevicePackageFactory devicePackageFactory;
@Inject
public DeviceManagementOperationRegistryService deviceManagementOperationRegistryService;

/**
* Returns the list of all the packages installed on the device.
*
* @param scopeId The {@link ScopeId} in which to search results.
* @param deviceId The id of the device
* @param timeout The timeout of the operation
* @param scopeId
* The {@link ScopeId} in which to search results.
* @param deviceId
* The id of the device
* @param timeout
* The timeout of the operation
* @return The list of packages installed.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @throws KapuaException
* Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.0.0
*/
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DevicePackages get(
@PathParam("scopeId") ScopeId scopeId,
@PathParam("deviceId") EntityId deviceId,
Expand All @@ -77,25 +79,30 @@ public DevicePackages get(
/**
* Download and optionally installs a package into the device.
*
* @param scopeId The {@link ScopeId} in which to search results.
* @param deviceId The {@link Device} ID.
* @param timeout The timeout of the operation
* @param packageDownloadRequest Mandatory object with all the informations needed to download and install a package
* @param scopeId
* The {@link ScopeId} in which to search results.
* @param deviceId
* The {@link Device} ID.
* @param timeout
* The timeout of the operation
* @param packageDownloadRequest
* Mandatory object with all the informations needed to download and install a package
* @return HTTP 200 if operation has completed successfully.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @throws KapuaException
* Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.0.0
*/
@POST
@Path("_download")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response download(
@PathParam("scopeId") ScopeId scopeId,
@PathParam("deviceId") EntityId deviceId,
@QueryParam("timeout") @DefaultValue("30000") Long timeout,
@QueryParam("legacy") @DefaultValue("false") boolean legacy,
DevicePackageDownloadRequest packageDownloadRequest)
throws KapuaException {
DevicePackageDownloadOptions options = devicePackageFactory.newPackageDownloadOptions();
DevicePackageDownloadOptions options = new DevicePackageDownloadOptions();
options.setTimeout(timeout);

KapuaId deviceManagementOperationId = devicePackageManagementService.downloadExec(scopeId, deviceId, packageDownloadRequest, options);
Expand All @@ -108,24 +115,29 @@ public Response download(
/**
* Uninstalls a package into the device.
*
* @param scopeId The {@link ScopeId} in which to search results.
* @param deviceId The {@link Device} ID.
* @param timeout The timeout of the operation
* @param packageUninstallRequest Mandatory object with all the informations needed to uninstall a package
* @param scopeId
* The {@link ScopeId} in which to search results.
* @param deviceId
* The {@link Device} ID.
* @param timeout
* The timeout of the operation
* @param packageUninstallRequest
* Mandatory object with all the informations needed to uninstall a package
* @return HTTP 200 if operation has completed successfully.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @throws KapuaException
* Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.0.0
*/
@POST
@Path("_uninstall")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response uninstall(
@PathParam("scopeId") ScopeId scopeId,
@PathParam("deviceId") EntityId deviceId,
@QueryParam("timeout") @DefaultValue("30000") Long timeout,
@QueryParam("legacy") @DefaultValue("false") boolean legacy,
DevicePackageUninstallRequest packageUninstallRequest) throws KapuaException {
DevicePackageUninstallOptions options = devicePackageFactory.newPackageUninstallOptions();
DevicePackageUninstallOptions options = new DevicePackageUninstallOptions();
options.setTimeout(timeout);

KapuaId deviceManagementOperationId = devicePackageManagementService.uninstallExec(scopeId, deviceId, packageUninstallRequest, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
package org.eclipse.kapua.model.domain;

import org.eclipse.kapua.model.KapuaEntityCreator;
import org.eclipse.kapua.model.KapuaUpdatableEntity;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.query.KapuaQuery;
import org.eclipse.kapua.service.KapuaEntityService;
import org.eclipse.kapua.service.KapuaNamedEntityService;
import org.eclipse.kapua.service.KapuaUpdatableEntityService;

/**
* {@link Actions} implementation {@code enum}.<br>
* Available actions defined are:
* {@link Actions} implementation {@code enum}.<br> Available actions defined are:
* <ul>
* <li>{@link Actions#read}: Represent any type of fetching data from the system.</li>
* <li>{@link Actions#write}: Represent any type of writing data into the system.</li>
Expand All @@ -35,8 +33,7 @@
*/
public enum Actions {
/**
* Represent any type of fetching data from the system. <br>
* Common usage is on:
* Represent any type of fetching data from the system. <br> Common usage is on:
* <ul>
* <li>{@link KapuaEntityService#find(KapuaId, KapuaId)}</li>
* <li>{@link KapuaEntityService#query(KapuaQuery)}</li>
Expand All @@ -49,20 +46,18 @@ public enum Actions {
read,

/**
* Represent any type of writing data into the system.
* Common usage is on:
* Represent any type of writing data into the system. Common usage is on:
* <ul>
* <li>{@link KapuaEntityService#create(KapuaEntityCreator)}</li>
* <li>{@link KapuaUpdatableEntityService#update(KapuaUpdatableEntity)}</li>
* <li>{@link KapuaUpdatableEntityService#update(Object)}</li>
* </ul>
*
* @since 1.0.0
*/
write,

/**
* Represent any type of deleting data from the system. <br>
* Common usage is on:
* Represent any type of deleting data from the system. <br> Common usage is on:
* <ul>
* <li>{@link KapuaEntityService#delete(KapuaId, KapuaId)}</li>
* </ul>
Expand All @@ -72,8 +67,7 @@ public enum Actions {
delete,

/**
* Represent any type of connect to resources of the system.<br>
* Examples are:
* Represent any type of connect to resources of the system.<br> Examples are:
* <ul>
* <li>Connecting to the message broker.</li>
* </ul>
Expand Down

This file was deleted.

Loading

0 comments on commit b5ea7ed

Please sign in to comment.