Skip to content

Commit

Permalink
Move deprecated repository and mgmt rest methods in separate module
Browse files Browse the repository at this point in the history
Some already deprecated management RRES methods are moved in separate module (together with used only for them repository api and impl).
The new module is hawkbit-mgmt-resource-deprecated. It is inculded, by default, in hawkbit-mgmt-stater. However, it could be excluded (by removing the module from runtime).
Also, when we decide to remove the implementation completely - it will be easily dropped. Also, after removal, for some time, untill the APIs are not changed there will be
possible to refer (and include) the deprecated method in the next hawkBit versions.

The deprecated methods are:
* POST /rest/v1/distributionsettags/{distributionsetTagId}/assigned/toggleTagAssignment
* POST /rest/v1/distributionsettags/{distributionsetTagId}/assigned
* POST /rest/v1/targettags/{targetTagId}/assigned/toggleTagAssignment
* POST /rest/v1/targettags/{targetTagId}/assigned

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Jan 9, 2025
1 parent 3fde960 commit aabb408
Show file tree
Hide file tree
Showing 30 changed files with 768 additions and 639 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut {

// deprecated format from the time 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)
private MgmtSoftwareModuleAssignment os;
Expand All @@ -45,8 +45,8 @@ public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetReque
@JsonProperty
@Schema(hidden = true)
private MgmtSoftwareModuleAssignment application;

// deprecated format - END

@JsonProperty
private List<MgmtSoftwareModuleAssignment> modules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedDistributionSetRequestBody;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtDistributionSetTagAssigmentResult;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
Expand Down Expand Up @@ -457,90 +455,4 @@ ResponseEntity<Void> unassignDistributionSet(
ResponseEntity<Void> unassignDistributionSets(
@PathVariable("distributionsetTagId") Long distributionsetTagId,
@RequestBody List<Long> distributionsetIds);

/**
* Handles the POST request to toggle the assignment of distribution sets by
* the given tag id.
*
* @param distributionsetTagId the ID of the distribution set tag to retrieve
* @param assignedDSRequestBodies list of distribution set ids to be toggled
* @return the list of assigned distribution sets and unassigned distribution sets.
* @deprecated since 0.6.0 with toggle assignment deprecation
*/
@Operation(summary = "[DEPRECATED] Toggle the assignment of distribution sets by the given tag id",
description = "Handles the POST request of toggle distribution assignment. The request body must " +
"always be a list of distribution set ids.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully retrieved"),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403",
description = "Insufficient permissions, entity is not allowed to be changed (i.e. read-only) or " +
"data volume restriction applies.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "409", description = "E.g. in case an entity is created or modified by another " +
"user in another request at the same time. You may retry your modification request.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "415", description = "The request was attempt with a media-type which is not " +
"supported by the server for this resource.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
"and the client has to wait another second.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
})
@PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING +
MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/toggleTagAssignment")
@Deprecated(forRemoval = true, since = "0.6.0")
ResponseEntity<MgmtDistributionSetTagAssigmentResult> toggleTagAssignment(
@PathVariable("distributionsetTagId") Long distributionsetTagId,
@RequestBody List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies);

