Remove unnecessary JsonProperty annotations (#2296)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-02-25 08:40:14 +02:00
committed by GitHub
parent 009e4a73ef
commit beda747c67
105 changed files with 531 additions and 906 deletions

View File

@@ -71,5 +71,4 @@ public class DdiActionFeedback {
public DdiActionFeedback(final DdiStatus status) { public DdiActionFeedback(final DdiStatus status) {
this(status, null); this(status, null);
} }
} }

View File

@@ -16,8 +16,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.Data;
import lombok.ToString;
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
/** /**
@@ -30,31 +29,28 @@ import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
* </ol> * </ol>
* that were sent to server earlier by the controller using {@link DdiActionFeedback}. * that were sent to server earlier by the controller using {@link DdiActionFeedback}.
*/ */
@EqualsAndHashCode @Data
@ToString
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@JsonPropertyOrder({ "status", "messages" }) @JsonPropertyOrder({ "status", "messages" })
public class DdiActionHistory { public class DdiActionHistory {
@JsonProperty("status")
@Schema(description = "Status of the deployment based on previous feedback by the device", example = "RUNNING") @Schema(description = "Status of the deployment based on previous feedback by the device", example = "RUNNING")
private final String actionStatus; private final String status;
@JsonProperty("messages")
@Schema(description = "Messages are previously sent to the feedback channel in LIFO order by the device. Note: The first status message is set by the system and describes the trigger of the deployment") @Schema(description = "Messages are previously sent to the feedback channel in LIFO order by the device. Note: The first status message is set by the system and describes the trigger of the deployment")
private final List<String> messages; private final List<String> messages;
/** /**
* Parameterized constructor for creating {@link DdiActionHistory}. * Parameterized constructor for creating {@link DdiActionHistory}.
* *
* @param actionStatus is the current action status at the server * @param status is the current action status at the server
* @param messages is a list of messages retrieved from action history. * @param messages is a list of messages retrieved from action history.
*/ */
@JsonCreator @JsonCreator
public DdiActionHistory( public DdiActionHistory(
@JsonProperty("status") final String actionStatus, @JsonProperty("status") final String status,
@JsonProperty("messages") List<String> messages) { @JsonProperty("messages") final List<String> messages) {
this.actionStatus = actionStatus; this.status = status;
this.messages = messages; this.messages = messages;
} }
} }

View File

