Refactoring/Improving source: dmf 2 (#1612)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-04 11:46:43 +02:00
committed by GitHub
parent da3a6470ec
commit c320a45b55
30 changed files with 135 additions and 505 deletions

View File

@@ -9,20 +9,15 @@
*/ */
package org.eclipse.hawkbit.dmf.amqp.api; package org.eclipse.hawkbit.dmf.amqp.api;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/** /**
* Global constants for RabbitMQ settings. * Global constants for RabbitMQ settings.
*
*
*
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AmqpSettings { public final class AmqpSettings {
public static final String DMF_EXCHANGE = "dmf.exchange"; public static final String DMF_EXCHANGE = "dmf.exchange";
public static final String AUTHENTICATION_EXCHANGE = "authentication.exchange"; public static final String AUTHENTICATION_EXCHANGE = "authentication.exchange";
private AmqpSettings() {
}
} }

View File

@@ -18,52 +18,42 @@ public enum EventTopic {
* Topic when sending and receiving a update status. * Topic when sending and receiving a update status.
*/ */
UPDATE_ACTION_STATUS, UPDATE_ACTION_STATUS,
/** /**
* Topic when sending and receiving a download and install task. * Topic when sending and receiving a download and install task.
*/ */
DOWNLOAD_AND_INSTALL, DOWNLOAD_AND_INSTALL,
/** /**
* Topic when sending and receiving a cancel download task. * Topic when sending and receiving a cancel download task.
*/ */
CANCEL_DOWNLOAD, CANCEL_DOWNLOAD,
/** /**
* Topic when updating device attributes. * Topic when updating device attributes.
*/ */
UPDATE_ATTRIBUTES, UPDATE_ATTRIBUTES,
/** /**
* Topic when updating auto-confirmation state. * Topic when updating auto-confirmation state.
*/ */
UPDATE_AUTO_CONFIRM, UPDATE_AUTO_CONFIRM,
/** /**
* Topic when sending a download only task, skipping the install. * Topic when sending a download only task, skipping the install.
*/ */
DOWNLOAD, DOWNLOAD,
/** /**
* Topic when an update of device attributes is requested. * Topic when an update of device attributes is requested.
*/ */
REQUEST_ATTRIBUTES_UPDATE, REQUEST_ATTRIBUTES_UPDATE,
/** /**
* Topic to send multiple actions to the device. * Topic to send multiple actions to the device.
*/ */
MULTI_ACTION, MULTI_ACTION,
/** /**
* Topic when sending a download only action to multiple devices. * Topic when sending a download only action to multiple devices.
*/ */
BATCH_DOWNLOAD, BATCH_DOWNLOAD,
/** /**
* Topic when sending a download and install action to multiple devices. * Topic when sending a download and install action to multiple devices.
*/ */
BATCH_DOWNLOAD_AND_INSTALL, BATCH_DOWNLOAD_AND_INSTALL,
/** /**
* Topic when confirmation of an action is requested. * Topic when confirmation of an action is requested.
*/ */

View File

@@ -9,46 +9,37 @@
*/ */
package org.eclipse.hawkbit.dmf.amqp.api; package org.eclipse.hawkbit.dmf.amqp.api;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/** /**
* The constant of all amqp message header. * The constant of all amqp message header.
*
*
*
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class MessageHeaderKey { public final class MessageHeaderKey {
/** /**
* The message type. * The message type.
*/ */
public static final String TYPE = "type"; public static final String TYPE = "type";
/** /**
* The used tenant. * The used tenant.
*/ */
public static final String TENANT = "tenant"; public static final String TENANT = "tenant";
/** /**
* The name of the thing/target. * The name of the thing/target.
*/ */
public static final String THING_ID = "thingId"; public static final String THING_ID = "thingId";
/** /**
* The name of the sender who has send the message. * The name of the sender who has send the message.
*/ */
public static final String SENDER = "sender"; public static final String SENDER = "sender";
/** /**
* The topic to handle events different. * The topic to handle events different.
*/ */
public static final String TOPIC = "topic"; public static final String TOPIC = "topic";
/** /**
* The content type. * The content type.
*/ */
public static final String CONTENT_TYPE = "content-type"; public static final String CONTENT_TYPE = "content-type";
private MessageHeaderKey() {
}
} }

View File