/**
* Handles the POST request to assign distribution sets to the given tag id.
*
* @param distributionsetTagId the ID of the distribution set tag to retrieve
* @param assignedDSRequestBodies list of distribution sets ids to be assigned
* @return the list of assigned distribution set.
* @deprecated since 0.6.0 in favor or assign by ds ids
*/
@Operation(summary = "[DEPRECATED] Assign distribution sets to the given tag id",
description = "Handles the POST request of distribution assignment. Already assigned distribution will " +
"be ignored.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully retrieved"),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403",
description = "Insufficient permissions, entity is not allowed to be changed (i.e. read-only) or " +
"data volume restriction applies.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "409", description = "E.g. in case an entity is created or modified by another " +
"user in another request at the same time. You may retry your modification request.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "415", description = "The request was attempt with a media-type which is not " +
"supported by the server for this resource.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
"and the client has to wait another second.",
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
})
@PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
@Deprecated(forRemoval = true, since = "0.6.0")
ResponseEntity<List<MgmtDistributionSet>> assignDistributionSetsByRequestBody(
@PathVariable("distributionsetTagId") Long distributionsetTagId,
@RequestBody List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtAssignedTargetRequestBody;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTargetTagAssigmentResult;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
import org.springframework.hateoas.MediaTypes;
Expand Down Expand Up @@ -388,74 +386,6 @@ ResponseEntity<Void> unassignTargets(
@Schema(description = "List of controller ids to be unassigned", example = "[\"controllerId1\", \"controllerId2\"]")
@RequestBody List<String> controllerId);

/**
* Handles the POST request to toggle the assignment of targets by the given tag id.
*
* @param targetTagId the ID of the target tag to retrieve
* @param assignedTargetRequestBodies list of controller ids to be toggled
* @return the list of assigned targets and unassigned targets.
* @deprecated since 0.6.0 - not very usable with very unclear logic
*/
@Operation(summary = "[DEPRECATED] Toggles target tag assignment", description = "Handles the POST request of toggle target " +
"assignment. The request body must always be a list of controller ids.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully retrieved"),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication."),
@ApiResponse(responseCode = "403", description = "Insufficient permissions, entity is not allowed to be " +
"changed (i.e. read-only) or data volume restriction applies."),
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource."),
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json."),
@ApiResponse(responseCode = "409", description = "E.g. in case an entity is created or modified by another " +
"user in another request at the same time. You may retry your modification request."),
@ApiResponse(responseCode = "415", description = "The request was attempt with a media-type which is not " +
"supported by the server for this resource."),
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts and the client has to wait another second.")
})
@PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING +
MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/toggleTagAssignment",
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
@Deprecated(forRemoval = true, since = "0.6.0")
ResponseEntity<MgmtTargetTagAssigmentResult> toggleTagAssignment(
@PathVariable("targetTagId") Long targetTagId,
@RequestBody List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);

/**
* Handles the POST request to assign targets to the given tag id.
*
* @param targetTagId the ID of the target tag to retrieve
* @param assignedTargetRequestBodies list of controller ids to be assigned
* @return the list of assigned targets.
* @deprecated since 0.6.0 in favour of {@link #assignTargets}
*/
@Operation(summary = "[DEPRECATED] Assign target(s) to given tagId and return targets",
description = "Handles the POST request of target assignment. Already assigned target will be ignored.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully assigned"),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication."),
@ApiResponse(responseCode = "403", description = "Insufficient permissions, entity is not allowed to be " +
"changed (i.e. read-only) or data volume restriction applies."),
@ApiResponse(responseCode = "405", description = "The http request method is not allowed on the resource."),
@ApiResponse(responseCode = "406", description = "In case accept header is specified and not application/json."),
@ApiResponse(responseCode = "409", description = "E.g. in case an entity is created or modified by another " +
"user in another request at the same time. You may retry your modification request."),
@ApiResponse(responseCode = "415", description = "The request was attempt with a media-type which is not " +
"supported by the server for this resource."),
@ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " +
"and the client has to wait another second.")
})
@PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
@Deprecated(forRemoval = true, since = "0.6.0")
ResponseEntity<List<MgmtTarget>> assignTargetsByRequestBody(
@PathVariable("targetTagId") Long targetTagId,
@RequestBody List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies);

enum OnNotFoundPolicy {
FAIL, // default
ON_WHAT_FOUND_AND_FAIL,
Expand Down
79 changes: 79 additions & 0 deletions hawkbit-mgmt/hawkbit-mgmt-resource-deprecated/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!--
Copyright (c) 2015 Bosch Software Innovations GmbH and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>hawkbit-mgmt-resource-deprecated</artifactId>
<name>hawkBit :: Management :: REST Resources (DEPRECATED)</name>

<dependencies>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-resource</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-rest-core</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-mgmt-resource</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-aspects</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit aabb408

Please sign in to comment.