@@ -19,12 +19,10 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DdiActivateAutoConfirmation { public class DdiActivateAutoConfirmation {
@JsonProperty
@Schema(description = "Individual value (e.g. username) stored as initiator and automatically used as confirmed" + @Schema(description = "Individual value (e.g. username) stored as initiator and automatically used as confirmed" +
" user in future actions", example = "exampleUser") " user in future actions", example = "exampleUser")
private final String initiator; private final String initiator;
@JsonProperty
@Schema(description = "Individual value to attach a remark which will be persisted when automatically " + @Schema(description = "Individual value to attach a remark which will be persisted when automatically " +
"confirming future actions", example = "exampleRemark") "confirming future actions", example = "exampleRemark")
private final String remark; private final String remark;

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ddi.json.model;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@@ -59,15 +60,22 @@ import org.springframework.hateoas.RepresentationModel;
public class DdiArtifact extends RepresentationModel<DdiArtifact> { public class DdiArtifact extends RepresentationModel<DdiArtifact> {
@NotNull @NotNull
@JsonProperty
@Schema(description = "File name", example = "binary.tgz") @Schema(description = "File name", example = "binary.tgz")
private String filename; private final String filename;
@JsonProperty
@Schema(description = "Artifact hashes") @Schema(description = "Artifact hashes")
private DdiArtifactHash hashes; private final DdiArtifactHash hashes;
@JsonProperty
@Schema(description = "Artifact size", example = "3") @Schema(description = "Artifact size", example = "3")
private Long size; private final Long size;
@JsonCreator
public DdiArtifact(
@JsonProperty("filename") final String filename,
@JsonProperty("hashes") final DdiArtifactHash hashes,
@JsonProperty("size") final Long size) {
this.filename = filename;
this.hashes = hashes;
this.size = size;
}
} }

View File

@@ -9,38 +9,30 @@
*/ */
package org.eclipse.hawkbit.ddi.json.model; package org.eclipse.hawkbit.ddi.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/** /**
* Hashes for given Artifact * Hashes for given Artifact
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode
@ToString
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DdiArtifactHash { public class DdiArtifactHash {
@JsonProperty
@Schema(description = "SHA1 hash of the artifact in Base 16 format", example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05") @Schema(description = "SHA1 hash of the artifact in Base 16 format", example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05")
private String sha1; private final String sha1;
@JsonProperty
@Schema(description = "MD5 hash of the artifact", example = "0d1b08c34858921bc7c662b228acb7ba") @Schema(description = "MD5 hash of the artifact", example = "0d1b08c34858921bc7c662b228acb7ba")
private String md5; private final String md5;
@JsonProperty
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@Schema(description = "SHA-256 hash of the artifact in Base 16 format", example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615") @Schema(description = "SHA-256 hash of the artifact in Base 16 format", example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615")
private String sha256; private final String sha256;
/** /**
* Public constructor. * Public constructor.
@@ -49,7 +41,11 @@ public class DdiArtifactHash {
* @param md5 md5 hash of the artifact * @param md5 md5 hash of the artifact
* @param sha256 sha256 hash of the artifact * @param sha256 sha256 hash of the artifact
*/ */
public DdiArtifactHash(final String sha1, final String md5, final String sha256) { @JsonCreator
public DdiArtifactHash(
@JsonProperty("sha1") final String sha1,
@JsonProperty("md5") final String md5,
@JsonProperty ("sha256") final String sha256) {
this.sha1 = sha1; this.sha1 = sha1;
this.md5 = md5; this.md5 = md5;
this.sha256 = sha256; this.sha256 = sha256;

View File

@@ -14,6 +14,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.Getter;
/** /**
* Allow a target to declare running distribution set version * Allow a target to declare running distribution set version
@@ -41,9 +42,4 @@ public class DdiAssignedVersion {
this.name = name; this.name = name;
this.version = version; this.version = version;
} }
@Override
public String toString() {
return "DdiInstalledVersion{" + "name='" + name + '\'' + ", version='" + version + '\'' + '}';
}
} }

View File

@@ -11,17 +11,17 @@ package org.eclipse.hawkbit.ddi.json.model;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
@NoArgsConstructor // needed for json create
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@@ -32,25 +32,26 @@ public class DdiAutoConfirmationState extends RepresentationModel<DdiAutoConfirm
@NotNull @NotNull
@Schema(example = "true") @Schema(example = "true")
private boolean active; private final boolean active;
@Schema(example = "exampleUserId") @Schema(example = "exampleUserId")
private String initiator; private final String initiator;
@Schema(example = "exampleRemark") @Schema(example = "exampleRemark")
private String remark; private final String remark;
@Schema(example = "1691065895439") @Schema(example = "1691065895439")
private Long activatedAt; private final Long activatedAt;
public static DdiAutoConfirmationState active(final long activatedAt) { @JsonCreator
final DdiAutoConfirmationState state = new DdiAutoConfirmationState(); public DdiAutoConfirmationState(
state.setActive(true); @JsonProperty("active") final boolean active,
state.setActivatedAt(activatedAt); @JsonProperty("initiator") final String initiator,
return state; @JsonProperty("remark") final String remark,
} @JsonProperty("activatedAt") final Long activatedAt) {
this.active = active;
public static DdiAutoConfirmationState disabled() { this.initiator = initiator;
return new DdiAutoConfirmationState(); this.remark = remark;
this.activatedAt = activatedAt;
} }
} }

View File

@@ -14,54 +14,43 @@ import java.util.List;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/** /**
* Deployment chunks. * Deployment chunks.
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode
@ToString
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DdiChunk { public class DdiChunk {
@JsonProperty("part")
@NotNull @NotNull
@Schema(description = "Type of the chunk, e.g. firmware, bundle, app. In update server mapped to Software Module Type") @Schema(description = "Type of the chunk, e.g. firmware, bundle, app. In update server mapped to Software Module Type")
private String part; private final String part;
@JsonProperty("version")
@NotNull @NotNull
@Schema(description = "Software version of the chunk", example = "1.2.0") @Schema(description = "Software version of the chunk", example = "1.2.0")
private String version; private final String version;
@JsonProperty("name")
@NotNull @NotNull
@Schema(description = "Name of the chunk") @Schema(description = "Name of the chunk")
private String name; private final String name;
@JsonProperty("encrypted")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "If encrypted") @Schema(description = "If encrypted")
private Boolean encrypted; private final Boolean encrypted;
@JsonProperty("artifacts")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "List of artifacts") @Schema(description = "List of artifacts")
private List<DdiArtifact> artifacts; private final List<DdiArtifact> artifacts;
@JsonProperty("metadata")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "Meta data of the respective software module that has been marked with 'target visible'") @Schema(description = "Meta data of the respective software module that has been marked with 'target visible'")
private List<DdiMetadata> metadata; private final List<DdiMetadata> metadata;
/** /**
* Constructor. * Constructor.
@@ -73,9 +62,14 @@ public class DdiChunk {
* @param artifacts download information * @param artifacts download information
* @param metadata optional as additional information for the target/device * @param metadata optional as additional information for the target/device
*/ */
@JsonCreator
public DdiChunk( public DdiChunk(
final String part, final String version, final String name, final Boolean encrypted, @JsonProperty("part") final String part,
final List<DdiArtifact> artifacts, final List<DdiMetadata> metadata) { @JsonProperty("version") final String version,
@JsonProperty("name") final String name,
@JsonProperty("encrypted") final Boolean encrypted,
@JsonProperty("artifacts") final List<DdiArtifact> artifacts,
@JsonProperty("metadata") final List<DdiMetadata> metadata) {
this.part = part; this.part = part;
this.version = version; this.version = version;
this.name = name; this.name = name;

View File

@@ -9,37 +9,32 @@
*/ */
package org.eclipse.hawkbit.ddi.json.model; package org.eclipse.hawkbit.ddi.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/** /**
* Standard configuration for the target. * Standard configuration for the target.
*/ */
@NoArgsConstructor // needed for json deserialization @Data
@Getter
@EqualsAndHashCode
@ToString
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@Schema(description = "DDI controller configuration") @Schema(description = "DDI controller configuration")
public class DdiConfig { public class DdiConfig {
@JsonProperty private final DdiPolling polling;
private DdiPolling polling;
/** /**
* Constructor. * Constructor.
* *
* @param polling configuration of the polling for the target * @param polling configuration of the polling for the target
*/ */
public DdiConfig(final DdiPolling polling) { @JsonCreator
public DdiConfig(@JsonProperty("polling") final DdiPolling polling) {
this.polling = polling; this.polling = polling;
} }
} }

View File

@@ -11,13 +11,13 @@ package org.eclipse.hawkbit.ddi.json.model;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
@@ -25,8 +25,7 @@ import org.springframework.hateoas.RepresentationModel;
* Confirmation base response. * Confirmation base response.
* Set order to place links at last. * Set order to place links at last.
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@@ -54,11 +53,12 @@ import org.springframework.hateoas.RepresentationModel;
}""") }""")
public class DdiConfirmationBase extends RepresentationModel<DdiConfirmationBase> { public class DdiConfirmationBase extends RepresentationModel<DdiConfirmationBase> {
@JsonProperty("autoConfirm")
@NotNull @NotNull
private DdiAutoConfirmationState autoConfirm; private final DdiAutoConfirmationState autoConfirm;
public DdiConfirmationBase(final DdiAutoConfirmationState autoConfirmState) { @JsonCreator
this.autoConfirm = autoConfirmState; public DdiConfirmationBase(
@JsonProperty(value = "autoConfirm", required = true) final DdiAutoConfirmationState autoConfirm) {
this.autoConfirm = autoConfirm;
} }
} }

View File

@@ -11,22 +11,22 @@ package org.eclipse.hawkbit.ddi.json.model;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.NonNull;
import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
/** /**
* Update action resource. * Update action resource.
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@@ -201,27 +201,23 @@ import org.springframework.hateoas.RepresentationModel;
}""") }""")
public class DdiConfirmationBaseAction extends RepresentationModel<DdiConfirmationBaseAction> { public class DdiConfirmationBaseAction extends RepresentationModel<DdiConfirmationBaseAction> {
@JsonProperty("id")
@NotNull @NotNull
@Schema(description = "Id of the action", example = "6") @Schema(description = "Id of the action", example = "6")
private String id; private final String id;
@JsonProperty("confirmation")
@NotNull @NotNull
@Schema(description = "Deployment confirmation operation") @Schema(description = "Deployment confirmation operation")
private DdiDeployment confirmation; private final DdiDeployment confirmation;
/** /**
* Action history containing current action status and a list of feedback * Action history containing current action status and a list of feedback messages received earlier from the controller.
* messages received earlier from the controller.
*/ */
@JsonProperty("actionHistory")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = """ @Schema(description = """
(Optional) GET parameter to retrieve a given number of messages which are previously (Optional) GET parameter to retrieve a given number of messages which are previously
provided by the device. Useful if the devices sent state information to the feedback channel and never provided by the device. Useful if the devices sent state information to the feedback channel and never
stored them locally""") stored them locally""")
private DdiActionHistory actionHistory; private final DdiActionHistory actionHistory;
/** /**
* Constructor. * Constructor.
@@ -230,7 +226,11 @@ public class DdiConfirmationBaseAction extends RepresentationModel<DdiConfirmati
* @param confirmation chunk details * @param confirmation chunk details
* @param actionHistory containing current action status and a list of feedback messages received earlier from the controller. * @param actionHistory containing current action status and a list of feedback messages received earlier from the controller.
*/ */
public DdiConfirmationBaseAction(final String id, final DdiDeployment confirmation, final DdiActionHistory actionHistory) { @JsonCreator
public DdiConfirmationBaseAction(
@JsonProperty(value = "id", required = true) @NonNull final String id,
@JsonProperty(value = "confirmation", required = true) @NonNull final DdiDeployment confirmation,
@JsonProperty("actionHistory") final DdiActionHistory actionHistory) {
this.id = id; this.id = id;
this.confirmation = confirmation; this.confirmation = confirmation;
this.actionHistory = actionHistory; this.actionHistory = actionHistory;

View File

@@ -9,22 +9,21 @@
*/ */
package org.eclipse.hawkbit.ddi.json.model; package org.eclipse.hawkbit.ddi.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
/** /**
* {@link DdiControllerBase} resource content. * {@link DdiControllerBase} resource content.
*/ */
@NoArgsConstructor // needed for json deserialization @Data
@Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@@ -56,15 +55,15 @@ import org.springframework.hateoas.RepresentationModel;
}""") }""")
public class DdiControllerBase extends RepresentationModel<DdiControllerBase> { public class DdiControllerBase extends RepresentationModel<DdiControllerBase> {
@JsonProperty private final DdiConfig config;
private DdiConfig config;
/** /**
* Constructor. * Constructor.
* *
* @param config configuration of the SP target * @param config configuration of the SP target
*/ */
public DdiControllerBase(final DdiConfig config) { @JsonCreator
public DdiControllerBase(@JsonProperty("config") final DdiConfig config) {
this.config = config; this.config = config;
} }
} }

View File

@@ -14,23 +14,18 @@ import java.util.List;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/** /**
* Detailed update action information. * Detailed update action information.
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode
@ToString
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DdiDeployment { public class DdiDeployment {
@@ -38,22 +33,21 @@ public class DdiDeployment {
@Schema(description = """ @Schema(description = """
Handling for the download part of the provisioning process ('skip': do not download yet, 'attempt': server asks Handling for the download part of the provisioning process ('skip': do not download yet, 'attempt': server asks
to download, 'forced': server requests immediate download)""") to download, 'forced': server requests immediate download)""")
private HandlingType download; private final HandlingType download;
@Schema(description = """ @Schema(description = """
Handling for the update part of the provisioning process ('skip': do not update yet, Handling for the update part of the provisioning process ('skip': do not update yet,
'attempt': server asks to update, 'forced': server requests immediate update)""") 'attempt': server asks to update, 'forced': server requests immediate update)""")
private HandlingType update; private final HandlingType update;
@JsonProperty("chunks")
@NotNull @NotNull
@Schema(description = "Software chunks of an update. In server mapped by Software Module") @Schema(description = "Software chunks of an update. In server mapped by Software Module")
private List<DdiChunk> chunks; private final List<DdiChunk> chunks;
@Schema(description = """ @Schema(description = """
Separation of download and installation by defining a maintenance window for the installation. Status shows if Separation of download and installation by defining a maintenance window for the installation. Status shows if
currently in a window""") currently in a window""")
private DdiMaintenanceWindowStatus maintenanceWindow; private final DdiMaintenanceWindowStatus maintenanceWindow;
/** /**
* Constructor. * Constructor.
@@ -66,9 +60,12 @@ public class DdiDeployment {
* and the update can progress) or 'unavailable' (implying that maintenance window is not available now and update should not * and the update can progress) or 'unavailable' (implying that maintenance window is not available now and update should not
* be attempted). If there is no maintenance schedule defined, the parameter is null. * be attempted). If there is no maintenance schedule defined, the parameter is null.
*/ */
@JsonCreator
public DdiDeployment( public DdiDeployment(
final HandlingType download, final HandlingType update, final List<DdiChunk> chunks, @JsonProperty("download") final HandlingType download,
final DdiMaintenanceWindowStatus maintenanceWindow) { @JsonProperty("update") final HandlingType update,
@JsonProperty(value = "chunks", required = true) final List<DdiChunk> chunks,
@JsonProperty("maintenanceWindow") final DdiMaintenanceWindowStatus maintenanceWindow) {
this.download = download; this.download = download;
this.update = update; this.update = update;
this.chunks = chunks; this.chunks = chunks;

View File

@@ -11,22 +11,21 @@ package org.eclipse.hawkbit.ddi.json.model;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
/** /**
* Update action resource. * Update action resource.
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@@ -198,24 +197,21 @@ import org.springframework.hateoas.RepresentationModel;
}""") }""")
public class DdiDeploymentBase extends RepresentationModel<DdiDeploymentBase> { public class DdiDeploymentBase extends RepresentationModel<DdiDeploymentBase> {
@JsonProperty("id")
@NotNull @NotNull
@Schema(description = "Id of the action", example = "8") @Schema(description = "Id of the action", example = "8")
private String id; private final String id;
@JsonProperty("deployment")
@NotNull @NotNull
@Schema(description = "Detailed deployment operation") @Schema(description = "Detailed deployment operation")
private DdiDeployment deployment; private final DdiDeployment deployment;
/** /**
* Action history containing current action status and a list of feedback * Action history containing current action status and a list of feedback
* messages received earlier from the controller. * messages received earlier from the controller.
*/ */
@JsonProperty("actionHistory")
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "Current deployment state") @Schema(description = "Current deployment state")
private DdiActionHistory actionHistory; private final DdiActionHistory actionHistory;
/** /**
* Constructor. * Constructor.
@@ -224,7 +220,11 @@ public class DdiDeploymentBase extends RepresentationModel<DdiDeploymentBase> {
* @param deployment details * @param deployment details
* @param actionHistory containing current action status and a list of feedback messages received earlier from the controller. * @param actionHistory containing current action status and a list of feedback messages received earlier from the controller.
*/ */
public DdiDeploymentBase(final String id, final DdiDeployment deployment, final DdiActionHistory actionHistory) { @JsonCreator
public DdiDeploymentBase(
@JsonProperty(value = "id", required = true) final String id,
@JsonProperty(value = "deployment", required = true) final DdiDeployment deployment,
@JsonProperty("actionHistory") final DdiActionHistory actionHistory) {
this.id = id; this.id = id;
this.deployment = deployment; this.deployment = deployment;
this.actionHistory = actionHistory; this.actionHistory = actionHistory;

View File

@@ -24,12 +24,10 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DdiMetadata { public class DdiMetadata {
@JsonProperty
@NotNull @NotNull
@Schema(description = "Key of meta data entry") @Schema(description = "Key of meta data entry")
private final String key; private final String key;
@JsonProperty
@NotNull @NotNull
@Schema(description = "Value of meta data entry") @Schema(description = "Value of meta data entry")
private final String value; private final String value;

View File

@@ -9,38 +9,33 @@
*/ */
package org.eclipse.hawkbit.ddi.json.model; package org.eclipse.hawkbit.ddi.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
/** /**
* Polling interval for the SP target. * Polling interval for the SP target.
*/ */
@NoArgsConstructor // needed for json create @Data
@Getter
@EqualsAndHashCode
@ToString
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@Schema(description = "Suggested sleep time between polls") @Schema(description = "Suggested sleep time between polls")
public class DdiPolling { public class DdiPolling {
@JsonProperty
@Schema(description = "Sleep time in HH:MM:SS notation", pattern = "HH:MM:SS", example = "12:00:00") @Schema(description = "Sleep time in HH:MM:SS notation", pattern = "HH:MM:SS", example = "12:00:00")
private String sleep; private final String sleep;
/** /**
* Constructor. * Constructor.
* *
* @param sleep between polls * @param sleep between polls
*/ */
public DdiPolling(final String sleep) { @JsonCreator
public DdiPolling(@JsonProperty("sleep") final String sleep) {
this.sleep = sleep; this.sleep = sleep;
} }
} }

View File

@@ -39,10 +39,7 @@ class DdiArtifactTest {
final DdiArtifactHash hashes = new DdiArtifactHash("123", "456", "789"); final DdiArtifactHash hashes = new DdiArtifactHash("123", "456", "789");
final Long size = 12345L; final Long size = 12345L;
final DdiArtifact ddiArtifact = new DdiArtifact(); final DdiArtifact ddiArtifact = new DdiArtifact(filename, hashes, size);
ddiArtifact.setFilename(filename);
ddiArtifact.setHashes(hashes);
ddiArtifact.setSize(size);
// Test // Test
final String serializedDdiArtifact = OBJECT_MAPPER.writeValueAsString(ddiArtifact); final String serializedDdiArtifact = OBJECT_MAPPER.writeValueAsString(ddiArtifact);

View File

@@ -174,10 +174,10 @@ public final class DataConversionHelper {
private static DdiArtifact createArtifact( private static DdiArtifact createArtifact(
final Target target, final ArtifactUrlHandler artifactUrlHandler, final Target target, final ArtifactUrlHandler artifactUrlHandler,
final Artifact artifact, final SystemManagement systemManagement, final HttpRequest request) { final Artifact artifact, final SystemManagement systemManagement, final HttpRequest request) {
final DdiArtifact file = new DdiArtifact(); final DdiArtifact file = new DdiArtifact(
file.setHashes(new DdiArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash(), artifact.getSha256Hash())); artifact.getFilename(),
file.setFilename(artifact.getFilename()); new DdiArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash(), artifact.getSha256Hash()),
file.setSize(artifact.getSize()); artifact.getSize());
final TenantMetaData tenantMetadata = systemManagement.getTenantMetadataWithoutDetails(); final TenantMetaData tenantMetadata = systemManagement.getTenantMetadataWithoutDetails();
artifactUrlHandler artifactUrlHandler

View File

@@ -775,15 +775,14 @@ public class DdiRootController implements DdiRootControllerRestApi {
private DdiAutoConfirmationState getAutoConfirmationState(final String controllerId) { private DdiAutoConfirmationState getAutoConfirmationState(final String controllerId) {
return confirmationManagement.getStatus(controllerId).map(status -> { return confirmationManagement.getStatus(controllerId).map(status -> {
final DdiAutoConfirmationState state = DdiAutoConfirmationState.active(status.getActivatedAt()); final DdiAutoConfirmationState state = new DdiAutoConfirmationState(
state.setInitiator(status.getInitiator()); true, status.getInitiator(), status.getRemark(), status.getActivatedAt());
state.setRemark(status.getRemark());
log.trace("Returning state auto-conf state active [initiator='{}' | activatedAt={}] for device {}", log.trace("Returning state auto-conf state active [initiator='{}' | activatedAt={}] for device {}",
controllerId, status.getInitiator(), status.getActivatedAt()); controllerId, status.getInitiator(), status.getActivatedAt());
return state; return state;
}).orElseGet(() -> { }).orElseGet(() -> {
log.trace("Returning state auto-conf state disabled for device {}", controllerId); log.trace("Returning state auto-conf state disabled for device {}", controllerId);
return DdiAutoConfirmationState.disabled(); return new DdiAutoConfirmationState(false, null, null, 0L);
}); });
} }
} }

View File

@@ -29,15 +29,10 @@ public class ControllerSecurityToken {
public static final String AUTHORIZATION_HEADER = "Authorization"; public static final String AUTHORIZATION_HEADER = "Authorization";
@JsonProperty
private final Long tenantId; private final Long tenantId;
@JsonProperty
private final Long targetId; private final Long targetId;
@JsonProperty
private final String controllerId; private final String controllerId;
@JsonProperty
private String tenant; private String tenant;
@JsonProperty
private Map<String, String> headers; private Map<String, String> headers;
/** /**

View File

@@ -19,6 +19,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
@@ -187,14 +188,10 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
protected DmfDownloadAndUpdateRequest createDownloadAndUpdateRequest( protected DmfDownloadAndUpdateRequest createDownloadAndUpdateRequest(
final Target target, final Long actionId, final Target target, final Long actionId,
final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) { final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) {
final DmfDownloadAndUpdateRequest request = new DmfDownloadAndUpdateRequest(); return new DmfDownloadAndUpdateRequest(
request.setActionId(actionId); actionId,
request.setTargetSecurityToken(systemSecurityContext.runAsSystem(target::getSecurityToken)); systemSecurityContext.runAsSystem(target::getSecurityToken),
convertToAmqpSoftwareModules(target, softwareModules));
if (softwareModules != null) {
softwareModules.entrySet().forEach(entry -> request.addSoftwareModule(convertToAmqpSoftwareModule(target, entry)));
}
return request;
} }
/** /**
@@ -264,9 +261,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
return; return;
} }
final DmfActionRequest actionRequest = new DmfActionRequest(); final DmfActionRequest actionRequest = new DmfActionRequest(actionId);
actionRequest.setActionId(actionId);
final Message message = getMessageConverter().toMessage( final Message message = getMessageConverter().toMessage(
actionRequest, actionRequest,
createConnectorMessagePropertiesEvent(tenant, controllerId, EventTopic.CANCEL_DOWNLOAD)); createConnectorMessagePropertiesEvent(tenant, controllerId, EventTopic.CANCEL_DOWNLOAD));
@@ -275,25 +270,15 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
} }
protected DmfTarget convertToDmfTarget(final Target target, final Long actionId) { protected DmfTarget convertToDmfTarget(final Target target, final Long actionId) {
final DmfTarget dmfTarget = new DmfTarget(); return new DmfTarget(actionId, target.getControllerId(), systemSecurityContext.runAsSystem(target::getSecurityToken));
dmfTarget.setActionId(actionId);
dmfTarget.setControllerId(target.getControllerId());
dmfTarget.setTargetSecurityToken(systemSecurityContext.runAsSystem(target::getSecurityToken));
return dmfTarget;
} }
protected DmfConfirmRequest createConfirmRequest( protected DmfConfirmRequest createConfirmRequest(
final Target target, final Long actionId, final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) { final Target target, final Long actionId, final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) {
final DmfConfirmRequest request = new DmfConfirmRequest(); return new DmfConfirmRequest(
request.setActionId(actionId); actionId,
request.setTargetSecurityToken(systemSecurityContext.runAsSystem(target::getSecurityToken)); systemSecurityContext.runAsSystem(target::getSecurityToken),
convertToAmqpSoftwareModules(target, softwareModules));
//Software modules can be filtered in the future exposing only the needed.
if (softwareModules != null) {
softwareModules.entrySet().forEach(entry ->
request.addSoftwareModule(convertToAmqpSoftwareModule(target, entry)));
}
return request;
} }
void sendMultiActionRequestToTarget( void sendMultiActionRequestToTarget(
@@ -304,18 +289,21 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
return; return;
} }
final DmfMultiActionRequest multiActionRequest = new DmfMultiActionRequest(); final DmfMultiActionRequest multiActionRequest = new DmfMultiActionRequest(
actions.forEach(action -> { actions.stream()
final DmfActionRequest actionRequest = createDmfActionRequest( .map(action -> {
target, action, final DmfActionRequest actionRequest = createDmfActionRequest(
action.getDistributionSet().getModules().stream() target, action,
.collect(Collectors.toMap(Function.identity(), module -> { action.getDistributionSet().getModules().stream()
final List<SoftwareModuleMetadata> softwareModuleMetadata = getSoftwareModuleMetaData.apply(module); .collect(Collectors.toMap(Function.identity(), module -> {
return softwareModuleMetadata == null ? Collections.emptyList() : softwareModuleMetadata; final List<SoftwareModuleMetadata> softwareModuleMetadata = getSoftwareModuleMetaData.apply(
}))); module);
final int weight = deploymentManagement.getWeightConsideringDefault(action); return softwareModuleMetadata == null ? Collections.emptyList() : softwareModuleMetadata;
multiActionRequest.addElement(getEventTypeForAction(action), actionRequest, weight); })));
}); final int weight = deploymentManagement.getWeightConsideringDefault(action);
return new DmfMultiActionRequest.DmfMultiActionElement(getEventTypeForAction(action), actionRequest, weight);
})
.toList());
final Message message = getMessageConverter().toMessage( final Message message = getMessageConverter().toMessage(
multiActionRequest, multiActionRequest,
@@ -323,12 +311,6 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
amqpSenderService.sendMessage(message, targetAddress); amqpSenderService.sendMessage(message, targetAddress);
} }
private static DmfActionRequest createPlainActionRequest(final Action action) {
final DmfActionRequest actionRequest = new DmfActionRequest();
actionRequest.setActionId(action.getId());
return actionRequest;
}
/** /**
* Method to get the type of event depending on whether the action is a DOWNLOAD_ONLY action or if it has a valid maintenance window * Method to get the type of event depending on whether the action is a DOWNLOAD_ONLY action or if it has a valid maintenance window
* available or not based on defined maintenance schedule. In case of no maintenance schedule or if there is a valid window available, * available or not based on defined maintenance schedule. In case of no maintenance schedule or if there is a valid window available,
@@ -488,7 +470,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
final Target target, final Action action, final Target target, final Action action,
final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) { final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) {
if (action.isCancelingOrCanceled()) { if (action.isCancelingOrCanceled()) {
return createPlainActionRequest(action); return new DmfActionRequest(action.getId());
} else if (action.isWaitingConfirmation()) { } else if (action.isWaitingConfirmation()) {
return createConfirmRequest(target, action.getId(), softwareModules); return createConfirmRequest(target, action.getId(), softwareModules);
} }
@@ -553,21 +535,24 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
amqpSenderService.sendMessage(message, URI.create(targetAddress)); amqpSenderService.sendMessage(message, URI.create(targetAddress));
} }
private List<DmfSoftwareModule> convertToAmqpSoftwareModules(
final Target target, final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) {
return Optional.ofNullable(softwareModules)
.map(Map::entrySet)
.map(Set::stream)
.map(stream -> stream.map(entry -> convertToAmqpSoftwareModule(target, entry)).toList())
.orElse(null);
}
private DmfSoftwareModule convertToAmqpSoftwareModule( private DmfSoftwareModule convertToAmqpSoftwareModule(
final Target target, final Target target, final Entry<SoftwareModule, List<SoftwareModuleMetadata>> entry) {
final Entry<SoftwareModule, List<SoftwareModuleMetadata>> entry) { return new DmfSoftwareModule(
final DmfSoftwareModule amqpSoftwareModule = new DmfSoftwareModule(); entry.getKey().getId(),
amqpSoftwareModule.setModuleId(entry.getKey().getId()); entry.getKey().getType().getKey(),
amqpSoftwareModule.setModuleType(entry.getKey().getType().getKey()); entry.getKey().getVersion(),
amqpSoftwareModule.setModuleVersion(entry.getKey().getVersion()); entry.getKey().isEncrypted() ? Boolean.TRUE : null,
amqpSoftwareModule.setEncrypted(entry.getKey().isEncrypted() ? Boolean.TRUE : null); convertArtifacts(target, entry.getKey().getArtifacts()),
amqpSoftwareModule.setArtifacts(convertArtifacts(target, entry.getKey().getArtifacts())); CollectionUtils.isEmpty(entry.getValue()) ? null :convertMetadata(entry.getValue()));
if (!CollectionUtils.isEmpty(entry.getValue())) {
amqpSoftwareModule.setMetadata(convertMetadata(entry.getValue()));
}
return amqpSoftwareModule;
} }
private List<DmfMetadata> convertMetadata(final List<SoftwareModuleMetadata> metadata) { private List<DmfMetadata> convertMetadata(final List<SoftwareModuleMetadata> metadata) {
@@ -584,24 +569,22 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
} }
private DmfArtifact convertArtifact(final Target target, final Artifact localArtifact) { private DmfArtifact convertArtifact(final Target target, final Artifact localArtifact) {
final DmfArtifact artifact = new DmfArtifact();
final TenantMetaData tenantMetadata = systemManagement.getTenantMetadataWithoutDetails(); final TenantMetaData tenantMetadata = systemManagement.getTenantMetadataWithoutDetails();
artifact.setUrls(artifactUrlHandler return new DmfArtifact(
.getUrls(new URLPlaceholder( localArtifact.getFilename(),
tenantMetadata.getTenant(), tenantMetadata.getId(), target.getControllerId(), target.getId(), new DmfArtifactHash(localArtifact.getSha1Hash(), localArtifact.getMd5Hash()),
new SoftwareData( localArtifact.getSize(),
localArtifact.getSoftwareModule().getId(), localArtifact.getFilename(), localArtifact.getId(), localArtifact.getLastModifiedAt(),
localArtifact.getSha1Hash())), artifactUrlHandler
ApiType.DMF) .getUrls(new URLPlaceholder(
.stream() tenantMetadata.getTenant(), tenantMetadata.getId(), target.getControllerId(), target.getId(),
.collect(Collectors.toMap(ArtifactUrl::getProtocol, ArtifactUrl::getRef))); new SoftwareData(
localArtifact.getSoftwareModule().getId(), localArtifact.getFilename(), localArtifact.getId(),
artifact.setFilename(localArtifact.getFilename()); localArtifact.getSha1Hash())),
artifact.setHashes(new DmfArtifactHash(localArtifact.getSha1Hash(), localArtifact.getMd5Hash())); ApiType.DMF)
artifact.setSize(localArtifact.getSize()); .stream()
artifact.setLastModified(localArtifact.getLastModifiedAt()); .collect(Collectors.toMap(ArtifactUrl::getProtocol, ArtifactUrl::getRef))
return artifact; );
} }
private Map<SoftwareModule, List<SoftwareModuleMetadata>> getSoftwareModulesWithMetadata(final DistributionSet distributionSet) { private Map<SoftwareModule, List<SoftwareModuleMetadata>> getSoftwareModulesWithMetadata(final DistributionSet distributionSet) {
@@ -622,18 +605,16 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
.map(t -> convertToDmfTarget(t, actions.get(t.getControllerId()).getId())) .map(t -> convertToDmfTarget(t, actions.get(t.getControllerId()).getId()))
.toList(); .toList();
final DmfBatchDownloadAndUpdateRequest batchRequest = new DmfBatchDownloadAndUpdateRequest(); // due to the fact that all targets in a batch use the same set of software modules we don't generate target-specific urls
batchRequest.setTimestamp(System.currentTimeMillis());
batchRequest.addTargets(dmfTargets);
// due to the fact that all targets in a batch use the same set of
// software modules we don't generate
// target-specific urls
final Target firstTarget = targets.get(0); final Target firstTarget = targets.get(0);
if (modules != null) { final DmfBatchDownloadAndUpdateRequest batchRequest = new DmfBatchDownloadAndUpdateRequest(
modules.entrySet().forEach(entry -> System.currentTimeMillis(),
batchRequest.addSoftwareModule(convertToAmqpSoftwareModule(firstTarget, entry))); dmfTargets,
} Optional.ofNullable(modules)
.map(Map::entrySet)
.map(Set::stream)
.map(stream -> stream.map(entry -> convertToAmqpSoftwareModule(firstTarget, entry)).toList())
.orElse(null));
// we use only the first action when constructing message as Tenant and action type are the same // we use only the first action when constructing message as Tenant and action type are the same
// since all actions have the same trigger // since all actions have the same trigger

View File

@@ -454,17 +454,16 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
final Action updatedAction; final Action updatedAction;
if (actionUpdateStatus.getActionStatus() == DmfActionStatus.CONFIRMED) { if (actionUpdateStatus.getActionStatus() == DmfActionStatus.CONFIRMED) {
updatedAction = confirmationManagement.confirmAction(action.getId(), updatedAction = confirmationManagement.confirmAction(action.getId(), actionUpdateStatus.getCode(), messages);
actionUpdateStatus.getCode().orElse(null), messages);
} else if (actionUpdateStatus.getActionStatus() == DmfActionStatus.DENIED) { } else if (actionUpdateStatus.getActionStatus() == DmfActionStatus.DENIED) {
updatedAction = confirmationManagement.denyAction(action.getId(), actionUpdateStatus.getCode().orElse(null), messages); updatedAction = confirmationManagement.denyAction(action.getId(), actionUpdateStatus.getCode(), messages);
} else { } else {
final ActionStatusCreate actionStatus = entityFactory.actionStatus().create(action.getId()).status(status).messages(messages); final ActionStatusCreate actionStatus = entityFactory.actionStatus().create(action.getId()).status(status).messages(messages);
actionUpdateStatus.getCode().ifPresent(code -> { Optional.ofNullable(actionUpdateStatus.getCode()).ifPresent(code -> {
actionStatus.code(code); actionStatus.code(code);
actionStatus.message("Device reported status code: " + code); actionStatus.message("Device reported status code: " + code);
}); });
updatedAction = ((Status.CANCELED == status) || (Status.CANCEL_REJECTED == status)) updatedAction = Status.CANCELED == status || Status.CANCEL_REJECTED == status
? controllerManagement.addCancelActionStatus(actionStatus) ? controllerManagement.addCancelActionStatus(actionStatus)
: controllerManagement.addUpdateActionStatus(actionStatus); : controllerManagement.addUpdateActionStatus(actionStatus);
} }

View File

@@ -174,8 +174,7 @@ class AmqpMessageHandlerServiceTest {
final String knownThingId = "2"; final String knownThingId = "2";
final String knownThingName = "NonDefaultTargetName"; final String knownThingName = "NonDefaultTargetName";
final DmfCreateThing payload = new DmfCreateThing(); final DmfCreateThing payload = new DmfCreateThing(knownThingName, null, null);
payload.setName(knownThingName);
processThingCreatedMessage(knownThingId, payload); processThingCreatedMessage(knownThingId, payload);
@@ -190,8 +189,7 @@ class AmqpMessageHandlerServiceTest {
final String knownThingId = "2"; final String knownThingId = "2";
final String knownThingTypeName = "TargetTypeName"; final String knownThingTypeName = "TargetTypeName";
final DmfCreateThing payload = new DmfCreateThing(); final DmfCreateThing payload = new DmfCreateThing(null, knownThingTypeName, null);
payload.setType(knownThingTypeName);
processThingCreatedMessage(knownThingId, payload); processThingCreatedMessage(knownThingId, payload);
@@ -215,12 +213,9 @@ class AmqpMessageHandlerServiceTest {
void createThingWithAttributes() { void createThingWithAttributes() {
final String knownThingId = "4"; final String knownThingId = "4";
final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(); final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate();
attributeUpdate.getAttributes().put("testKey1", "testValue1");
attributeUpdate.getAttributes().put("testKey2", "testValue2");
final DmfCreateThing payload = new DmfCreateThing(); final DmfCreateThing payload = new DmfCreateThing(null, null, attributeUpdate);
payload.setAttributeUpdate(attributeUpdate);
processThingCreatedMessage(knownThingId, payload); processThingCreatedMessage(knownThingId, payload);
@@ -235,14 +230,9 @@ class AmqpMessageHandlerServiceTest {
final String knownThingId = "5"; final String knownThingId = "5";
final String knownThingName = "NonDefaultTargetName"; final String knownThingName = "NonDefaultTargetName";
final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(); final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(
attributeUpdate.getAttributes().put("testKey1", "testValue1"); Map.of("testKey1", "testValue1", "testKey2", "testValue2"), DmfUpdateMode.REPLACE);
attributeUpdate.getAttributes().put("testKey2", "testValue2"); final DmfCreateThing payload = new DmfCreateThing(knownThingName, null, attributeUpdate);
attributeUpdate.setMode(DmfUpdateMode.REPLACE);
final DmfCreateThing payload = new DmfCreateThing();
payload.setName(knownThingName);
payload.setAttributeUpdate(attributeUpdate);
processThingCreatedMessage(knownThingId, payload); processThingCreatedMessage(knownThingId, payload);
@@ -259,9 +249,7 @@ class AmqpMessageHandlerServiceTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_ATTRIBUTES"); messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_ATTRIBUTES");
final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(); final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate();
attributeUpdate.getAttributes().put("testKey1", "testValue1");
attributeUpdate.getAttributes().put("testKey2", "testValue2");
final Message message = createMessage(attributeUpdate, messageProperties); final Message message = createMessage(attributeUpdate, messageProperties);
@@ -281,9 +269,7 @@ class AmqpMessageHandlerServiceTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_ATTRIBUTES"); messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_ATTRIBUTES");
final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(); DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate();
attributeUpdate.getAttributes().put("testKey1", "testValue1");
attributeUpdate.getAttributes().put("testKey2", "testValue2");
when(controllerManagementMock.updateControllerAttributes(targetIdCaptor.capture(), attributesCaptor.capture(), when(controllerManagementMock.updateControllerAttributes(targetIdCaptor.capture(), attributesCaptor.capture(),
modeCaptor.capture())).thenReturn(null); modeCaptor.capture())).thenReturn(null);
@@ -296,27 +282,36 @@ class AmqpMessageHandlerServiceTest {
assertThingAttributesModeCapturedField(null); assertThingAttributesModeCapturedField(null);
// send a message which specifies update mode MERGE // send a message which specifies update mode MERGE
attributeUpdate.setMode(DmfUpdateMode.MERGE); attributeUpdate = dmfAttributeUpdate(DmfUpdateMode.MERGE);
message = createMessage(attributeUpdate, messageProperties); message = createMessage(attributeUpdate, messageProperties);
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST); amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST);
// verify that the update mode is converted and forwarded as expected // verify that the update mode is converted and forwarded as expected
assertThingAttributesModeCapturedField(UpdateMode.MERGE); assertThingAttributesModeCapturedField(UpdateMode.MERGE);
// send a message which specifies update mode REPLACE // send a message which specifies update mode REPLACE
attributeUpdate.setMode(DmfUpdateMode.REPLACE); attributeUpdate = dmfAttributeUpdate(DmfUpdateMode.REPLACE);
message = createMessage(attributeUpdate, messageProperties); message = createMessage(attributeUpdate, messageProperties);
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST); amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST);
// verify that the update mode is converted and forwarded as expected // verify that the update mode is converted and forwarded as expected
assertThingAttributesModeCapturedField(UpdateMode.REPLACE); assertThingAttributesModeCapturedField(UpdateMode.REPLACE);
// send a message which specifies update mode REMOVE // send a message which specifies update mode REMOVE
attributeUpdate.setMode(DmfUpdateMode.REMOVE); attributeUpdate = dmfAttributeUpdate(DmfUpdateMode.REMOVE);
message = createMessage(attributeUpdate, messageProperties); message = createMessage(attributeUpdate, messageProperties);
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST); amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST);
// verify that the update mode is converted and forwarded as expected // verify that the update mode is converted and forwarded as expected
assertThingAttributesModeCapturedField(UpdateMode.REMOVE); assertThingAttributesModeCapturedField(UpdateMode.REMOVE);
} }
private static DmfAttributeUpdate dmfAttributeUpdate() {
return dmfAttributeUpdate(null);
}
private static DmfAttributeUpdate dmfAttributeUpdate(final DmfUpdateMode mode) {
return new DmfAttributeUpdate(
Map.of("testKey1", "testValue1", "testKey2", "testValue2"), mode);
}
@Test @Test
@Description("Tests the creation of a thing without a 'reply to' header in message.") @Description("Tests the creation of a thing without a 'reply to' header in message.")
void createThingWithoutReplyTo() { void createThingWithoutReplyTo() {
@@ -470,7 +465,6 @@ class AmqpMessageHandlerServiceTest {
@Test @Test
@Description("Test feedback code is persisted in messages when provided with DmfActionUpdateStatus") @Description("Test feedback code is persisted in messages when provided with DmfActionUpdateStatus")
void feedBackCodeIsPersistedInMessages() throws IllegalAccessException { void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
// Mock // Mock
final Action action = createActionWithTarget(22L); final Action action = createActionWithTarget(22L);
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action)); when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
@@ -483,23 +477,22 @@ class AmqpMessageHandlerServiceTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(23L, DmfActionStatus.RUNNING); final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(
actionUpdateStatus.setSoftwareModuleId(Long.valueOf(2)); 23L, DmfActionStatus.RUNNING, null, 2L, null, 12);
actionUpdateStatus.setCode(12);
final Message message = createMessage(actionUpdateStatus, messageProperties); final Message message = createMessage(actionUpdateStatus, messageProperties);
// test // test
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST); amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, VIRTUAL_HOST);
final ArgumentCaptor<ActionStatusCreate> actionPropertiesCaptor = ArgumentCaptor final ArgumentCaptor<ActionStatusCreate> actionPropertiesCaptor = ArgumentCaptor.forClass(ActionStatusCreate.class);
.forClass(ActionStatusCreate.class);
verify(controllerManagementMock, times(1)).addUpdateActionStatus(actionPropertiesCaptor.capture()); verify(controllerManagementMock, times(1)).addUpdateActionStatus(actionPropertiesCaptor.capture());
final JpaActionStatus jpaActionStatus = (JpaActionStatus) actionPropertiesCaptor.getValue().build(); final JpaActionStatus jpaActionStatus = (JpaActionStatus) actionPropertiesCaptor.getValue().build();
assertThat(jpaActionStatus.getCode()).as("Action status for reported code is missing").contains(12); assertThat(jpaActionStatus.getCode()).as("Action status for reported code is missing").contains(12);
assertThat(jpaActionStatus.getMessages()).as("Action status message for reported code is missing") assertThat(jpaActionStatus.getMessages())
.as("Action status message for reported code is missing")
.contains("Device reported status code: 12"); .contains("Device reported status code: 12");
} }
@@ -542,10 +535,7 @@ class AmqpMessageHandlerServiceTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_AUTO_CONFIRM"); messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_AUTO_CONFIRM");
final DmfAutoConfirmation autoConfirmation = new DmfAutoConfirmation(); final DmfAutoConfirmation autoConfirmation = new DmfAutoConfirmation(true, initiator, remark);
autoConfirmation.setEnabled(true);
autoConfirmation.setInitiator(initiator);
autoConfirmation.setRemark(remark);
final Message message = createMessage(autoConfirmation, messageProperties); final Message message = createMessage(autoConfirmation, messageProperties);
@@ -569,7 +559,7 @@ class AmqpMessageHandlerServiceTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_AUTO_CONFIRM"); messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_AUTO_CONFIRM");
final DmfAutoConfirmation autoConfirmation = new DmfAutoConfirmation(); final DmfAutoConfirmation autoConfirmation = new DmfAutoConfirmation(false, null, null);
final Message message = createMessage(autoConfirmation, messageProperties); final Message message = createMessage(autoConfirmation, messageProperties);
@@ -649,9 +639,7 @@ class AmqpMessageHandlerServiceTest {
} }
private DmfActionUpdateStatus createActionUpdateStatus(final DmfActionStatus status, final Long id) { private DmfActionUpdateStatus createActionUpdateStatus(final DmfActionStatus status, final Long id) {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(id, status); return new DmfActionUpdateStatus(id, status, null, 2L, null, null);
actionUpdateStatus.setSoftwareModuleId(Long.valueOf(2));
return actionUpdateStatus;
} }
private MessageProperties createMessageProperties(final MessageType type) { private MessageProperties createMessageProperties(final MessageType type) {

View File

@@ -13,6 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.util.List;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -100,12 +102,7 @@ class BaseAmqpServiceTest {
} }
private DmfActionUpdateStatus createActionStatus() { private DmfActionUpdateStatus createActionStatus() {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); return new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING, null, 2L, List.of("Message 1", "Message 2"), 2);
actionUpdateStatus.setCode(2);
actionUpdateStatus.setSoftwareModuleId(2L);
actionUpdateStatus.addMessage("Message 1");
actionUpdateStatus.addMessage("Message 2");
return actionUpdateStatus;
} }
} }

View File

@@ -306,14 +306,9 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
DmfCreateThing payload = null; DmfCreateThing payload = null;
if (!StringUtils.isEmpty(name) || !CollectionUtils.isEmpty(attributes)) { if (!StringUtils.isEmpty(name) || !CollectionUtils.isEmpty(attributes)) {
payload = new DmfCreateThing(); payload = new DmfCreateThing(
payload.setName(name); name, null,
CollectionUtils.isEmpty(attributes) ? null : new DmfAttributeUpdate(attributes, null));
if (!CollectionUtils.isEmpty(attributes)) {
final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate();
attributeUpdate.getAttributes().putAll(attributes);
payload.setAttributeUpdate(attributeUpdate);
}
} }
return createMessage(payload, messageProperties); return createMessage(payload, messageProperties);
@@ -330,7 +325,8 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
protected void createAndSendActionStatusUpdateMessage(final String target, final long actionId, protected void createAndSendActionStatusUpdateMessage(final String target, final long actionId,
final DmfActionStatus status) { final DmfActionStatus status) {
final DmfActionUpdateStatus dmfActionUpdateStatus = new DmfActionUpdateStatus(actionId, status, System.currentTimeMillis()); final DmfActionUpdateStatus dmfActionUpdateStatus = new DmfActionUpdateStatus(
actionId, status, System.currentTimeMillis(), null, null, null);
final Message eventMessage = createUpdateActionEventMessage(dmfActionUpdateStatus); final Message eventMessage = createUpdateActionEventMessage(dmfActionUpdateStatus);
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.THING_ID, target); eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.THING_ID, target);

View File

@@ -729,9 +729,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
// setup // setup
registerAndAssertTargetWithExistingTenant(controllerId); registerAndAssertTargetWithExistingTenant(controllerId);
final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(
controllerAttribute.getAttributes().put("test1", "testA"); Map.of("test1", "testA", "test2", "testB"), null);
controllerAttribute.getAttributes().put("test2", "testB");
final Message createUpdateAttributesMessage = createUpdateAttributesMessage(null, TENANT_EXIST, final Message createUpdateAttributesMessage = createUpdateAttributesMessage(null, TENANT_EXIST,
controllerAttribute); controllerAttribute);
createUpdateAttributesMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID); createUpdateAttributesMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
@@ -741,7 +740,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
// verify // verify
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
final DmfAttributeUpdate controllerAttributeEmpty = new DmfAttributeUpdate(); final DmfAttributeUpdate controllerAttributeEmpty = new DmfAttributeUpdate(null, null);
assertUpdateAttributes(controllerId, controllerAttributeEmpty.getAttributes()); assertUpdateAttributes(controllerId, controllerAttributeEmpty.getAttributes());
} }
@@ -754,11 +753,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
void updateAttributesWithWrongBody() { void updateAttributesWithWrongBody() {
// setup // setup
registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID); registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID);
final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); final Message createUpdateAttributesMessageWrongBody = createUpdateAttributesMessageWrongBody( UPDATE_ATTR_TEST_CONTROLLER_ID);
controllerAttribute.getAttributes().put("test1", "testA");
controllerAttribute.getAttributes().put("test2", "testB");
final Message createUpdateAttributesMessageWrongBody = createUpdateAttributesMessageWrongBody(
UPDATE_ATTR_TEST_CONTROLLER_ID);
// test // test
getDmfClient().send(createUpdateAttributesMessageWrongBody); getDmfClient().send(createUpdateAttributesMessageWrongBody);
@@ -1051,9 +1046,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
removeAttributes.put("k1", "foo"); removeAttributes.put("k1", "foo");
removeAttributes.put("k3", "bar"); removeAttributes.put("k3", "bar");
final DmfAttributeUpdate remove = new DmfAttributeUpdate(); final DmfAttributeUpdate remove = new DmfAttributeUpdate(removeAttributes, DmfUpdateMode.REMOVE);
remove.setMode(DmfUpdateMode.REMOVE);
remove.getAttributes().putAll(removeAttributes);
sendUpdateAttributeMessage(remove); sendUpdateAttributeMessage(remove);
// validate // validate
@@ -1071,9 +1064,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
mergeAttributes.put("k1", "v1_modified_again"); mergeAttributes.put("k1", "v1_modified_again");
mergeAttributes.put("k4", "v4"); mergeAttributes.put("k4", "v4");
final DmfAttributeUpdate merge = new DmfAttributeUpdate(); final DmfAttributeUpdate merge = new DmfAttributeUpdate(mergeAttributes, DmfUpdateMode.MERGE);
merge.setMode(DmfUpdateMode.MERGE);
merge.getAttributes().putAll(mergeAttributes);
sendUpdateAttributeMessage(merge); sendUpdateAttributeMessage(merge);
// validate // validate
@@ -1091,9 +1082,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
expectedAttributes.put("k2", "v2"); expectedAttributes.put("k2", "v2");
expectedAttributes.put("k3", "v3"); expectedAttributes.put("k3", "v3");
final DmfAttributeUpdate replace = new DmfAttributeUpdate(); final DmfAttributeUpdate replace = new DmfAttributeUpdate(expectedAttributes, DmfUpdateMode.REPLACE);
replace.setMode(DmfUpdateMode.REPLACE);
replace.getAttributes().putAll(expectedAttributes);
sendUpdateAttributeMessage(replace); sendUpdateAttributeMessage(replace);
// validate // validate
@@ -1107,8 +1096,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
expectedAttributes.put("k0", "v0"); expectedAttributes.put("k0", "v0");
expectedAttributes.put("k1", "v1"); expectedAttributes.put("k1", "v1");
final DmfAttributeUpdate defaultUpdate = new DmfAttributeUpdate(); final DmfAttributeUpdate defaultUpdate = new DmfAttributeUpdate(expectedAttributes, null);
defaultUpdate.getAttributes().putAll(expectedAttributes);
sendUpdateAttributeMessage(defaultUpdate); sendUpdateAttributeMessage(defaultUpdate);
// validate // validate
@@ -1135,10 +1123,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
private void sendUpdateAttributesMessageWithGivenAttributes(final String key, final String value) { private void sendUpdateAttributesMessageWithGivenAttributes(final String key, final String value) {
final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(Map.of(key, value), null);
controllerAttribute.getAttributes().put(key, value); final Message message = createUpdateAttributesMessage(UPDATE_ATTR_TEST_CONTROLLER_ID, TENANT_EXIST, controllerAttribute);
final Message message = createUpdateAttributesMessage(UPDATE_ATTR_TEST_CONTROLLER_ID, TENANT_EXIST,
controllerAttribute);
getDmfClient().send(message); getDmfClient().send(message);
} }

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -23,6 +24,10 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfActionRequest { public class DmfActionRequest {
@JsonProperty private final Long actionId;
private Long actionId;
@JsonCreator
public DmfActionRequest(@JsonProperty("actionId") final Long actionId) {
this.actionId = actionId;
}
} }

View File

@@ -9,20 +9,15 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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.Data;
import lombok.Setter;
/** /**
* JSON representation of action update status. * JSON representation of action update status.
@@ -35,31 +30,28 @@ public class DmfActionUpdateStatus {
private final Long actionId; private final Long actionId;
private final DmfActionStatus actionStatus; private final DmfActionStatus actionStatus;
private final long timestamp; private final long timestamp;
private final Long softwareModuleId;
private final List<String> message;
private final Integer code;
@JsonProperty @JsonCreator
private Long softwareModuleId; public DmfActionUpdateStatus(
@JsonProperty(value = "actionId", required = true) final Long actionId,
@Setter(AccessLevel.NONE) @JsonProperty(value = "actionStatus", required = true) final DmfActionStatus actionStatus,
@JsonProperty @JsonProperty(value = "timestamp") final Long timestamp,
private List<String> message; @JsonProperty("softwareModuleId") final Long softwareModuleId,
@JsonProperty("message") final List<String> message,
@JsonProperty @JsonProperty("code") final Integer code) {
private Integer code;
public DmfActionUpdateStatus(@JsonProperty(value = "actionId", required = true) final Long actionId,
@JsonProperty(value = "actionStatus", required = true) final DmfActionStatus actionStatus, @JsonProperty(value = "timestamp") final Long timestamp) {
this.actionId = actionId; this.actionId = actionId;
this.actionStatus = actionStatus; this.actionStatus = actionStatus;
this.timestamp = timestamp != null ? timestamp : System.currentTimeMillis(); this.timestamp = timestamp != null ? timestamp : System.currentTimeMillis();
this.softwareModuleId = softwareModuleId;
this.message = message;
this.code = code;
} }
public DmfActionUpdateStatus(final Long actionId, final DmfActionStatus actionStatus) { public DmfActionUpdateStatus(final Long actionId, final DmfActionStatus actionStatus) {
this(actionId, actionStatus, null); this(actionId, actionStatus, null, null, null, 0);
}
@JsonIgnore
public Optional<Integer> getCode() {
return Optional.ofNullable(code);
} }
public List<String> getMessage() { public List<String> getMessage() {
@@ -69,25 +61,4 @@ public class DmfActionUpdateStatus {
return message; return message;
} }
public boolean addMessage(final String message) {
if (this.message == null) {
this.message = new ArrayList<>();
}
return this.message.add(message);
}
public boolean addMessage(final Collection<String> messages) {
if (messages == null || messages.isEmpty()) {
return false;
}
if (message == null) {
message = new ArrayList<>(messages);
return true;
}
return message.addAll(messages);
}
} }

View File

@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.dmf.json.model;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -26,22 +27,23 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfArtifact { public class DmfArtifact {
@JsonProperty private final String filename;
private String filename; private final DmfArtifactHash hashes;
@JsonProperty private final long size;
private DmfArtifactHash hashes; private final long lastModified;
@JsonProperty private final Map<String, String> urls;
private long size;
@JsonProperty
private long lastModified;
@JsonProperty
private Map<String, String> urls;
public Map<String, String> getUrls() { @JsonCreator
if (urls == null) { public DmfArtifact(
return Collections.emptyMap(); @JsonProperty("filename") final String filename,
} @JsonProperty("hashes") final DmfArtifactHash hashes,
@JsonProperty("size") final long size,
return Collections.unmodifiableMap(urls); @JsonProperty("lastModified") final long lastModified,
@JsonProperty("urls") final Map<String, String> urls) {
this.filename = filename;
this.hashes = hashes;
this.size = size;
this.lastModified = lastModified;
this.urls = urls == null ? Collections.emptyMap() : Collections.unmodifiableMap(urls);
} }
} }

View File

@@ -19,10 +19,8 @@ import lombok.Data;
@Data @Data
public class DmfArtifactHash { public class DmfArtifactHash {
@JsonProperty private final String sha1;
private String sha1; private final String md5;
@JsonProperty
private String md5;
/** /**
* Constructor. * Constructor.

View File

@@ -9,9 +9,10 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import java.util.HashMap; import java.util.Collections;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -26,9 +27,14 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfAttributeUpdate { public class DmfAttributeUpdate {
@JsonProperty private final Map<String, String> attributes;
private final Map<String, String> attributes = new HashMap<>(); private final DmfUpdateMode mode;
@JsonProperty @JsonCreator
private DmfUpdateMode mode; public DmfAttributeUpdate(
@JsonProperty("attributes") final Map<String, String> attributes,
@JsonProperty("mode") final DmfUpdateMode mode) {
this.attributes = attributes == null ? Collections.emptyMap() : attributes;
this.mode = mode;
}
} }

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -23,10 +24,17 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfAutoConfirmation { public class DmfAutoConfirmation {
@JsonProperty private final boolean enabled;
private boolean enabled; private final String initiator;
@JsonProperty private final String remark;
private String initiator;
@JsonProperty @JsonCreator
private String remark; public DmfAutoConfirmation(
@JsonProperty("enabled") final boolean enabled,
@JsonProperty("initiator") final String initiator,
@JsonProperty("remark") final String remark) {
this.enabled = enabled;
this.initiator = initiator;
this.remark = remark;
}
} }

View File

@@ -17,78 +17,28 @@ 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.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
/** /**
* JSON representation of batch download and update request. * JSON representation of batch download and update request.
*/ */
@Data
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfBatchDownloadAndUpdateRequest { public class DmfBatchDownloadAndUpdateRequest {
@Getter private final Long timestamp;
@Setter private final List<DmfTarget> targets;
@JsonProperty private final List<DmfSoftwareModule> softwareModules;
private Long timestamp;
@JsonProperty public DmfBatchDownloadAndUpdateRequest(
private List<DmfTarget> targets; @JsonProperty("timestamp") final Long timestamp,
@JsonProperty("targets") final List<DmfTarget> targets,
@JsonProperty @JsonProperty("softwareModules") final List<DmfSoftwareModule> softwareModules) {
private List<DmfSoftwareModule> softwareModules; this.timestamp = timestamp;
this.targets = targets == null ? Collections.emptyList() : targets;
public List<DmfSoftwareModule> getSoftwareModules() { this.softwareModules = softwareModules == null ? Collections.emptyList() : Collections.unmodifiableList(softwareModules);
if (softwareModules == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(softwareModules);
}
/**
* Add a Software module.
*
* @param createSoftwareModule the module
*/
public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) {
if (softwareModules == null) {
softwareModules = new ArrayList<>();
}
softwareModules.add(createSoftwareModule);
}
public List<DmfTarget> getTargets() {
if (targets == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(targets);
}
/**
* Add a Target.
*
* @param target the target
*/
public void addTarget(final DmfTarget target) {
if (targets == null) {
targets = new ArrayList<>();
}
targets.add(target);
}
/**
* Add multiple Targets.
*
* @param targets the target
*/
public void addTargets(final List<DmfTarget> targets) {
if (this.targets == null) {
this.targets = new ArrayList<>();
}
this.targets.addAll(targets);
} }
} }

View File

@@ -9,33 +9,41 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.ToString;
/** /**
* JSON representation of confirm request. * JSON representation of confirm request.
*/ */
@Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@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 private final String targetSecurityToken;
@Setter private final List<DmfSoftwareModule> softwareModules;
@JsonProperty
private String targetSecurityToken;
@JsonProperty @JsonCreator
private List<DmfSoftwareModule> softwareModules; public DmfConfirmRequest(
@JsonProperty("actionId") final Long actionId,
@JsonProperty("targetSecurityToken") final String targetSecurityToken,
@JsonProperty("softwareModules") final List<DmfSoftwareModule> softwareModules) {
super(actionId);
this.targetSecurityToken = targetSecurityToken;
this.softwareModules = softwareModules;
}
public List<DmfSoftwareModule> getSoftwareModules() { public List<DmfSoftwareModule> getSoftwareModules() {
if (softwareModules == null) { if (softwareModules == null) {
@@ -44,18 +52,4 @@ public class DmfConfirmRequest extends DmfActionRequest {
return Collections.unmodifiableList(softwareModules); return Collections.unmodifiableList(softwareModules);
} }
/**
* Add a Software module.
*
* @param createSoftwareModule the module
*/
public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) {
if (softwareModules == null) {
softwareModules = new ArrayList<>();
}
softwareModules.add(createSoftwareModule);
}
} }

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -23,12 +24,17 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfCreateThing { public class DmfCreateThing {
@JsonProperty private final String name;
private String name; private final String type;
private final DmfAttributeUpdate attributeUpdate;
@JsonProperty @JsonCreator
private String type; public DmfCreateThing(
@JsonProperty("name") final String name,
@JsonProperty @JsonProperty("type") final String type,
private DmfAttributeUpdate attributeUpdate; @JsonProperty("attributeUpdate") final DmfAttributeUpdate attributeUpdate) {
this.name = name;
this.type = type;
this.attributeUpdate = attributeUpdate;
}
} }

View File

@@ -13,43 +13,35 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.ToString;
/** /**
* JSON representation of download and update request. * JSON representation of download and update request.
*/ */
@Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfDownloadAndUpdateRequest extends DmfActionRequest { public class DmfDownloadAndUpdateRequest extends DmfActionRequest {
@Setter private final String targetSecurityToken;
@Getter private final List<DmfSoftwareModule> softwareModules;
@JsonProperty
private String targetSecurityToken;
@JsonProperty @JsonCreator
private List<DmfSoftwareModule> softwareModules; public DmfDownloadAndUpdateRequest(
@JsonProperty("actionId") final Long actionId,
public List<DmfSoftwareModule> getSoftwareModules() { @JsonProperty("targetSecurityToken") final String targetSecurityToken,
if (softwareModules == null) { @JsonProperty("softwareModules") final List<DmfSoftwareModule> softwareModules) {
return Collections.emptyList(); super(actionId);
} this.targetSecurityToken = targetSecurityToken;
this.softwareModules = softwareModules == null ? Collections.emptyList() : Collections.unmodifiableList(softwareModules);
return Collections.unmodifiableList(softwareModules);
}
public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) {
if (softwareModules == null) {
softwareModules = new ArrayList<>();
}
softwareModules.add(createSoftwareModule);
} }
} }

View File

@@ -24,10 +24,7 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfMetadata { public class DmfMetadata {
@JsonProperty
private final String key; private final String key;
@JsonProperty
private final String value; private final String value;
@JsonCreator @JsonCreator

View File

@@ -22,18 +22,16 @@ import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
/** /**
* 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 final List<DmfMultiActionElement> elements;
@JsonCreator @JsonCreator
public DmfMultiActionRequest(final List<DmfMultiActionElement> elements) { public DmfMultiActionRequest(final List<DmfMultiActionElement> elements) {
@@ -45,41 +43,28 @@ public class DmfMultiActionRequest {
return elements; return elements;
} }
public void addElement(final DmfMultiActionElement element) {
if (elements == null) {
elements = new ArrayList<>();
}
elements.add(element);
}
public void addElement(final EventTopic topic, final DmfActionRequest action, final int weight) {
final DmfMultiActionElement element = new DmfMultiActionElement();
element.setTopic(topic);
element.setAction(action);
element.setWeight(weight);
addElement(element);
}
/** /**
* Represents an element within a {@link DmfMultiActionRequest}. * Represents an element within a {@link DmfMultiActionRequest}.
*/ */
@Data @Data
public static class DmfMultiActionElement { public static class DmfMultiActionElement {
@JsonProperty private final EventTopic topic;
private EventTopic topic; private final DmfActionRequest action;
private final int weight;
@JsonProperty @JsonCreator
private DmfActionRequest action; public DmfMultiActionElement(
@JsonProperty("topic") final EventTopic topic,
@JsonProperty @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "topic", defaultImpl = DmfActionRequest.class)
private int weight; @JsonSubTypes({
@Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD"),
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "topic", defaultImpl = DmfActionRequest.class) @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD_AND_INSTALL") })
@JsonSubTypes({ @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD"), @JsonProperty("action") final DmfActionRequest action,
@Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD_AND_INSTALL") }) @JsonProperty("weight") final int weight) {
public void setAction(final DmfActionRequest action) { this.topic = topic;
this.action = action; this.action = action;
this.weight = weight;
} }
} }
} }

View File

@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.dmf.json.model;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -26,30 +27,26 @@ import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfSoftwareModule { public class DmfSoftwareModule {
@JsonProperty private final Long moduleId;
private Long moduleId; private final String moduleType;
@JsonProperty private final String moduleVersion;
private String moduleType; private final Boolean encrypted;
@JsonProperty private final List<DmfArtifact> artifacts;
private String moduleVersion; private final List<DmfMetadata> metadata;
@JsonProperty
private Boolean encrypted;
@JsonProperty
private List<DmfArtifact> artifacts;
@JsonProperty
private List<DmfMetadata> metadata;
public List<DmfArtifact> getArtifacts() { @JsonCreator
if (artifacts == null) { public DmfSoftwareModule(
return Collections.emptyList(); @JsonProperty("moduleId") final Long moduleId,
} @JsonProperty("moduleType") final String moduleType,
@JsonProperty("moduleVersion") final String moduleVersion,
return Collections.unmodifiableList(artifacts); @JsonProperty("encrypted") final Boolean encrypted,
} @JsonProperty("artifacts") final List<DmfArtifact> artifacts,
@JsonProperty("metadata") final List<DmfMetadata> metadata) {
public void setMetadata(final List<DmfMetadata> metadata) { this.moduleId = moduleId;
if (metadata != null && !metadata.isEmpty()) { this.moduleType = moduleType;
this.metadata = metadata; this.moduleVersion = moduleVersion;
} this.encrypted = encrypted;
this.artifacts = artifacts == null ? Collections.emptyList() : Collections.unmodifiableList(artifacts);
this.metadata = metadata == null || metadata.isEmpty() ? null : metadata;
} }
} }

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.dmf.json.model; package org.eclipse.hawkbit.dmf.json.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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;
@@ -24,11 +25,18 @@ import lombok.ToString;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DmfTarget { public class DmfTarget {
@JsonProperty private final Long actionId;
private Long actionId; private final String controllerId;
@JsonProperty
private String controllerId;
@ToString.Exclude @ToString.Exclude
@JsonProperty private final String targetSecurityToken;
private String targetSecurityToken;
@JsonCreator
public DmfTarget(
@JsonProperty("actionId") final Long actionId,
@JsonProperty("controllerId") final String controllerId,
@JsonProperty("targetSecurityToken") final String targetSecurityToken) {
this.actionId = actionId;
this.controllerId = controllerId;
this.targetSecurityToken = targetSecurityToken;
}
} }

View File

@@ -9,14 +9,11 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model; package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.RepresentationModel;
/** /**
@@ -28,34 +25,20 @@ import org.springframework.hateoas.RepresentationModel;
@ToString(callSuper = true) @ToString(callSuper = true)
public abstract class MgmtBaseEntity extends RepresentationModel<MgmtBaseEntity> { public abstract class MgmtBaseEntity extends RepresentationModel<MgmtBaseEntity> {
@JsonProperty
@Schema(description = "Entity was originally created by (User, AMQP-Controller, anonymous etc.)", @Schema(description = "Entity was originally created by (User, AMQP-Controller, anonymous etc.)",
accessMode = Schema.AccessMode.READ_ONLY, example = "bumlux") accessMode = Schema.AccessMode.READ_ONLY, example = "bumlux")
private String createdBy; private String createdBy;
@JsonProperty
@Schema(description = "Entity was originally created at (timestamp UTC in milliseconds)", @Schema(description = "Entity was originally created at (timestamp UTC in milliseconds)",
accessMode = Schema.AccessMode.READ_ONLY, example = "1691065905897") accessMode = Schema.AccessMode.READ_ONLY, example = "1691065905897")
private Long createdAt; private Long createdAt;
@JsonProperty
@Schema(description = "Entity was last modified by (User, AMQP-Controller, anonymous etc.)", @Schema(description = "Entity was last modified by (User, AMQP-Controller, anonymous etc.)",
accessMode = Schema.AccessMode.READ_ONLY, example = "bumlux") accessMode = Schema.AccessMode.READ_ONLY, example = "bumlux")
private String lastModifiedBy; private String lastModifiedBy;
@JsonProperty
@Schema(description = "Entity was last modified at (timestamp UTC in milliseconds)", @Schema(description = "Entity was last modified at (timestamp UTC in milliseconds)",
accessMode = Schema.AccessMode.READ_ONLY, example = "1691065906407") accessMode = Schema.AccessMode.READ_ONLY, example = "1691065906407")
@EqualsAndHashCode.Exclude @EqualsAndHashCode.Exclude
private Long lastModifiedAt; private Long lastModifiedAt;
/**
* Added for backwards compatibility
*
* @return the unique identifier of the {@link MgmtBaseEntity}.
*/
@JsonIgnore
public Link getId() {
return this.getRequiredLink("self");
}
} }

View File

@@ -14,7 +14,6 @@ import java.util.concurrent.TimeUnit;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
@@ -34,6 +33,5 @@ public class MgmtMaintenanceWindow extends MgmtMaintenanceWindowRequestBody {
/** /**
* Time in {@link TimeUnit#MILLISECONDS} of the next maintenance window start * Time in {@link TimeUnit#MILLISECONDS} of the next maintenance window start
*/ */
@JsonProperty
private long nextStartAt; private long nextStartAt;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -30,17 +29,14 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtMaintenanceWindowRequestBody { public class MgmtMaintenanceWindowRequestBody {
@JsonProperty
@Schema(description = """ @Schema(description = """
Schedule for the maintenance window start in quartz cron notation, such as '0 15 10 * * ? 2018' Schedule for the maintenance window start in quartz cron notation, such as '0 15 10 * * ? 2018'
for 10:15am every day during the year 2018""", example = "10 12 14 3 8 ? 2023") for 10:15am every day during the year 2018""", example = "10 12 14 3 8 ? 2023")
private String schedule; private String schedule;
@JsonProperty
@Schema(description = "Duration of the window, such as '02:00:00' for 2 hours", example = "00:10:00") @Schema(description = "Duration of the window, such as '02:00:00' for 2 hours", example = "00:10:00")
private String duration; private String duration;
@JsonProperty
@Schema(description = "A time-zone offset from Greenwich/UTC, such as '+02:00'", example = "+00:00") @Schema(description = "A time-zone offset from Greenwich/UTC, such as '+02:00'", example = "+00:00")
private String timezone; private String timezone;
} }

View File

@@ -32,7 +32,6 @@ public class MgmtMetadata {
@Schema(description = "Metadata property key", example = "someKnownKey") @Schema(description = "Metadata property key", example = "someKnownKey")
private String key; private String key;
@JsonProperty
@Schema(description = "Metadata property value", example = "someKnownKeyValue") @Schema(description = "Metadata property value", example = "someKnownKeyValue")
private String value; private String value;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -28,7 +27,6 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtMetadataBodyPut { public class MgmtMetadataBodyPut {
@JsonProperty
@Schema(example = "someValue") @Schema(example = "someValue")
private String value; private String value;
} }

View File

@@ -29,7 +29,6 @@ public abstract class MgmtNamedEntity extends MgmtBaseEntity {
@Schema(example = "Name of entity") @Schema(example = "Name of entity")
private String name; private String name;
@JsonProperty
@Schema(example = "Description of entity") @Schema(example = "Description of entity")
private String description; private String description;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -28,15 +27,12 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtPollStatus { public class MgmtPollStatus {
@JsonProperty
@Schema(example = "1691065941102") @Schema(example = "1691065941102")
private Long lastRequestAt; private Long lastRequestAt;
@JsonProperty
@Schema(example = "1691109141102") @Schema(example = "1691109141102")
private Long nextExpectedRequestAt; private Long nextExpectedRequestAt;
@JsonProperty
@Schema(example = "false") @Schema(example = "false")
private boolean overdue; private boolean overdue;
} }

View File

@@ -29,12 +29,10 @@ public abstract class MgmtTypeEntity extends MgmtNamedEntity {
@Schema(description = "Key that can be interpreted by the target", example = "id.t23") @Schema(description = "Key that can be interpreted by the target", example = "id.t23")
private String key; private String key;
@JsonProperty
@Schema(description = "Colour assigned to the entity that could be used for representation purposes", @Schema(description = "Colour assigned to the entity that could be used for representation purposes",
example = "brown") example = "brown")
private String colour; private String colour;
@JsonProperty
@Schema(description = "Deleted flag, used for soft deleted entities", example = "false") @Schema(description = "Deleted flag, used for soft deleted entities", example = "false")
private boolean deleted; private boolean deleted;
} }

View File

@@ -39,12 +39,8 @@ import org.springframework.hateoas.RepresentationModel;
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
public class PagedList<T> extends RepresentationModel<PagedList<T>> { public class PagedList<T> extends RepresentationModel<PagedList<T>> {
@JsonProperty
private final List<T> content; private final List<T> content;
@JsonProperty
private final long total; private final long total;
private final int size; private final int size;
/** /**

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model.action;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -84,52 +83,33 @@ public class MgmtAction extends MgmtBaseEntity {
*/ */
public static final String ACTION_PENDING = "pending"; public static final String ACTION_PENDING = "pending";
@JsonProperty("id")
@Schema(description = "ID of the action", example = "7") @Schema(description = "ID of the action", example = "7")
private Long actionId; private Long id;
@JsonProperty
@Schema(description = "Type of action", example = "update") @Schema(description = "Type of action", example = "update")
private String type; private String type;
@JsonProperty
@Schema(description = "Status of action", example = "finished") @Schema(description = "Status of action", example = "finished")
private String status; private String status;
@JsonProperty
@Schema(description = "Detailed status of action", example = "finished") @Schema(description = "Detailed status of action", example = "finished")
private String detailStatus; private String detailStatus;
@JsonProperty
@Schema(example = "1691065903238") @Schema(example = "1691065903238")
private Long forceTime; private Long forceTime;
private MgmtActionType forceType;
@JsonProperty(value = "forceType")
private MgmtActionType actionType;
@JsonProperty
@Schema(description = "Weight of the action showing the importance of the update", example = "600") @Schema(description = "Weight of the action showing the importance of the update", example = "600")
private Integer weight; private Integer weight;
@JsonProperty
@Schema(hidden = true) @Schema(hidden = true)
private MgmtMaintenanceWindow maintenanceWindow; private MgmtMaintenanceWindow maintenanceWindow;
@JsonProperty
@Schema(description = "The ID of the rollout this action was created for", example = "1") @Schema(description = "The ID of the rollout this action was created for", example = "1")
private Long rollout; private Long rollout;
@JsonProperty
@Schema(description = "The name of the rollout this action was created for", example = "rollout") @Schema(description = "The name of the rollout this action was created for", example = "rollout")
private String rolloutName; private String rolloutName;
@JsonProperty
@Schema(description = "(Optional) Code provided as part of the last status update that was sent by the device.", @Schema(description = "(Optional) Code provided as part of the last status update that was sent by the device.",
example = "200") example = "200")
private Integer lastStatusCode; private Integer lastStatusCode;
@JsonProperty
@Schema(description = "If created by external system this field contains the external reference for the action") @Schema(description = "If created by external system this field contains the external reference for the action")
private String externalRef; private String externalRef;
} }

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model.action; package org.eclipse.hawkbit.mgmt.json.model.action;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@@ -23,6 +22,5 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
@ToString @ToString
public class MgmtActionRequestBodyPut { public class MgmtActionRequestBodyPut {
@JsonProperty(value = "forceType") private MgmtActionType forceType;
private MgmtActionType actionType;
} }

View File

@@ -14,7 +14,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@@ -28,26 +27,20 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtActionStatus { public class MgmtActionStatus {
@JsonProperty("id")
@Schema(example = "21") @Schema(example = "21")
private Long statusId; private Long id;
@JsonProperty
@Schema(example = "running") @Schema(example = "running")
private String type; private String type;
@JsonProperty
private List<String> messages; private List<String> messages;
@JsonProperty
@Schema(example = "1691065929524") @Schema(example = "1691065929524")
private Long reportedAt; private Long reportedAt;
@JsonProperty
@Schema(example = "1691065929524") @Schema(example = "1691065929524")
private Long timestamp; private Long timestamp;
@JsonProperty
@Schema(example = "200") @Schema(example = "200")
private Integer code; private Integer code;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model.artifact;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -57,18 +56,14 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity;
}""") }""")
public class MgmtArtifact extends MgmtBaseEntity { public class MgmtArtifact extends MgmtBaseEntity {
@JsonProperty("id")
@Schema(description = "Artifact id", example = "3") @Schema(description = "Artifact id", example = "3")
private Long artifactId; private Long id;
@JsonProperty
private MgmtArtifactHash hashes; private MgmtArtifactHash hashes;
@JsonProperty
@Schema(example = "file1") @Schema(example = "file1")
private String providedFilename; private String providedFilename;
@JsonProperty
@Schema(description = "Size of the artifact", example = "3") @Schema(description = "Size of the artifact", example = "3")
private Long size; private Long size;
} }

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model.artifact; package org.eclipse.hawkbit.mgmt.json.model.artifact;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@@ -25,15 +24,10 @@ import lombok.ToString;
@ToString @ToString
public class MgmtArtifactHash { public class MgmtArtifactHash {
@JsonProperty
@Schema(description = "SHA1 hash of the artifact", example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05") @Schema(description = "SHA1 hash of the artifact", example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05")
private String sha1; private String sha1;
@JsonProperty
@Schema(description = "MD5 hash of the artifact.", example = "0d1b08c34858921bc7c662b228acb7ba") @Schema(description = "MD5 hash of the artifact.", example = "0d1b08c34858921bc7c662b228acb7ba")
private String md5; private String md5;
@JsonProperty
@Schema(description = "SHA256 hash of the artifact", example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615") @Schema(description = "SHA256 hash of the artifact", example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615")
private String sha256; private String sha256;

View File

@@ -14,7 +14,6 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -46,18 +45,17 @@ import org.springframework.hateoas.RepresentationModel;
}""") }""")
public class MgmtActionId extends RepresentationModel<MgmtActionId> { public class MgmtActionId extends RepresentationModel<MgmtActionId> {
@JsonProperty("id")
@Schema(description = "ID of the action") @Schema(description = "ID of the action")
private long actionId; private long id;
/** /**
* Constructor * Constructor
* *
* @param actionId the actionId
* @param controllerId the controller Id * @param controllerId the controller Id
* @param id the actionId
*/ */
public MgmtActionId(final String controllerId, final long actionId) { public MgmtActionId(final String controllerId, final long id) {
this.actionId = actionId; this.id = id;
add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, actionId)).withSelfRel().expand()); add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, id)).withSelfRel().expand());
} }
} }

View File

@@ -133,47 +133,38 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
}""") }""")
public class MgmtDistributionSet extends MgmtNamedEntity { public class MgmtDistributionSet extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "51") @Schema(description = "The technical identifier of the entity", example = "51")
private Long dsId; private Long id;
@JsonProperty
@Schema(description = "Package version", example = "1.4.2") @Schema(description = "Package version", example = "1.4.2")
private String version; private String version;
@JsonProperty
@Schema(description = "The type of the distribution set", example = "test_default_ds_type") @Schema(description = "The type of the distribution set", example = "test_default_ds_type")
private String type; private String type;
@JsonProperty
@Schema(description = "The type name of the distribution set", @Schema(description = "The type name of the distribution set",
example = "OS (FW) mandatory, runtime (FW) and app (SW) optional") example = "OS (FW) mandatory, runtime (FW) and app (SW) optional")
private String typeName; private String typeName;
@JsonProperty
@Schema(description = """ @Schema(description = """
True of the distribution set software module setup is complete as defined by the True of the distribution set software module setup is complete as defined by the
distribution set type""", example = "true") distribution set type""", example = "true")
private Boolean complete; private Boolean complete;
@JsonProperty
@Schema(description = "If the distribution set is locked", example = "true") @Schema(description = "If the distribution set is locked", example = "true")
private boolean locked; private boolean locked;
@JsonProperty
@Schema(description = "Deleted flag, used for soft deleted entities", example = "false") @Schema(description = "Deleted flag, used for soft deleted entities", example = "false")
private boolean deleted; private boolean deleted;
@JsonProperty
@Schema(description = "True by default and false after the distribution set is invalidated by the user", example = "true") @Schema(description = "True by default and false after the distribution set is invalidated by the user", example = "true")
private boolean valid; private boolean valid;
@JsonProperty
@Schema(description = """ @Schema(description = """
True if DS is a required migration step for another DS. As a result the DSs assignment will not be cancelled True if DS is a required migration step for another DS. As a result the DSs assignment will not be cancelled
when another DS is assigned (note: updatable only if DS is not yet assigned to a target)""", example = "false") when another DS is assigned (note: updatable only if DS is not yet assigned to a target)""", example = "false")
private boolean requiredMigrationStep; private boolean requiredMigrationStep;
@JsonProperty
private List<MgmtSoftwareModule> modules = new ArrayList<>(); private List<MgmtSoftwareModule> modules = new ArrayList<>();
} }

View File

@@ -14,7 +14,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -34,23 +33,18 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssi
public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut { public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut {
// deprecated format from the times where os, application and runtime where statically defined // deprecated format from the times where os, application and runtime where statically defined
@JsonProperty
@Schema(hidden = true) @Schema(hidden = true)
private MgmtSoftwareModuleAssignment os; private MgmtSoftwareModuleAssignment os;
@JsonProperty
@Schema(hidden = true) @Schema(hidden = true)
private MgmtSoftwareModuleAssignment runtime; private MgmtSoftwareModuleAssignment runtime;
@JsonProperty
@Schema(hidden = true) @Schema(hidden = true)
private MgmtSoftwareModuleAssignment application; private MgmtSoftwareModuleAssignment application;
// deprecated format - END // deprecated format - END
@JsonProperty
private List<MgmtSoftwareModuleAssignment> modules; private List<MgmtSoftwareModuleAssignment> modules;
@JsonProperty
@Schema(description = "The type of the distribution set", example = "test_default_ds_type") @Schema(description = "The type of the distribution set", example = "test_default_ds_type")
private String type; private String type;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@@ -26,19 +25,15 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetRequestBodyPut { public class MgmtDistributionSetRequestBodyPut {
@JsonProperty
@Schema(description = "The name of the entity", example = "dsOne") @Schema(description = "The name of the entity", example = "dsOne")
private String name; private String name;
@JsonProperty
@Schema(description = "The description of the entity", example = "Description of the distribution set.") @Schema(description = "The description of the entity", example = "Description of the distribution set.")
private String description; private String description;
@JsonProperty
@Schema(description = "Package version", example = "1.0.0") @Schema(description = "Package version", example = "1.0.0")
private String version; private String version;
@JsonProperty
@Schema(description = """ @Schema(description = """
Should be set only if change of locked state is requested. If put, the distribution set locked flag will be Should be set only if change of locked state is requested. If put, the distribution set locked flag will be
set to the requested. Note: unlock (i.e. set this property to false) with extreme care! set to the requested. Note: unlock (i.e. set this property to false) with extreme care!
@@ -47,7 +42,6 @@ public class MgmtDistributionSetRequestBodyPut {
example = "true") example = "true")
private Boolean locked; private Boolean locked;
@JsonProperty
@Schema(description = """ @Schema(description = """
True if DS is a required migration step for another DS. As a result the DSs assignment will not be cancelled True if DS is a required migration step for another DS. As a result the DSs assignment will not be cancelled
when another DS is assigned (note: updatable only if DS is not yet assigned to a target)""", example = "false") when another DS is assigned (note: updatable only if DS is not yet assigned to a target)""", example = "false")

View File

@@ -15,7 +15,6 @@ import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
@@ -32,13 +31,12 @@ public class MgmtDistributionSetStatistics {
private static final String TOTAL = "total"; private static final String TOTAL = "total";
@JsonProperty("actions") // totalActionsPerStatus
private Map<String, Long> totalActionsPerStatus; private Map<String, Long> actions;
@JsonProperty("rollouts") // totalRolloutsPerStatus
private Map<String, Long> totalRolloutsPerStatus; private Map<String, Long> rollouts;
@JsonProperty
private Long totalAutoAssignments; private Long totalAutoAssignments;
public static class Builder { public static class Builder {
@@ -71,8 +69,8 @@ public class MgmtDistributionSetStatistics {
public MgmtDistributionSetStatistics build() { public MgmtDistributionSetStatistics build() {
MgmtDistributionSetStatistics statistics = new MgmtDistributionSetStatistics(); MgmtDistributionSetStatistics statistics = new MgmtDistributionSetStatistics();
statistics.totalActionsPerStatus = calculateTotalWithStatus(totalActionsPerStatus); statistics.actions = calculateTotalWithStatus(totalActionsPerStatus);
statistics.totalRolloutsPerStatus = calculateTotalWithStatus(totalRolloutsPerStatus); statistics.rollouts = calculateTotalWithStatus(totalRolloutsPerStatus);
statistics.totalAutoAssignments = calculateTotalAutoAssignments(); statistics.totalAutoAssignments = calculateTotalAutoAssignments();
return statistics; return statistics;
} }

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.mgmt.json.model.distributionset;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@@ -24,11 +23,9 @@ import lombok.experimental.Accessors;
public class MgmtInvalidateDistributionSetRequestBody { public class MgmtInvalidateDistributionSetRequestBody {
@NotNull @NotNull
@JsonProperty
@Schema(description = "Type of cancelation for actions referring to the given distribution set") @Schema(description = "Type of cancelation for actions referring to the given distribution set")
private MgmtCancelationType actionCancelationType; private MgmtCancelationType actionCancelationType;
@JsonProperty
@Schema(description = "Defines if rollouts referring to this distribution set should be canceled", example = "true") @Schema(description = "Defines if rollouts referring to this distribution set should be canceled", example = "true")
private boolean cancelRollouts; private boolean cancelRollouts;
} }

View File

@@ -34,7 +34,7 @@ import org.springframework.hateoas.RepresentationModel;
public class MgmtTargetAssignmentResponseBody extends RepresentationModel<MgmtTargetAssignmentResponseBody> { public class MgmtTargetAssignmentResponseBody extends RepresentationModel<MgmtTargetAssignmentResponseBody> {
@Schema(description = """ @Schema(description = """
Targets that had this distribution set already assigned (in "offline" case this includes Targets that had this distribution already assigned (in "offline" case this includes
targets that have arbitrary updates running)""") targets that have arbitrary updates running)""")
private int alreadyAssigned; private int alreadyAssigned;
@@ -44,6 +44,7 @@ public class MgmtTargetAssignmentResponseBody extends RepresentationModel<MgmtTa
/** /**
* @return the count of assigned targets * @return the count of assigned targets
*/ */
@Schema(description = "Targets that had this distribution set really assigned excluding already assigned")
@JsonProperty("assigned") @JsonProperty("assigned")
public int getAssigned() { public int getAssigned() {
return assignedActions == null ? 0 : assignedActions.size(); return assignedActions == null ? 0 : assignedActions.size();
@@ -52,6 +53,7 @@ public class MgmtTargetAssignmentResponseBody extends RepresentationModel<MgmtTa
/** /**
* @return the total * @return the total
*/ */
@Schema(description = "Total targets")
@JsonProperty("total") @JsonProperty("total")
public int getTotal() { public int getTotal() {
return getAssigned() + alreadyAssigned; return getAssigned() + alreadyAssigned;

View File

@@ -60,7 +60,7 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
}""") }""")
public class MgmtDistributionSetType extends MgmtTypeEntity { public class MgmtDistributionSetType extends MgmtTypeEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "99") @Schema(description = "The technical identifier of the entity", example = "99")
private Long moduleId; private Long id;
} }

View File

@@ -36,11 +36,9 @@ public class MgmtDistributionSetTypeRequestBodyPost extends MgmtDistributionSetT
@Schema(description = "Functional key of the distribution set type", example = "Example key") @Schema(description = "Functional key of the distribution set type", example = "Example key")
private String key; private String key;
@JsonProperty
@Schema(description = "Mandatory module type IDs") @Schema(description = "Mandatory module type IDs")
private List<MgmtSoftwareModuleTypeAssignment> mandatorymodules; private List<MgmtSoftwareModuleTypeAssignment> mandatorymodules;
@JsonProperty
@Schema(description = "Optional module type IDs") @Schema(description = "Optional module type IDs")
private List<MgmtSoftwareModuleTypeAssignment> optionalmodules; private List<MgmtSoftwareModuleTypeAssignment> optionalmodules;

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model.distributionsettype; package org.eclipse.hawkbit.mgmt.json.model.distributionsettype;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -23,11 +22,9 @@ import lombok.experimental.Accessors;
@ToString @ToString
public class MgmtDistributionSetTypeRequestBodyPut { public class MgmtDistributionSetTypeRequestBodyPut {
@JsonProperty
@Schema(description = "The description of the entity", example = "Example description") @Schema(description = "The description of the entity", example = "Example description")
private String description; private String description;
@JsonProperty
@Schema(description = "The colour of the entity", example = "rgb(86,37,99)") @Schema(description = "The colour of the entity", example = "rgb(86,37,99)")
private String colour; private String colour;
} }

View File

@@ -101,16 +101,16 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
}""") }""")
public class MgmtRolloutResponseBody extends MgmtNamedEntity { public class MgmtRolloutResponseBody extends MgmtNamedEntity {
@JsonProperty(required = true)
@Schema(description = "Rollout id", example = "2")
private Long id;
@Schema(description = "Target filter query language expression", example = "controllerId==exampleTarget*") @Schema(description = "Target filter query language expression", example = "controllerId==exampleTarget*")
private String targetFilterQuery; private String targetFilterQuery;
@Schema(description = "The ID of distribution set of this rollout", example = "2") @Schema(description = "The ID of distribution set of this rollout", example = "2")
private Long distributionSetId; private Long distributionSetId;
@JsonProperty(value = "id", required = true)
@Schema(description = "Rollout id", example = "2")
private Long rolloutId;
@JsonProperty(required = true) @JsonProperty(required = true)
@Schema(description = "The status of this rollout", example = "ready") @Schema(description = "The status of this rollout", example = "ready")
private String status; private String status;
@@ -120,43 +120,33 @@ public class MgmtRolloutResponseBody extends MgmtNamedEntity {
private Long totalTargets; private Long totalTargets;
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
@JsonProperty
@Schema(description = "The total targets per status") @Schema(description = "The total targets per status")
private Map<String, Long> totalTargetsPerStatus; private Map<String, Long> totalTargetsPerStatus;
@JsonProperty
@Schema(description = "The total number of groups created by this rollout", example = "5") @Schema(description = "The total number of groups created by this rollout", example = "5")
private Integer totalGroups; private Integer totalGroups;
@JsonProperty
@Schema(description = "Start at timestamp of Rollout", example = "1691065753136") @Schema(description = "Start at timestamp of Rollout", example = "1691065753136")
private Long startAt; private Long startAt;
@JsonProperty
@Schema(description = "Forcetime in milliseconds", example = "1691065762496") @Schema(description = "Forcetime in milliseconds", example = "1691065762496")
private Long forcetime; private Long forcetime;
@JsonProperty
@Schema(description = "Deleted flag, used for soft deleted entities", example = "false") @Schema(description = "Deleted flag, used for soft deleted entities", example = "false")
private boolean deleted; private boolean deleted;
@JsonProperty
@Schema(description = "The type of this rollout") @Schema(description = "The type of this rollout")
private MgmtActionType type; private MgmtActionType type;
@JsonProperty
@Schema(description = "Weight of the resulting Actions", example = "400") @Schema(description = "Weight of the resulting Actions", example = "400")
private Integer weight; private Integer weight;
@JsonProperty
@Schema(description = "If this rollout is dynamic or static", example = "true") @Schema(description = "If this rollout is dynamic or static", example = "true")
private boolean dynamic; private boolean dynamic;
@JsonProperty
@Schema(example = "Approved remark.") @Schema(example = "Approved remark.")
private String approvalRemark; private String approvalRemark;
@JsonProperty
@Schema(example = "exampleUsername") @Schema(example = "exampleUsername")
private String approveDecidedBy; private String approveDecidedBy;

View File

@@ -14,7 +14,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -79,19 +78,15 @@ public class MgmtRolloutRestRequestBodyPost extends AbstractMgmtRolloutCondition
@Schema(description = "Start at timestamp of Rollout", example = "1691065780929") @Schema(description = "Start at timestamp of Rollout", example = "1691065780929")
private Long startAt; private Long startAt;
@JsonProperty
@Schema(description = "Weight of the resulting Actions", example = "400") @Schema(description = "Weight of the resulting Actions", example = "400")
private Integer weight; private Integer weight;
@JsonProperty
@Schema(example = "true") @Schema(example = "true")
private boolean dynamic; private boolean dynamic;
@JsonProperty
@Schema(description = "Template for dynamic groups (only if dynamic flag is true)") @Schema(description = "Template for dynamic groups (only if dynamic flag is true)")
private MgmtDynamicRolloutGroupTemplate dynamicGroupTemplate; private MgmtDynamicRolloutGroupTemplate dynamicGroupTemplate;
@JsonProperty
@Schema(description = """ @Schema(description = """
(Available with user consent flow active) If the confirmation is required for this rollout. Value will be used (Available with user consent flow active) If the confirmation is required for this rollout. Value will be used
if confirmation options are missing in the rollout group definitions. Confirmation is required per default""", if confirmation options are missing in the rollout group definitions. Confirmation is required per default""",

View File

@@ -80,14 +80,13 @@ import lombok.experimental.Accessors;
}""") }""")
public class MgmtRolloutGroupResponseBody extends MgmtRolloutGroup { public class MgmtRolloutGroupResponseBody extends MgmtRolloutGroup {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "Rollouts id", example = "63") @Schema(description = "Rollouts id", example = "63")
private Long rolloutGroupId; private Long id;
@Schema(description = "If the rollout group is dynamic", example = "false") @Schema(description = "If the rollout group is dynamic", example = "false")
private boolean dynamic; private boolean dynamic;
@JsonProperty(required = true)
@Schema(description = "The status of this rollout", example = "ready") @Schema(description = "The status of this rollout", example = "ready")
private String status; private String status;

View File

@@ -67,9 +67,9 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
}""") }""")
public class MgmtSoftwareModule extends MgmtNamedEntity { public class MgmtSoftwareModule extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "6") @Schema(description = "The technical identifier of the entity", example = "6")
private Long moduleId; private Long id;
@JsonProperty(required = true) @JsonProperty(required = true)
@Schema(description = "Package version", example = "1.0.0") @Schema(description = "Package version", example = "1.0.0")
@@ -82,19 +82,15 @@ public class MgmtSoftwareModule extends MgmtNamedEntity {
@Schema(description = "The software module type name of the entity", example = "OS") @Schema(description = "The software module type name of the entity", example = "OS")
private String typeName; private String typeName;
@JsonProperty
@Schema(description = "The software vendor", example = "Vendor Limited, California") @Schema(description = "The software vendor", example = "Vendor Limited, California")
private String vendor; private String vendor;
@JsonProperty
@Schema(description = "If the software module is encrypted", example = "false") @Schema(description = "If the software module is encrypted", example = "false")
private boolean encrypted; private boolean encrypted;
@JsonProperty
@Schema(description = "If the software module is locked", example = "true") @Schema(description = "If the software module is locked", example = "true")
private boolean locked; private boolean locked;
@JsonProperty
@Schema(description = "If the software module is deleted", example = "false") @Schema(description = "If the software module is deleted", example = "false")
private boolean deleted; private boolean deleted;
} }

View File

@@ -32,12 +32,9 @@ public class MgmtSoftwareModuleMetadata {
@Schema(description = "Metadata property key", example = "someKnownKey") @Schema(description = "Metadata property key", example = "someKnownKey")
private String key; private String key;
@JsonProperty
@Schema(description = "Metadata property value", example = "someKnownValue") @Schema(description = "Metadata property value", example = "someKnownValue")
private String value; private String value;
@JsonProperty @Schema(description = "Metadata property is visible to targets as part of software update action", example = "false")
@Schema(description = "Metadata property is visible to targets as part of software update action",
example = "false")
private boolean targetVisible; private boolean targetVisible;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model.softwaremodule;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -28,11 +27,9 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSoftwareModuleMetadataBodyPut { public class MgmtSoftwareModuleMetadataBodyPut {
@JsonProperty
@Schema(example = "newValue") @Schema(example = "newValue")
private String value; private String value;
@JsonProperty
@Schema(example = "true") @Schema(example = "true")
private Boolean targetVisible; private Boolean targetVisible;
} }

View File

@@ -35,15 +35,12 @@ public class MgmtSoftwareModuleRequestBodyPost {
@Schema(example = "os") @Schema(example = "os")
private String type; private String type;
@JsonProperty
@Schema(example = "SM Description") @Schema(example = "SM Description")
private String description; private String description;
@JsonProperty
@Schema(example = "Vendor Limited, California") @Schema(example = "Vendor Limited, California")
private String vendor; private String vendor;
@JsonProperty
@Schema(example = "false") @Schema(example = "false")
private boolean encrypted; private boolean encrypted;
} }

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model.softwaremodule; package org.eclipse.hawkbit.mgmt.json.model.softwaremodule;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -23,15 +22,12 @@ import lombok.experimental.Accessors;
@ToString @ToString
public class MgmtSoftwareModuleRequestBodyPut { public class MgmtSoftwareModuleRequestBodyPut {
@JsonProperty
@Schema(example = "SM Description") @Schema(example = "SM Description")
private String description; private String description;
@JsonProperty
@Schema(example = "SM Vendor Name") @Schema(example = "SM Vendor Name")
private String vendor; private String vendor;
@JsonProperty
@Schema(description = """ @Schema(description = """
Should be set only if change of locked state is requested. If put, the software module locked flag will be Should be set only if change of locked state is requested. If put, the software module locked flag will be
set to the requested. Note: unlock (i.e. set this property to false) with extreme care! set to the requested. Note: unlock (i.e. set this property to false) with extreme care!

View File

@@ -50,11 +50,10 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
}""") }""")
public class MgmtSoftwareModuleType extends MgmtTypeEntity { public class MgmtSoftwareModuleType extends MgmtTypeEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "83") @Schema(description = "The technical identifier of the entity", example = "83")
private Long moduleId; private Long id;
@JsonProperty
@Schema(description = "Software modules of that type can be assigned at this maximum number " + @Schema(description = "Software modules of that type can be assigned at this maximum number " +
"(e.g. operating system only once)", example = "1") "(e.g. operating system only once)", example = "1")
private int maxAssignments; private int maxAssignments;

View File

@@ -33,7 +33,6 @@ public class MgmtSoftwareModuleTypeRequestBodyPost extends MgmtSoftwareModuleTyp
@Schema(example = "Example key") @Schema(example = "Example key")
private String key; private String key;
@JsonProperty
@Schema(example = "1") @Schema(example = "1")
private int maxAssignments; private int maxAssignments;

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -23,11 +22,9 @@ import lombok.experimental.Accessors;
@ToString @ToString
public class MgmtSoftwareModuleTypeRequestBodyPut { public class MgmtSoftwareModuleTypeRequestBodyPut {
@JsonProperty
@Schema(example = "Example description") @Schema(example = "Example description")
private String description; private String description;
@JsonProperty
@Schema(example = "rgb(0,0,255") @Schema(example = "rgb(0,0,255")
private String colour; private String colour;
} }

View File

@@ -14,7 +14,6 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@@ -27,21 +26,15 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSystemStatisticsRest { public class MgmtSystemStatisticsRest {
@JsonProperty
private long overallTargets; private long overallTargets;
@JsonProperty
private long overallArtifacts; private long overallArtifacts;
@JsonProperty
private long overallArtifactVolumeInBytes; private long overallArtifactVolumeInBytes;
@JsonProperty
private long overallActions; private long overallActions;
@JsonProperty
private long overallTenants; private long overallTenants;
@JsonProperty
private List<MgmtSystemTenantServiceUsage> tenantStats; private List<MgmtSystemTenantServiceUsage> tenantStats;
} }

View File

@@ -14,7 +14,6 @@ import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@@ -29,21 +28,15 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtSystemTenantServiceUsage { public class MgmtSystemTenantServiceUsage {
@JsonProperty
private String tenantName; private String tenantName;
@JsonProperty
private long targets; private long targets;
@JsonProperty
private long artifacts; private long artifacts;
@JsonProperty
private long actions; private long actions;
@JsonProperty
private long overallArtifactVolumeInBytes; private long overallArtifactVolumeInBytes;
@JsonProperty
private Map<String, String> usageData; private Map<String, String> usageData;
} }

View File

@@ -53,11 +53,10 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
}""") }""")
public class MgmtTag extends MgmtNamedEntity { public class MgmtTag extends MgmtNamedEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "2") @Schema(description = "The technical identifier of the entity", example = "2")
private Long tagId; private Long id;
@JsonProperty
@Schema(description = "The colour of the entity", example = "red") @Schema(description = "The colour of the entity", example = "red")
private String colour; private String colour;
} }

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.json.model.tag;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 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 io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
@@ -28,15 +27,12 @@ import lombok.experimental.Accessors;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtTagRequestBodyPut { public class MgmtTagRequestBodyPut {
@JsonProperty
@Schema(description = "The name of the entity", example = "Example name") @Schema(description = "The name of the entity", example = "Example name")
private String name; private String name;
@JsonProperty
@Schema(description = "The description of the entity", example = "Example description") @Schema(description = "The description of the entity", example = "Example description")
private String description; private String description;
@JsonProperty
@Schema(description = "The colour of the entity", example = "rgb(0,255,0)") @Schema(description = "The colour of the entity", example = "rgb(0,255,0)")
private String colour; private String colour;
} }

View File

@@ -26,11 +26,9 @@ public class MgmtDistributionSetAssignment extends MgmtId {
@Schema(description = "Forcetime in milliseconds", example = "1691065930359") @Schema(description = "Forcetime in milliseconds", example = "1691065930359")
private long forcetime; private long forcetime;
@JsonProperty
@Schema(description = "Importance of the assignment", example = "23") @Schema(description = "Importance of the assignment", example = "23")
private Integer weight; private Integer weight;
@JsonProperty
@Schema(description = """ @Schema(description = """
(Available with user consent flow active) Specifies if the confirmation by the device (Available with user consent flow active) Specifies if the confirmation by the device
is required for this action""", example = "false") is required for this action""", example = "false")

View File

@@ -90,52 +90,41 @@ public class MgmtTarget extends MgmtNamedEntity {
@Schema(description = "Controller ID", example = "123") @Schema(description = "Controller ID", example = "123")
private String controllerId; private String controllerId;
@JsonProperty
@Schema(description = "If the target is in sync", example = "in_sync") @Schema(description = "If the target is in sync", example = "in_sync")
private String updateStatus; private String updateStatus;
@JsonProperty
@Schema(description = "Timestamp of the last controller request", example = "1691065941102") @Schema(description = "Timestamp of the last controller request", example = "1691065941102")
private Long lastControllerRequestAt; private Long lastControllerRequestAt;
@JsonProperty
@Schema(description = "Install timestamp", example = "1691065941155") @Schema(description = "Install timestamp", example = "1691065941155")
private Long installedAt; private Long installedAt;
@JsonProperty
@Schema(description = "Last known IP address of the target. Only presented if IP address of the target " + @Schema(description = "Last known IP address of the target. Only presented if IP address of the target " +
"itself is known (connected directly through DDI API)", example = "192.168.0.1") "itself is known (connected directly through DDI API)", example = "192.168.0.1")
private String ipAddress; private String ipAddress;
@JsonProperty
@Schema(description = "The last known address URI of the target. Includes information of the target is " + @Schema(description = "The last known address URI of the target. Includes information of the target is " +
"connected either directly (DDI) through HTTP or indirectly (DMF) through amqp.", "connected either directly (DDI) through HTTP or indirectly (DMF) through amqp.",
example = "http://192.168.0.1") example = "http://192.168.0.1")
private String address; private String address;
@JsonProperty
@Schema(description = "Poll status") @Schema(description = "Poll status")
private MgmtPollStatus pollStatus; private MgmtPollStatus pollStatus;
@JsonProperty
@Schema(description = "Pre-Shared key that allows targets to authenticate at Direct Device Integration " + @Schema(description = "Pre-Shared key that allows targets to authenticate at Direct Device Integration " +
"API if enabled in the tenant settings", example = "38e6a19932b014040ba061795186514e") "API if enabled in the tenant settings", example = "38e6a19932b014040ba061795186514e")
@ToString.Exclude @ToString.Exclude
private String securityToken; private String securityToken;
@JsonProperty
@Schema(description = "Request re-transmission of target attributes", example = "true") @Schema(description = "Request re-transmission of target attributes", example = "true")
private boolean requestAttributes; private boolean requestAttributes;
@JsonProperty
@Schema(description = "ID of the target type", example = "19") @Schema(description = "ID of the target type", example = "19")
private Long targetType; private Long targetType;
@JsonProperty
@Schema(description = "Name of the target type", example = "defaultType") @Schema(description = "Name of the target type", example = "defaultType")
private String targetTypeName; private String targetTypeName;
@JsonProperty
@Schema(description = "Present if user consent flow active. Indicates if auto-confirm is active", example = "false") @Schema(description = "Present if user consent flow active. Indicates if auto-confirm is active", example = "false")
private Boolean autoConfirmActive; private Boolean autoConfirmActive;
} }

View File

@@ -24,11 +24,9 @@ import lombok.experimental.Accessors;
@ToString @ToString
public class MgmtTargetAutoConfirmUpdate { public class MgmtTargetAutoConfirmUpdate {
@JsonProperty
@Schema(description = "(Optional) Initiator set on activation", example = "custom_initiator_value") @Schema(description = "(Optional) Initiator set on activation", example = "custom_initiator_value")
private final String initiator; private final String initiator;
@JsonProperty
@Schema(description = "(Optional) Remark set on activation", example = "custom_remark") @Schema(description = "(Optional) Remark set on activation", example = "custom_remark")
private final String remark; private final String remark;

View File

@@ -28,22 +28,18 @@ public class MgmtTargetRequestBody {
@Schema(description = "Controller ID", example = "123") @Schema(description = "Controller ID", example = "123")
private String controllerId; private String controllerId;
@JsonProperty
@Schema(description = "The last known address URI of the target. Includes information of the target is " + @Schema(description = "The last known address URI of the target. Includes information of the target is " +
"connected either directly (DDI) through HTTP or indirectly (DMF) through amqp", "connected either directly (DDI) through HTTP or indirectly (DMF) through amqp",
example = "https://192.168.0.1") example = "https://192.168.0.1")
private String address; private String address;
@JsonProperty
@Schema(description = "Pre-Shared key that allows targets to authenticate at Direct Device Integration API if " + @Schema(description = "Pre-Shared key that allows targets to authenticate at Direct Device Integration API if " +
"enabled in the tenant settings", example = "2345678DGGDGFTDzztgf") "enabled in the tenant settings", example = "2345678DGGDGFTDzztgf")
private String securityToken; private String securityToken;
@JsonProperty
@Schema(description = "Request re-transmission of target attributes", example = "true") @Schema(description = "Request re-transmission of target attributes", example = "true")
private Boolean requestAttributes; private Boolean requestAttributes;
@JsonProperty
@Schema(description = "ID of the target type", example = "10") @Schema(description = "ID of the target type", example = "10")
private Long targetType; private Long targetType;
} }

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.mgmt.json.model.targetfilter; package org.eclipse.hawkbit.mgmt.json.model.targetfilter;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
@@ -27,12 +26,9 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
@ToString(callSuper = true) @ToString(callSuper = true)
public class MgmtDistributionSetAutoAssignment extends MgmtId { public class MgmtDistributionSetAutoAssignment extends MgmtId {
@JsonProperty
private MgmtActionType type; private MgmtActionType type;
@JsonProperty
private Integer weight; private Integer weight;
@JsonProperty
private Boolean confirmationRequired; private Boolean confirmationRequired;
} }

View File

@@ -55,31 +55,25 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
}""") }""")
public class MgmtTargetFilterQuery extends MgmtBaseEntity { public class MgmtTargetFilterQuery extends MgmtBaseEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "2") @Schema(description = "The technical identifier of the entity", example = "2")
private Long filterId; private Long id;
@JsonProperty
@Schema(description = "The name of the entity", example = "filterName") @Schema(description = "The name of the entity", example = "filterName")
private String name; private String name;
@JsonProperty
@Schema(description = "Target filter query expression", example = "name==*") @Schema(description = "Target filter query expression", example = "name==*")
private String query; private String query;
@JsonProperty
@Schema(example = "15") @Schema(example = "15")
private Long autoAssignDistributionSet; private Long autoAssignDistributionSet;
@JsonProperty
@Schema(description = "Auto assign distribution set id") @Schema(description = "Auto assign distribution set id")
private MgmtActionType autoAssignActionType; private MgmtActionType autoAssignActionType;
@JsonProperty
@Schema(description = "Weight of the resulting Actions", example = "600") @Schema(description = "Weight of the resulting Actions", example = "600")
private Integer autoAssignWeight; private Integer autoAssignWeight;
@JsonProperty
@Schema(description = "(Available with user consent flow active) Defines, if the confirmation is required for an " + @Schema(description = "(Available with user consent flow active) Defines, if the confirmation is required for an " +
"action. Confirmation is required per default.", example = "false") "action. Confirmation is required per default.", example = "false")
private Boolean confirmationRequired; private Boolean confirmationRequired;

View File

@@ -53,7 +53,7 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity;
}""") }""")
public class MgmtTargetType extends MgmtTypeEntity { public class MgmtTargetType extends MgmtTypeEntity {
@JsonProperty(value = "id", required = true) @JsonProperty(required = true)
@Schema(description = "The technical identifier of the entity", example = "26") @Schema(description = "The technical identifier of the entity", example = "26")
private Long typeId; private Long id;
} }

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.mgmt.json.model.targettype;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -28,11 +27,9 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS
@ToString(callSuper = true) @ToString(callSuper = true)
public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut { public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut {
@JsonProperty
@Schema(description = "Target type key", example = "id.t23") @Schema(description = "Target type key", example = "id.t23")
private String key; private String key;
@JsonProperty
@Schema(description = "Array of distribution set types that are compatible to that target type") @Schema(description = "Array of distribution set types that are compatible to that target type")
private List<MgmtDistributionSetTypeAssignment> compatibledistributionsettypes; private List<MgmtDistributionSetTypeAssignment> compatibledistributionsettypes;
} }

View File

@@ -27,11 +27,9 @@ public class MgmtTargetTypeRequestBodyPut {
@Schema(description = "The name of the entity", example = "updatedTypeName") @Schema(description = "The name of the entity", example = "updatedTypeName")
private String name; private String name;
@JsonProperty
@Schema(description = "The description of the entity", example = "an updated description") @Schema(description = "The description of the entity", example = "an updated description")
private String description; private String description;
@JsonProperty
@Schema(description = "The colour of the entity", example = "#aaafff") @Schema(description = "The colour of the entity", example = "#aaafff")
private String colour; private String colour;
} }

View File

@@ -71,7 +71,7 @@ public final class MgmtDistributionSetMapper {
final MgmtDistributionSet response = new MgmtDistributionSet(); final MgmtDistributionSet response = new MgmtDistributionSet();
MgmtRestModelMapper.mapNamedToNamed(response, distributionSet); MgmtRestModelMapper.mapNamedToNamed(response, distributionSet);
response.setDsId(distributionSet.getId()); response.setId(distributionSet.getId());
response.setVersion(distributionSet.getVersion()); response.setVersion(distributionSet.getVersion());
response.setComplete(distributionSet.isComplete()); response.setComplete(distributionSet.isComplete());
response.setType(distributionSet.getType().getKey()); response.setType(distributionSet.getType().getKey());
@@ -85,14 +85,14 @@ public final class MgmtDistributionSetMapper {
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId())) response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getId()))
.withSelfRel().expand()); .withSelfRel().expand());
return response; return response;
} }
static void addLinks(final DistributionSet distributionSet, final MgmtDistributionSet response) { static void addLinks(final DistributionSet distributionSet, final MgmtDistributionSet response) {
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getAssignedSoftwareModules(response.getDsId(), response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getAssignedSoftwareModules(response.getId(),
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null)) MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null))
.withRel(MgmtRestConstants.DISTRIBUTIONSET_V1_MODULE).expand()); .withRel(MgmtRestConstants.DISTRIBUTIONSET_V1_MODULE).expand());
@@ -100,7 +100,7 @@ public final class MgmtDistributionSetMapper {
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class) response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
.getDistributionSetType(distributionSet.getType().getId())).withRel("type").expand()); .getDistributionSetType(distributionSet.getType().getId())).withRel("type").expand());
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getMetadata(response.getDsId(), response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getMetadata(response.getId(),
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata") MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata")
.expand()); .expand());