@@ -19,30 +19,24 @@ public enum MessageType {
* The event type related to interaction with a thing. * The event type related to interaction with a thing.
*/ */
EVENT, EVENT,
/** /**
* The thing created type. * The thing created type.
*/ */
THING_CREATED, THING_CREATED,
/** /**
* The thing deleted type. * The thing deleted type.
*/ */
THING_DELETED, THING_DELETED,
/** /**
* The request to delete a target. * The request to delete a target.
*/ */
THING_REMOVED, THING_REMOVED,
/** /**
* DMF receiver health check type. * DMF receiver health check type.
*/ */
PING, PING,
/** /**
* DMF receiver health check response type. * DMF receiver health check response type.
*/ */
PING_RESPONSE PING_RESPONSE
} }

View File

@@ -13,22 +13,16 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of an action related request. * JSON representation of an action related request.
*
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfActionRequest { public class DmfActionRequest {
@JsonProperty @JsonProperty
private Long actionId; private Long actionId;
public Long getActionId() {
return actionId;
}
public void setActionId(final Long correlator) {
this.actionId = correlator;
}
} }

View File

@@ -15,63 +15,51 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
/** /**
* The json message action status. * The json message action status.
*
*
*
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public enum DmfActionStatus { public enum DmfActionStatus {
/** /**
* Action requests download by this target which has now started. * Action requests download by this target which has now started.
*/ */
DOWNLOAD, DOWNLOAD,
/** /**
* Action has been send to the target. * Action has been send to the target.
*/ */
RETRIEVED, RETRIEVED,
/** /**
* Action is still running for this target. * Action is still running for this target.
*/ */
RUNNING, RUNNING,
/** /**
* Action is finished successfully for this target. * Action is finished successfully for this target.
*/ */
FINISHED, FINISHED,
/** /**
* Action has failed for this target. * Action has failed for this target.
*/ */
ERROR, ERROR,
/** /**
* Action is still running but with warnings. * Action is still running but with warnings.
*/ */
WARNING, WARNING,
/** /**
* Action has been canceled for this target. * Action has been canceled for this target.
*/ */
CANCELED, CANCELED,
/** /**
* Cancellation has been rejected by the target.. * Cancellation has been rejected by the target..
*/ */
CANCEL_REJECTED, CANCEL_REJECTED,
/** /**
* Action has been downloaded for this target. * Action has been downloaded for this target.
*/ */
DOWNLOADED, DOWNLOADED,
/** /**
* Action is confirmed by the target. * Action is confirmed by the target.
*/ */
CONFIRMED, CONFIRMED,
/** /**
* Action has been denied by the target. * Action has been denied by the target.
*/ */

View File

@@ -20,10 +20,14 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Setter;
/** /**
* JSON representation of action update status. * JSON representation of action update status.
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfActionUpdateStatus { public class DmfActionUpdateStatus {
@@ -34,6 +38,7 @@ public class DmfActionUpdateStatus {
@JsonProperty @JsonProperty
private Long softwareModuleId; private Long softwareModuleId;
@Setter(AccessLevel.NONE)
@JsonProperty @JsonProperty
private List<String> message; private List<String> message;
@@ -46,31 +51,11 @@ public class DmfActionUpdateStatus {
this.actionStatus = actionStatus; this.actionStatus = actionStatus;
} }
public Long getActionId() {
return actionId;
}
public Long getSoftwareModuleId() {
return softwareModuleId;
}
public void setSoftwareModuleId(final Long softwareModuleId) {
this.softwareModuleId = softwareModuleId;
}
public DmfActionStatus getActionStatus() {
return actionStatus;
}
@JsonIgnore @JsonIgnore
public Optional<Integer> getCode() { public Optional<Integer> getCode() {
return Optional.ofNullable(code); return Optional.ofNullable(code);
} }
public void setCode(final Integer code) {
this.code = code;
}
public List<String> getMessage() { public List<String> getMessage() {
if (message == null) { if (message == null) {
return Collections.emptyList(); return Collections.emptyList();
@@ -99,9 +84,4 @@ public class DmfActionUpdateStatus {
return message.addAll(messages); return message.addAll(messages);
} }
public void setCode(final int code) {
this.code = code;
}
} }

View File

@@ -16,25 +16,24 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of artifact. * JSON representation of artifact.
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfArtifact { public class DmfArtifact {
@JsonProperty @JsonProperty
private String filename; private String filename;
@JsonProperty @JsonProperty
private DmfArtifactHash hashes; private DmfArtifactHash hashes;
@JsonProperty @JsonProperty
private long size; private long size;
@JsonProperty @JsonProperty
private long lastModified; private long lastModified;
@JsonProperty @JsonProperty
private Map<String, String> urls; private Map<String, String> urls;
@@ -45,41 +44,4 @@ public class DmfArtifact {
return Collections.unmodifiableMap(urls); return Collections.unmodifiableMap(urls);
} }
public long getLastModified() {
return lastModified;
}
public void setLastModified(final long lastModified) {
this.lastModified = lastModified;
}
public void setUrls(final Map<String, String> urls) {
this.urls = urls;
}
public String getFilename() {
return filename;
}
public void setFilename(final String filename) {
this.filename = filename;
}
public DmfArtifactHash getHashes() {
return hashes;
}
public void setHashes(final DmfArtifactHash hashes) {
this.hashes = hashes;
}
public long getSize() {
return size;
}
public void setSize(final long size) {
this.size = size;
}
} }

View File

@@ -11,46 +11,28 @@ package org.eclipse.hawkbit.dmf.json.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of artifact hash. * JSON representation of artifact hash.
*/ */
@Data
public class DmfArtifactHash { public class DmfArtifactHash {
@JsonProperty @JsonProperty
private String sha1; private String sha1;
@JsonProperty @JsonProperty
private String md5; private String md5;
/** /**
* Constructor. * Constructor.
* *
* @param sha1 * @param sha1 the sha1 hash
* the sha1 hash * @param md5 the md5 hash
* @param md5
* the md5 hash
*/ */
@JsonCreator @JsonCreator
public DmfArtifactHash(@JsonProperty("sha1") final String sha1, @JsonProperty("md5") final String md5) { public DmfArtifactHash(@JsonProperty("sha1") final String sha1, @JsonProperty("md5") final String md5) {
this.sha1 = sha1; this.sha1 = sha1;
this.md5 = md5; this.md5 = md5;
} }
public void setSha1(final String sha1) {
this.sha1 = sha1;
}
public void setMd5(final String md5) {
this.md5 = md5;
}
public String getSha1() {
return sha1;
}
public String getMd5() {
return md5;
}
} }

View File