View File

@@ -57,9 +57,9 @@ final class MgmtDistributionSetTypeMapper {
final MgmtDistributionSetType result = new MgmtDistributionSetType(); final MgmtDistributionSetType result = new MgmtDistributionSetType();
MgmtRestModelMapper.mapTypeToType(result, type); MgmtRestModelMapper.mapTypeToType(result, type);
result.setModuleId(type.getId()); result.setId(type.getId());
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId())) result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getId()))
.withSelfRel().expand()); .withSelfRel().expand());
return result; return result;
@@ -67,10 +67,10 @@ final class MgmtDistributionSetTypeMapper {
static void addLinks(final MgmtDistributionSetType result) { static void addLinks(final MgmtDistributionSetType result) {
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getModuleId())) result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getId()))
.withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES).expand()); .withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES).expand());
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getOptionalModules(result.getModuleId())) result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getOptionalModules(result.getId()))
.withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULES).expand()); .withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULES).expand());
} }

View File

@@ -78,7 +78,7 @@ final class MgmtRolloutMapper {
body.setLastModifiedAt(rollout.getLastModifiedAt()); body.setLastModifiedAt(rollout.getLastModifiedAt());
body.setLastModifiedBy(rollout.getLastModifiedBy()); body.setLastModifiedBy(rollout.getLastModifiedBy());
body.setName(rollout.getName()); body.setName(rollout.getName());
body.setRolloutId(rollout.getId()); body.setId(rollout.getId());
body.setDynamic(rollout.isDynamic()); body.setDynamic(rollout.isDynamic());
body.setTargetFilterQuery(rollout.getTargetFilterQuery()); body.setTargetFilterQuery(rollout.getTargetFilterQuery());
body.setDistributionSetId(rollout.getDistributionSet().getId()); body.setDistributionSetId(rollout.getDistributionSet().getId());
@@ -217,7 +217,7 @@ final class MgmtRolloutMapper {
body.setLastModifiedAt(rolloutGroup.getLastModifiedAt()); body.setLastModifiedAt(rolloutGroup.getLastModifiedAt());
body.setLastModifiedBy(rolloutGroup.getLastModifiedBy()); body.setLastModifiedBy(rolloutGroup.getLastModifiedBy());
body.setName(rolloutGroup.getName()); body.setName(rolloutGroup.getName());
body.setRolloutGroupId(rolloutGroup.getId()); body.setId(rolloutGroup.getId());
body.setStatus(rolloutGroup.getStatus().toString().toLowerCase()); body.setStatus(rolloutGroup.getStatus().toString().toLowerCase());
body.setTargetPercentage(rolloutGroup.getTargetPercentage()); body.setTargetPercentage(rolloutGroup.getTargetPercentage());
body.setTargetFilterQuery(rolloutGroup.getTargetFilterQuery()); body.setTargetFilterQuery(rolloutGroup.getTargetFilterQuery());

View File

@@ -99,7 +99,7 @@ public final class MgmtSoftwareModuleMapper {
final MgmtSoftwareModule response = new MgmtSoftwareModule(); final MgmtSoftwareModule response = new MgmtSoftwareModule();
MgmtRestModelMapper.mapNamedToNamed(response, softwareModule); MgmtRestModelMapper.mapNamedToNamed(response, softwareModule);
response.setModuleId(softwareModule.getId()); response.setId(softwareModule.getId());
response.setVersion(softwareModule.getVersion()); response.setVersion(softwareModule.getVersion());
response.setType(softwareModule.getType().getKey()); response.setType(softwareModule.getType().getKey());
response.setTypeName(softwareModule.getType().getName()); response.setTypeName(softwareModule.getType().getName());
@@ -108,21 +108,21 @@ public final class MgmtSoftwareModuleMapper {
response.setDeleted(softwareModule.isDeleted()); response.setDeleted(softwareModule.isDeleted());
response.setEncrypted(softwareModule.isEncrypted()); response.setEncrypted(softwareModule.isEncrypted());
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getModuleId())) response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getId()))
.withSelfRel().expand()); .withSelfRel().expand());
return response; return response;
} }
static void addLinks(final SoftwareModule softwareModule, final MgmtSoftwareModule response) { static void addLinks(final SoftwareModule softwareModule, final MgmtSoftwareModule response) {
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getModuleId(), null, null)) response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getId(), null, null))
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT).expand()); .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT).expand());
response.add(linkTo( response.add(linkTo(
methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(softwareModule.getType().getId())) methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(softwareModule.getType().getId()))
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE).expand()); .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE).expand());
response.add(linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getModuleId(), response.add(linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getId(),
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata") MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata")
.expand().expand()); .expand().expand());
@@ -130,7 +130,7 @@ public final class MgmtSoftwareModuleMapper {
static MgmtArtifact toResponse(final Artifact artifact) { static MgmtArtifact toResponse(final Artifact artifact) {
final MgmtArtifact artifactRest = new MgmtArtifact(); final MgmtArtifact artifactRest = new MgmtArtifact();
artifactRest.setArtifactId(artifact.getId()); artifactRest.setId(artifact.getId());
artifactRest.setSize(artifact.getSize()); artifactRest.setSize(artifact.getSize());
artifactRest.setHashes( artifactRest.setHashes(
new MgmtArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash(), artifact.getSha256Hash())); new MgmtArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash(), artifact.getSha256Hash()));

View File

@@ -54,9 +54,9 @@ final class MgmtSoftwareModuleTypeMapper {
MgmtRestModelMapper.mapTypeToType(result, type); MgmtRestModelMapper.mapTypeToType(result, type);
result.setMaxAssignments(type.getMaxAssignments()); result.setMaxAssignments(type.getMaxAssignments());
result.setModuleId(type.getId()); result.setId(type.getId());
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getId()))
.withSelfRel().expand()); .withSelfRel().expand());
return result; return result;