@@ -16,10 +16,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of the Attribute Update message. * JSON representation of the Attribute Update message.
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfAttributeUpdate { public class DmfAttributeUpdate {
@@ -29,17 +31,4 @@ public class DmfAttributeUpdate {
@JsonProperty @JsonProperty
private DmfUpdateMode mode; private DmfUpdateMode mode;
public DmfUpdateMode getMode() {
return mode;
}
public void setMode(final DmfUpdateMode mode) {
this.mode = mode;
}
public Map<String, String> getAttributes() {
return attributes;
}
} }

View File

@@ -13,46 +13,20 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of auto confirmation config. * JSON representation of auto confirmation config.
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfAutoConfirmation { public class DmfAutoConfirmation {
@JsonProperty @JsonProperty
private boolean enabled; private boolean enabled;
@JsonProperty @JsonProperty
private String initiator; private String initiator;
@JsonProperty @JsonProperty
private String remark; private String remark;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
public String getInitiator() {
return initiator;
}
public void setInitiator(final String initiator) {
this.initiator = initiator;
}
public String getRemark() {
return remark;
}
public void setRemark(final String remark) {
this.remark = remark;
}
} }

View File

@@ -13,6 +13,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -26,6 +28,7 @@ import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfBatchDownloadAndUpdateRequest { public class DmfBatchDownloadAndUpdateRequest {
@Getter @Setter
@JsonProperty @JsonProperty
private Long timestamp; private Long timestamp;
@@ -35,14 +38,6 @@ public class DmfBatchDownloadAndUpdateRequest {
@JsonProperty @JsonProperty
private List<DmfSoftwareModule> softwareModules; private List<DmfSoftwareModule> softwareModules;
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(final Long timestamp) {
this.timestamp = timestamp;
}
public List<DmfSoftwareModule> getSoftwareModules() { public List<DmfSoftwareModule> getSoftwareModules() {
if (softwareModules == null) { if (softwareModules == null) {
return Collections.emptyList(); return Collections.emptyList();
@@ -54,8 +49,7 @@ public class DmfBatchDownloadAndUpdateRequest {
/** /**
* Add a Software module. * Add a Software module.
* *
* @param createSoftwareModule * @param createSoftwareModule the module
* the module
*/ */
public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) { public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) {
if (softwareModules == null) { if (softwareModules == null) {
@@ -73,7 +67,6 @@ public class DmfBatchDownloadAndUpdateRequest {
return Collections.unmodifiableList(targets); return Collections.unmodifiableList(targets);
} }
/** /**
* Add a Target. * Add a Target.
* *
@@ -91,8 +84,7 @@ public class DmfBatchDownloadAndUpdateRequest {
/** /**
* Add multiple Targets. * Add multiple Targets.
* *
* @param targets * @param targets the target
* the target
*/ */
public void addTargets(final List<DmfTarget> targets) { public void addTargets(final List<DmfTarget> targets) {
if (this.targets == null) { if (this.targets == null) {

View File

@@ -13,6 +13,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -20,26 +22,18 @@ import java.util.List;
/** /**
* JSON representation of confirm request. * JSON representation of confirm request.
*
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfConfirmRequest extends DmfActionRequest { public class DmfConfirmRequest extends DmfActionRequest {
@Getter @Setter
@JsonProperty @JsonProperty
private String targetSecurityToken; private String targetSecurityToken;
@JsonProperty @JsonProperty
private List<DmfSoftwareModule> softwareModules; private List<DmfSoftwareModule> softwareModules;
public String getTargetSecurityToken() {
return targetSecurityToken;
}
public void setTargetSecurityToken(final String targetSecurityToken) {
this.targetSecurityToken = targetSecurityToken;
}
public List<DmfSoftwareModule> getSoftwareModules() { public List<DmfSoftwareModule> getSoftwareModules() {
if (softwareModules == null) { if (softwareModules == null) {
return Collections.emptyList(); return Collections.emptyList();

View File

@@ -13,10 +13,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of the Attribute THING_CREATED message. * JSON representation of the Attribute THING_CREATED message.
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfCreateThing { public class DmfCreateThing {
@@ -29,28 +31,4 @@ public class DmfCreateThing {
@JsonProperty @JsonProperty
private DmfAttributeUpdate attributeUpdate; private DmfAttributeUpdate attributeUpdate;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(final String type) {
this.type = type;
}
public DmfAttributeUpdate getAttributeUpdate() {
return attributeUpdate;
}
public void setAttributeUpdate(final DmfAttributeUpdate attributeUpdate) {
this.attributeUpdate = attributeUpdate;
}
} }

View File

@@ -17,25 +17,22 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
/** /**
* JSON representation of download and update request. * JSON representation of download and update request.
*
*/ */
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfDownloadAndUpdateRequest extends DmfActionRequest { public class DmfDownloadAndUpdateRequest extends DmfActionRequest {
@Getter
@JsonProperty @JsonProperty
private String targetSecurityToken; private String targetSecurityToken;
@JsonProperty @JsonProperty
private List<DmfSoftwareModule> softwareModules; private List<DmfSoftwareModule> softwareModules;
public String getTargetSecurityToken() {
return targetSecurityToken;
}
public void setTargetSecurityToken(final String targetSecurityToken) { public void setTargetSecurityToken(final String targetSecurityToken) {
this.targetSecurityToken = targetSecurityToken; this.targetSecurityToken = targetSecurityToken;
} }

View File

@@ -13,58 +13,22 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* The authentification response JSON representation. * The download response JSON representation.
*
*
*
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfDownloadResponse { public class DmfDownloadResponse {
@JsonProperty @JsonProperty
private String downloadUrl; private String downloadUrl;
@JsonProperty @JsonProperty
private DmfArtifact artifact; private DmfArtifact artifact;
@JsonProperty @JsonProperty
private int responseCode; private int responseCode;
@JsonProperty @JsonProperty
private String message; private String message;
public String getMessage() {
return message;
}
public void setMessage(final String message) {
this.message = message;
}
public int getResponseCode() {
return responseCode;
}
public void setResponseCode(final int responseCode) {
this.responseCode = responseCode;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(final String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public DmfArtifact getArtifact() {
return artifact;
}
public void setArtifact(final DmfArtifact artifact) {
this.artifact = artifact;
}
} }

View File

@@ -14,11 +14,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* Additional metadata to be provided for the target/device. * Additional metadata to be provided for the target/device.
*
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfMetadata { public class DmfMetadata {
@@ -33,55 +34,4 @@ public class DmfMetadata {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
public String getKey() {
return key;
}
public String getValue() {
return value;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((key == null) ? 0 : key.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DmfMetadata other = (DmfMetadata) obj;
if (key == null) {
if (other.key != null) {
return false;
}
} else if (!key.equals(other.key)) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
@Override
public String toString() {
return String.format("DmfMetadata [key='%s', value='%s']", key, value);
}
} }

View File

@@ -12,6 +12,8 @@ package org.eclipse.hawkbit.dmf.json.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
@@ -27,15 +29,13 @@ import com.fasterxml.jackson.annotation.JsonValue;
/** /**
* JSON representation of a multi-action request. * JSON representation of a multi-action request.
*/ */
@NoArgsConstructor
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfMultiActionRequest { public class DmfMultiActionRequest {
private List<DmfMultiActionElement> elements; private List<DmfMultiActionElement> elements;
public DmfMultiActionRequest() {
}
@JsonCreator @JsonCreator
public DmfMultiActionRequest(final List<DmfMultiActionElement> elements) { public DmfMultiActionRequest(final List<DmfMultiActionElement> elements) {
this.elements = elements; this.elements = elements;
@@ -64,6 +64,7 @@ public class DmfMultiActionRequest {
/** /**
* Represents an element within a {@link DmfMultiActionRequest}. * Represents an element within a {@link DmfMultiActionRequest}.
*/ */
@Data
public static class DmfMultiActionElement { public static class DmfMultiActionElement {
@JsonProperty @JsonProperty
@@ -75,32 +76,11 @@ public class DmfMultiActionRequest {
@JsonProperty @JsonProperty
private int weight; private int weight;
public DmfActionRequest getAction() {
return action;
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "topic", defaultImpl = DmfActionRequest.class) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "topic", defaultImpl = DmfActionRequest.class)
@JsonSubTypes({ @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD"), @JsonSubTypes({ @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD"),
@Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD_AND_INSTALL") }) @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD_AND_INSTALL") })
public void setAction(final DmfActionRequest action) { public void setAction(final DmfActionRequest action) {
this.action = action; this.action = action;
} }
public EventTopic getTopic() {
return topic;
} }
public void setTopic(final EventTopic actionType) {
this.topic = actionType;
}
public void setWeight(final int weight) {
this.weight = weight;
}
public int getWeight() {
return weight;
}
}
} }

View File

@@ -17,11 +17,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/** /**
* JSON representation of a software module. * JSON representation of a software module.
*
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfSoftwareModule { public class DmfSoftwareModule {
@@ -39,22 +40,6 @@ public class DmfSoftwareModule {
@JsonProperty @JsonProperty
private List<DmfMetadata> metadata; private List<DmfMetadata> metadata;
public String getModuleType() {
return moduleType;
}
public void setModuleType(final String moduleType) {
this.moduleType = moduleType;
}
public String getModuleVersion() {
return moduleVersion;
}
public void setModuleVersion(final String moduleVersion) {
this.moduleVersion = moduleVersion;
}
public List<DmfArtifact> getArtifacts() { public List<DmfArtifact> getArtifacts() {
if (artifacts == null) { if (artifacts == null) {
return Collections.emptyList(); return Collections.emptyList();
@@ -63,41 +48,9 @@ public class DmfSoftwareModule {
return Collections.unmodifiableList(artifacts); return Collections.unmodifiableList(artifacts);
} }
public Long getModuleId() {
return moduleId;
}
@JsonIgnore
public void setModuleId(final Long moduleId) {
this.moduleId = moduleId;
}
public void setArtifacts(final List<DmfArtifact> artifacts) {
this.artifacts = artifacts;
}
public List<DmfMetadata> getMetadata() {
return metadata;
}
public void setMetadata(final List<DmfMetadata> metadata) { public void setMetadata(final List<DmfMetadata> metadata) {
if (metadata != null && !metadata.isEmpty()) { if (metadata != null && !metadata.isEmpty()) {
this.metadata = metadata; this.metadata = metadata;
} }
} }
public Boolean getEncrypted() {
return encrypted;
}
public void setEncrypted(final Boolean encrypted) {
this.encrypted = encrypted;
}
@Override
public String toString() {
return String.format(
"DmfSoftwareModule [moduleId=%d, moduleType='%s', moduleVersion='%s', encrypted='%s' artifacts=%s, metadata=%s]",
moduleId, moduleType, moduleVersion, encrypted, artifacts, metadata);
}
} }

View File

@@ -13,53 +13,22 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.ToString;
/** /**
* Json representation of Target used in batch download and update request. * Json representation of Target used in batch download and update request.
*
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfTarget { public class DmfTarget {
@JsonProperty @JsonProperty
private Long actionId; private Long actionId;
@JsonProperty @JsonProperty
private String controllerId; private String controllerId;
@ToString.Exclude
@JsonProperty @JsonProperty
private String targetSecurityToken; private String targetSecurityToken;
public Long getActionId() {
return actionId;
}
public void setActionId(final Long actionId) {
this.actionId = actionId;
}
public String getControllerId() {
return controllerId;
}
public void setControllerId(final String controllerId) {
this.controllerId = controllerId;
}
public String getTargetSecurityToken() {
return targetSecurityToken;
}
public void setTargetSecurityToken(final String targetSecurityToken) {
this.targetSecurityToken = targetSecurityToken;
}
@Override
public String toString() {
return String.format(
"DmfTarget [actionId=%d controllerId='%s']",
actionId, controllerId);
}
} }

View File

@@ -21,15 +21,12 @@ public enum DmfUpdateMode {
* Merge update strategy * Merge update strategy
*/ */
MERGE, MERGE,
/** /**
* Replacement update strategy * Replacement update strategy
*/ */
REPLACE, REPLACE,
/** /**
* Removal update strategy * Removal update strategy
*/ */
REMOVE REMOVE
} }

View File

@@ -14,6 +14,7 @@ import jakarta.validation.constraints.Min;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -25,6 +26,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
*/ */
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode
@ToString
public class AutoAssignDistributionSetUpdate { public class AutoAssignDistributionSetUpdate {
private final long targetFilterId; private final long targetFilterId;

View File

@@ -9,19 +9,26 @@
*/ */
package org.eclipse.hawkbit.repository.event.remote; package org.eclipse.hawkbit.repository.event.remote;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import java.io.Serial;
import java.util.Arrays; import java.util.Arrays;
/** /**
* An base definition class for an event which contains an id. * An base definition class for an event which contains an id.
*/ */
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class RemoteIdEvent extends RemoteTenantAwareEvent { public class RemoteIdEvent extends RemoteTenantAwareEvent {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long entityId; private Long entityId;
@@ -30,13 +37,6 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent {
private String interfaceClass; private String interfaceClass;
/**
* Default constructor.
*/
protected RemoteIdEvent() {
// for serialization libs like jackson
}
/** /**
* Constructor for json serialization. * Constructor for json serialization.
* *

View File

@@ -11,20 +11,25 @@ package org.eclipse.hawkbit.repository.event.remote;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
import org.eclipse.hawkbit.repository.event.TenantAwareEvent; import org.eclipse.hawkbit.repository.event.TenantAwareEvent;
import org.springframework.cloud.bus.event.RemoteApplicationEvent; import org.springframework.cloud.bus.event.RemoteApplicationEvent;
import com.cronutils.utils.StringUtils; import com.cronutils.utils.StringUtils;
import java.io.Serial;
/** /**
* A distributed tenant aware event. It's the base class of the other * A distributed tenant aware event. It's the base class of the other
* distributed events. All the necessary information of distributing events to * distributed events. All the necessary information of distributing events to
* other nodes. * other nodes.
*/ */
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements TenantAwareEvent { public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements TenantAwareEvent {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String tenant; private String tenant;

View File

@@ -9,35 +9,32 @@
*/ */
package org.eclipse.hawkbit.repository.event.remote; package org.eclipse.hawkbit.repository.event.remote;
import java.io.Serial;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
/** /**
* TenantAwareEvent that gets sent when a distribution set gets assigned to a * TenantAwareEvent that gets sent when a distribution set gets assigned to a target.
* target.
*/ */
@NoArgsConstructor // for serialization libs like jackson
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class TargetAssignDistributionSetEvent extends AbstractAssignmentEvent { public class TargetAssignDistributionSetEvent extends AbstractAssignmentEvent {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private long distributionSetId; private long distributionSetId;
private boolean maintenanceWindowAvailable; private boolean maintenanceWindowAvailable;
/**
* Default constructor.
*/
public TargetAssignDistributionSetEvent() {
// for serialization libs like jackson
}
/** /**
* Constructor. * Constructor.
* *

View File

@@ -11,16 +11,23 @@ package org.eclipse.hawkbit.repository.event.remote;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import java.io.Serial;
/** /**
* Defines the remote event of triggering attribute updates of a {@link Target}. * Defines the remote event of triggering attribute updates of a {@link Target}.
*/ */
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class TargetAttributesRequestedEvent extends RemoteIdEvent { public class TargetAttributesRequestedEvent extends RemoteIdEvent {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String controllerId; private String controllerId;
private String targetAddress; private String targetAddress;

View File

@@ -11,18 +11,24 @@ package org.eclipse.hawkbit.repository.event.remote;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import java.io.Serial;
/** /**
* Defines the remote event of deleting a {@link Target}. * Defines the remote event of deleting a {@link Target}.
*/ */
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class TargetDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent { public class TargetDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
@Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
private String controllerId; private String controllerId;
private String targetAddress; private String targetAddress;

View File

@@ -11,16 +11,22 @@ package org.eclipse.hawkbit.repository.event.remote;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import java.io.Serial;
/** /**
* Event is send in case a target polls either through DDI or DMF. * Event is send in case a target polls either through DDI or DMF.
*/ */
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class TargetPollEvent extends RemoteTenantAwareEvent { public class TargetPollEvent extends RemoteTenantAwareEvent {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String controllerId; private String controllerId;
private String targetAdress; private String targetAdress;

View File

@@ -11,17 +11,23 @@ package org.eclipse.hawkbit.repository.event.remote;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import java.io.Serial;
/** /**
* Defines the remote event of deleting a {@link org.eclipse.hawkbit.repository.model.TenantConfiguration}. * Defines the remote event of deleting a {@link org.eclipse.hawkbit.repository.model.TenantConfiguration}.
*/ */
@NoArgsConstructor // for serialization libs like jackson
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode(callSuper = true)
@ToString
public class TenantConfigurationDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent { public class TenantConfigurationDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
@Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
private String configKey; private String configKey;
@@ -29,26 +35,12 @@ public class TenantConfigurationDeletedEvent extends RemoteIdEvent implements En
private String configValue; private String configValue;
/** /**
* Default constructor. * @param tenant the tenant
*/ * @param entityId the entity id
public TenantConfigurationDeletedEvent() { * @param configKey the config key
// for serialization libs like jackson * @param configValue the config value
} * @param entityClass the entity class
* @param applicationId the origin application id
/**
*
* @param tenant
* the tenant
* @param entityId
* the entity id
* @param configKey
* the config key
* @param configValue
* the config value
* @param entityClass
* the entity class
* @param applicationId
* the origin application id
*/ */
public TenantConfigurationDeletedEvent(final String tenant, final Long entityId, final String configKey, public TenantConfigurationDeletedEvent(final String tenant, final Long entityId, final String configKey,
final String configValue, final Class<? extends TenantAwareBaseEntity> entityClass, final String configValue, final Class<? extends TenantAwareBaseEntity> entityClass,

View File

@@ -18,6 +18,7 @@ import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent;
@@ -78,13 +79,14 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpd
@NoArgsConstructor(access = AccessLevel.PUBLIC) @NoArgsConstructor(access = AccessLevel.PUBLIC)
@Getter @Getter
@EqualsAndHashCode @EqualsAndHashCode
@ToString
public class EventType { public class EventType {
private static final Map<Integer, Class<?>> TYPES = new HashMap<>(); private static final Map<Integer, Class<?>> TYPES = new HashMap<>();
/** /**
* The associated event-type-value must remain the same as initially * The associated event-type-value must remain the same as initially
* declared. Otherwise messages cannot correctly de-serialized. * declared. Otherwise, messages cannot correctly de-serialized.
*/ */
static { static {
// target // target