View File

@@ -115,7 +115,7 @@ final class MgmtTagMapper {
private static void mapTag(final MgmtTag response, final Tag tag) { private static void mapTag(final MgmtTag response, final Tag tag) {
MgmtRestModelMapper.mapNamedToNamed(response, tag); MgmtRestModelMapper.mapNamedToNamed(response, tag);
response.setTagId(tag.getId()); response.setId(tag.getId());
response.setColour(tag.getColour()); response.setColour(tag.getColour());
} }
} }

View File

@@ -14,7 +14,6 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -49,7 +48,7 @@ public final class MgmtTargetFilterQueryMapper {
static MgmtTargetFilterQuery toResponse(final TargetFilterQuery filter, final boolean confirmationFlowEnabled, static MgmtTargetFilterQuery toResponse(final TargetFilterQuery filter, final boolean confirmationFlowEnabled,
final boolean isRepresentationFull) { final boolean isRepresentationFull) {
final MgmtTargetFilterQuery targetRest = new MgmtTargetFilterQuery(); final MgmtTargetFilterQuery targetRest = new MgmtTargetFilterQuery();
targetRest.setFilterId(filter.getId()); targetRest.setId(filter.getId());
targetRest.setName(filter.getName()); targetRest.setName(filter.getName());
targetRest.setQuery(filter.getQuery()); targetRest.setQuery(filter.getQuery());
@@ -84,7 +83,7 @@ public final class MgmtTargetFilterQueryMapper {
static void addLinks(final MgmtTargetFilterQuery targetRest) { static void addLinks(final MgmtTargetFilterQuery targetRest) {
targetRest.add(linkTo(methodOn(MgmtTargetFilterQueryRestApi.class) targetRest.add(linkTo(methodOn(MgmtTargetFilterQueryRestApi.class)
.postAssignedDistributionSet(targetRest.getFilterId(), null)).withRel("autoAssignDS").expand()); .postAssignedDistributionSet(targetRest.getId(), null)).withRel("autoAssignDS").expand());
} }
static TargetFilterQueryCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetFilterQueryRequestBody filterRest) { static TargetFilterQueryCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetFilterQueryRequestBody filterRest) {

View File

@@ -224,13 +224,13 @@ public final class MgmtTargetMapper {
static MgmtAction toResponse(final String targetId, final Action action) { static MgmtAction toResponse(final String targetId, final Action action) {
final MgmtAction result = new MgmtAction(); final MgmtAction result = new MgmtAction();
result.setActionId(action.getId()); result.setId(action.getId());
result.setType(getType(action)); result.setType(getType(action));
if (ActionType.TIMEFORCED == action.getActionType()) { if (ActionType.TIMEFORCED == action.getActionType()) {
result.setForceTime(action.getForcedTime()); result.setForceTime(action.getForcedTime());
} }
action.getWeight().ifPresent(result::setWeight); action.getWeight().ifPresent(result::setWeight);
result.setActionType(MgmtRestModelMapper.convertActionType(action.getActionType())); result.setForceType(MgmtRestModelMapper.convertActionType(action.getActionType()));
if (action.isActive()) { if (action.isActive()) {
result.setStatus(MgmtAction.ACTION_PENDING); result.setStatus(MgmtAction.ACTION_PENDING);
@@ -354,7 +354,7 @@ public final class MgmtTargetMapper {
result.setMessages(messages); result.setMessages(messages);
result.setReportedAt(actionStatus.getCreatedAt()); result.setReportedAt(actionStatus.getCreatedAt());
result.setTimestamp(actionStatus.getOccurredAt()); result.setTimestamp(actionStatus.getOccurredAt());
result.setStatusId(actionStatus.getId()); result.setId(actionStatus.getId());
result.setType(actionStatus.getStatus().name().toLowerCase()); result.setType(actionStatus.getStatus().name().toLowerCase());
actionStatus.getCode().ifPresent(result::setCode); actionStatus.getCode().ifPresent(result::setCode);

View File

@@ -275,7 +275,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
return ResponseEntity.notFound().build(); return ResponseEntity.notFound().build();
} }
if (MgmtActionType.FORCED != actionUpdate.getActionType()) { if (MgmtActionType.FORCED != actionUpdate.getForceType()) {
throw new ValidationException("Resource supports only switch to FORCED."); throw new ValidationException("Resource supports only switch to FORCED.");
} }

View File

@@ -56,14 +56,14 @@ public final class MgmtTargetTypeMapper {
final MgmtTargetType result = new MgmtTargetType(); final MgmtTargetType result = new MgmtTargetType();
MgmtRestModelMapper.mapTypeToType(result, type); MgmtRestModelMapper.mapTypeToType(result, type);
result.setTypeId(type.getId()); result.setId(type.getId());
result.add( result.add(
linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(result.getTypeId())).withSelfRel().expand()); linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(result.getId())).withSelfRel().expand());
return result; return result;
} }
static void addLinks(final MgmtTargetType result) { static void addLinks(final MgmtTargetType result) {
result.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getCompatibleDistributionSets(result.getTypeId())) result.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getCompatibleDistributionSets(result.getId()))
.withRel(MgmtRestConstants.TARGETTYPE_V1_DS_TYPES).expand()); .withRel(MgmtRestConstants.TARGETTYPE_V1_DS_TYPES).expand());
} }

View File

@@ -195,7 +195,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
} }
@Test @Test
@Description(" Get a single meta data value for a meta data key.") @Description("Get a single meta data value for a meta data key.")
public void getMetadataValue() throws Exception { public void getMetadataValue() throws Exception {
// prepare and create metadata // prepare and create metadata
@@ -205,8 +205,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
softwareModuleManagement.updateMetaData( softwareModuleManagement.updateMetaData(
entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue)); entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue));
mvc.perform( mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
module.getId(), knownKey)) module.getId(), knownKey))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
@@ -399,7 +398,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
final MgmtArtifact artResult = ResourceUtility.convertArtifactResponse( final MgmtArtifact artResult = ResourceUtility.convertArtifactResponse(
mvcResult.getResponse().getContentAsString()); mvcResult.getResponse().getContentAsString());
final Long artId = softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getId(); final Long artId = softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getId();
assertThat(artResult.getArtifactId()).as("Wrong artifact id").isEqualTo(artId); assertThat(artResult.getId()).as("Wrong artifact id").isEqualTo(artId);
assertThat((Object)JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString())) assertThat((Object)JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString()))
.as("Link contains no self url") .as("Link contains no self url")
.hasToString("http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artId); .hasToString("http://localhost/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artId);

View File

@@ -37,5 +37,4 @@ public class ActionUpdatedEvent extends AbstractActionEvent implements EntityUpd
final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId, final String applicationId) { final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId, final String applicationId) {
super(action, targetId, rolloutId, rolloutGroupId, applicationId); super(action, targetId, rolloutId, rolloutGroupId, applicationId);
} }
} }

Some files were not shown because too many files have changed in this diff Show More