diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java index 567e42f17..41671e2b6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java @@ -261,11 +261,11 @@ public interface MgmtDistributionSetRestApi { * Handles the GET request of retrieving assigned targets to a specific distribution set. * * @param distributionSetId the ID of the distribution set to retrieve the assigned targets + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return status OK if get request is successful with the paged list of targets */ @Operation(summary = "Return assigned targets to a specific distribution set", description = "Handles the GET " + @@ -294,7 +294,11 @@ public interface MgmtDistributionSetRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedTargets( @PathVariable("distributionSetId") Long distributionSetId, - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -310,22 +314,17 @@ public interface MgmtDistributionSetRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving installed targets to a specific distribution set. * * @param distributionSetId the ID of the distribution set to retrieve the assigned targets + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return status OK if get request is successful with the paged list of targets */ @Operation(summary = "Return installed targets to a specific distribution set", description = "Handles the GET " + @@ -354,7 +353,11 @@ public interface MgmtDistributionSetRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getInstalledTargets( @PathVariable("distributionSetId") Long distributionSetId, - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -370,22 +373,17 @@ public interface MgmtDistributionSetRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request to retrieve target filter queries that have the given distribution set as auto assign DS. * * @param distributionSetId the ID of the distribution set to retrieve the assigned targets + * @param rsqlParam the search name parameter in the request URL, syntax {@code q=myFilter} * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search name parameter in the request URL, syntax {@code q=myFilter} * @return status OK if get request is successful with the paged list of targets */ @Operation(summary = "Return target filter queries that have the given distribution set as auto assign DS", @@ -414,7 +412,11 @@ public interface MgmtDistributionSetRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAutoAssignTargetFilterQueries( @PathVariable("distributionSetId") Long distributionSetId, - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -430,12 +432,7 @@ public interface MgmtDistributionSetRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the POST request of assigning multiple targets to a single distribution set. diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java index 4c8ad8780..269965d07 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java @@ -50,11 +50,11 @@ public interface MgmtDistributionSetTagRestApi { /** * Handles the GET request of retrieving all DistributionSet tags. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of DistributionSet tags for pagination, might not be present in the rest request then default * value will be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all target tags for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -81,7 +81,11 @@ public interface MgmtDistributionSetTagRestApi { @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTags( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -97,12 +101,7 @@ public interface MgmtDistributionSetTagRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a single distribution set tag. @@ -257,11 +256,11 @@ public interface MgmtDistributionSetTagRestApi { * Handles the GET request of retrieving all assigned distribution sets by the given tag id. * * @param distributionsetTagId the ID of the distribution set tag + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of target tags for pagination, might not be present in the rest request then default value * will be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return the list of assigned distribution sets. */ @Operation(summary = "Return all assigned distribution sets by given tag Id", @@ -290,7 +289,11 @@ public interface MgmtDistributionSetTagRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedDistributionSets( @PathVariable("distributionsetTagId") Long distributionsetTagId, - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -306,12 +309,7 @@ public interface MgmtDistributionSetTagRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the POST request to assign distribution sets to the given tag id. diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java index b16fba594..f76732b17 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java @@ -52,11 +52,11 @@ public interface MgmtDistributionSetTypeRestApi { /** * Handles the GET request of retrieving all DistributionSetTypes. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of modules for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all DistributionSetType for a defined or default page request with status OK. The response is always paged. In any * failure the JsonResponseExceptionHandler is handling the response. */ @@ -83,7 +83,11 @@ public interface MgmtDistributionSetTypeRestApi { @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTypes( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -99,12 +103,7 @@ public interface MgmtDistributionSetTypeRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a single DistributionSetType within. diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java index a757e578a..4eaae9b04 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java @@ -209,11 +209,11 @@ public interface MgmtSoftwareModuleRestApi { /** * Handles the GET request of retrieving all software modules. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of modules for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all modules for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -239,7 +239,11 @@ public interface MgmtSoftwareModuleRestApi { @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getSoftwareModules( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -255,12 +259,7 @@ public interface MgmtSoftwareModuleRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a single software module. diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java index d9a8c2369..b314c7fbc 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java @@ -51,11 +51,11 @@ public interface MgmtSoftwareModuleTypeRestApi { /** * Handles the GET request of retrieving all SoftwareModuleTypes . * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of modules for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all module type for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -82,7 +82,11 @@ public interface MgmtSoftwareModuleTypeRestApi { @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTypes( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -98,12 +102,7 @@ public interface MgmtSoftwareModuleTypeRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a single software module type . diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java index 3dafb354e..2d4202327 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java @@ -82,11 +82,11 @@ public interface MgmtTargetFilterQueryRestApi { /** * Handles the GET request of retrieving all filters. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all targets for a defined or default page reque status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -112,7 +112,11 @@ public interface MgmtTargetFilterQueryRestApi { @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getFilters( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -129,11 +133,6 @@ public interface MgmtTargetFilterQueryRestApi { The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam); /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java index 860bd7309..d50bc15cf 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java @@ -99,11 +99,11 @@ public interface MgmtTargetRestApi { /** * Handles the GET request of retrieving all targets. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all targets for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -129,7 +129,11 @@ public interface MgmtTargetRestApi { @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargets( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -145,12 +149,7 @@ public interface MgmtTargetRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the POST request of creating new targets. The request body must always be a list of targets. @@ -350,11 +349,11 @@ public interface MgmtTargetRestApi { * Handles the GET request of retrieving the Actions of a specific target. * * @param targetId to load actions for + * @param rsqlParam the search parameter in the request URL, syntax {@code q=status==pending} * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will * be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=status==pending} * @return a list of all Actions for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -382,7 +381,11 @@ public interface MgmtTargetRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getActionHistory( @PathVariable("targetId") String targetId, - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -398,12 +401,7 @@ public interface MgmtTargetRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a specific Actions of a specific Target. diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java index 00366271e..640f7c4fd 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java @@ -50,11 +50,11 @@ public interface MgmtTargetTagRestApi { /** * Handles the GET request of retrieving all target tags. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of target tags for pagination, might not be present in the rest request then default value * will be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all target tags for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -75,7 +75,11 @@ public interface MgmtTargetTagRestApi { @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTags( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -91,12 +95,7 @@ public interface MgmtTargetTagRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a single target tag. @@ -216,11 +215,11 @@ public interface MgmtTargetTagRestApi { * Handles the GET request of retrieving all assigned targets by the given tag id. * * @param targetTagId the ID of the target tag to retrieve + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of target tags for pagination, might not be present in the rest request then default value * will be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return the list of assigned targets. */ @Operation(summary = "Return assigned targets for tag", @@ -243,7 +242,11 @@ public interface MgmtTargetTagRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedTargets( @PathVariable("targetTagId") Long targetTagId, - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -259,12 +262,7 @@ public interface MgmtTargetTagRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the PUT request to assign targets to the given tag id. diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java index 224fe6ce5..6febe2875 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java @@ -52,11 +52,11 @@ public interface MgmtTargetTypeRestApi { /** * Handles the GET request of retrieving all TargetTypes. * + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @param pagingOffsetParam the offset of list of target types for pagination, might not be present in the rest request then default value * will be applied * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return a list of all TargetTypes for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @@ -82,7 +82,11 @@ public interface MgmtTargetTypeRestApi { @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTypes( - @RequestParam( + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) + @Schema(description = """ + Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for + available fields.""") + String rsqlParam, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") @@ -98,12 +102,7 @@ public interface MgmtTargetTypeRestApi { consists of the name of a field and the sort direction (ASC for ascending and DESC descending). The sequence of the sort criteria (multiple can be used) defines the sort order of the entities in the result.""") - String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") - String rsqlParam); + String sortParam); /** * Handles the GET request of retrieving a single TargetType. diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java index 510a5a6e9..fa5a85b7f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java @@ -9,20 +9,21 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeActionSortParam; + import lombok.extern.slf4j.Slf4j; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtActionMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.DeploymentManagement; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Action; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -41,10 +42,7 @@ public class MgmtActionResource implements MgmtActionRestApi { public ResponseEntity> getActions( final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam, final String representationModeParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeActionSortParam(sortParam); - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionSortParam(sortParam)); final Slice actions; final long totalActionCount; diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java index cfa202d2d..93d04d99f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeDistributionSetSortParam; + import java.text.MessageFormat; import java.util.AbstractMap.SimpleEntry; import java.util.Collection; @@ -38,13 +40,18 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssi import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDeploymentRequestMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDistributionSetMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtSoftwareModuleMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetFilterQueryMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetInvalidationManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareModuleManagement; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; @@ -64,7 +71,6 @@ import org.eclipse.hawkbit.utils.TenantConfigHelper; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -113,11 +119,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { @Override public ResponseEntity> getDistributionSets( final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeDistributionSetSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Slice findDsPage; final long countModulesAll; if (rsqlParam != null) { @@ -193,39 +195,27 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { @Override public ResponseEntity> getAssignedTargets( - final Long distributionSetId, - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Long distributionSetId, final String rsqlParam, + final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Page targetsAssignedDS; if (rsqlParam != null) { - targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId, - rsqlParam); + targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId, rsqlParam); } else { targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(pageable, distributionSetId); } - return ResponseEntity - .ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent(), tenantConfigHelper), - targetsAssignedDS.getTotalElements())); + return ResponseEntity.ok(new PagedList<>( + MgmtTargetMapper.toResponse(targetsAssignedDS.getContent(), tenantConfigHelper), targetsAssignedDS.getTotalElements())); } @Override public ResponseEntity> getInstalledTargets( - final Long distributionSetId, - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - // check if distribution set exists otherwise throw exception - // immediately + final Long distributionSetId, final String rsqlParam, + final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + // check if distribution set exists otherwise throw exception immediately distributionSetManagement.getOrElseThrowException(distributionSetId); - - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Page targetsInstalledDS; if (rsqlParam != null) { targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable, distributionSetId, rsqlParam); @@ -233,26 +223,21 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId); } - return ResponseEntity - .ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent(), tenantConfigHelper), - targetsInstalledDS.getTotalElements())); + return ResponseEntity.ok(new PagedList<>( + MgmtTargetMapper.toResponse(targetsInstalledDS.getContent(), tenantConfigHelper), targetsInstalledDS.getTotalElements())); } @Override public ResponseEntity> getAutoAssignTargetFilterQueries( - final Long distributionSetId, - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetFilterQuerySortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Long distributionSetId, final String rsqlParam, + final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Page targetFilterQueries = targetFilterQueryManagement .findByAutoAssignDSAndRsql(pageable, distributionSetId, rsqlParam); - return ResponseEntity - .ok(new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent(), - tenantConfigHelper.isConfirmationFlowEnabled(), false), targetFilterQueries.getTotalElements())); + return ResponseEntity.ok(new PagedList<>( + MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent(), tenantConfigHelper.isConfirmationFlowEnabled(), false), + targetFilterQueries.getTotalElements())); } @Override @@ -309,7 +294,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { } @Override - public ResponseEntity assignSoftwareModules(final Long distributionSetId, final List softwareModuleIDs) { + public ResponseEntity assignSoftwareModules(final Long distributionSetId, + final List softwareModuleIDs) { distributionSetManagement.assignSoftwareModules( distributionSetId, softwareModuleIDs.stream() @@ -329,13 +315,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { public ResponseEntity> getAssignedSoftwareModules( final Long distributionSetId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam); - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - final Page softwaremodules = softwareModuleManagement.findByAssignedTo(distributionSetId, pageable); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); + final Page softwareModules = softwareModuleManagement.findByAssignedTo(distributionSetId, pageable); return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse( - softwaremodules.getContent()), softwaremodules.getTotalElements())); + softwareModules.getContent()), softwareModules.getTotalElements())); } @Override diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java index 2a6c87113..df0b6bc55 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeTagSortParam; + import java.util.List; import lombok.extern.slf4j.Slf4j; @@ -18,11 +20,12 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDistributionSetMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTagMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTagManagement; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; @@ -31,7 +34,6 @@ import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -57,12 +59,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @Override public ResponseEntity> getDistributionSetTags( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam)); final Slice distributionSetTags; final long count; if (rsqlParam == null) { @@ -79,8 +77,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes } @Override - public ResponseEntity getDistributionSetTag( - final Long distributionsetTagId) { + public ResponseEntity getDistributionSetTag(final Long distributionsetTagId) { final DistributionSetTag distributionSetTag = findDistributionTagById(distributionsetTagId); final MgmtTag response = MgmtTagMapper.toResponse(distributionSetTag); @@ -90,23 +87,19 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes } @Override - public ResponseEntity> createDistributionSetTags( - final List tags) { + public ResponseEntity> createDistributionSetTags(final List tags) { log.debug("creating {} ds tags", tags.size()); final List createdTags = distributionSetTagManagement.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags)); - return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED); } @Override @AuditLog(entity = "DistributionSetTag", type = AuditLog.Type.UPDATE, description = "Update Distribution Set Tag") - public ResponseEntity updateDistributionSetTag( - final Long distributionsetTagId, - final MgmtTagRequestBodyPut restDSTagRest) { + public ResponseEntity updateDistributionSetTag(final Long distributionSetTagId, final MgmtTagRequestBodyPut restDSTagRest) { final DistributionSetTag distributionSetTag = distributionSetTagManagement - .update(entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName()) + .update(entityFactory.tag().update(distributionSetTagId).name(restDSTagRest.getName()) .description(restDSTagRest.getDescription()).colour(restDSTagRest.getColour())); final MgmtTag response = MgmtTagMapper.toResponse(distributionSetTag); @@ -117,8 +110,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @Override @AuditLog(entity = "DistributionSetTag", type = AuditLog.Type.DELETE, description = "Delete Distribution Set Tag") - public ResponseEntity deleteDistributionSetTag( - final Long distributionsetTagId) { + public ResponseEntity deleteDistributionSetTag(final Long distributionsetTagId) { log.debug("Delete {} distribution set tag", distributionsetTagId); final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); @@ -129,37 +121,31 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @Override public ResponseEntity> getAssignedDistributionSets( - final Long distributionsetTagId, - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - Page findDistrAll; + final Long distributionSetTagId, final String rsqlParam, + final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam)); + final Page distributionSets; if (rsqlParam == null) { - findDistrAll = distributionSetManagement.findByTag(distributionsetTagId, pageable); + distributionSets = distributionSetManagement.findByTag(distributionSetTagId, pageable); } else { - findDistrAll = distributionSetManagement.findByRsqlAndTag(rsqlParam, distributionsetTagId, pageable); + distributionSets = distributionSetManagement.findByRsqlAndTag(rsqlParam, distributionSetTagId, pageable); } - final List rest = MgmtDistributionSetMapper.toResponseFromDsList(findDistrAll.getContent()); - return ResponseEntity.ok(new PagedList<>(rest, findDistrAll.getTotalElements())); + final List rest = MgmtDistributionSetMapper.toResponseFromDsList(distributionSets.getContent()); + return ResponseEntity.ok(new PagedList<>(rest, distributionSets.getTotalElements())); } @Override - public ResponseEntity assignDistributionSet( - final Long distributionsetTagId, - final Long distributionsetId) { - log.debug("Assign ds {} for ds tag {}", distributionsetId, distributionsetTagId); - this.distributionSetManagement.assignTag(List.of(distributionsetId), distributionsetTagId); + public ResponseEntity assignDistributionSet(final Long distributionSetTagId, final Long distributionSetId) { + log.debug("Assign ds {} for ds tag {}", distributionSetId, distributionSetTagId); + this.distributionSetManagement.assignTag(List.of(distributionSetId), distributionSetTagId); return ResponseEntity.ok().build(); } @Override - public ResponseEntity assignDistributionSets(final Long distributionsetTagId, final List distributionsetIds) { - log.debug("Assign DistributionSet {} for ds tag {}", distributionsetIds.size(), distributionsetTagId); - final List assignedDs = this.distributionSetManagement.assignTag(distributionsetIds, distributionsetTagId); + public ResponseEntity assignDistributionSets(final Long distributionSetTagId, final List distributionSetIds) { + log.debug("Assign DistributionSet {} for ds tag {}", distributionSetIds.size(), distributionSetTagId); + final List assignedDs = this.distributionSetManagement.assignTag(distributionSetIds, distributionSetTagId); log.debug("Assigned DistributionSet {}", assignedDs.size()); return ResponseEntity.ok().build(); } @@ -173,9 +159,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @Override @AuditLog(entity = "DistributionSetTag", type = AuditLog.Type.UPDATE, description = "Unassign Distribution Set From Tag") - public ResponseEntity unassignDistributionSet( - final Long distributionsetTagId, - final Long distributionsetId) { + public ResponseEntity unassignDistributionSet(final Long distributionsetTagId, final Long distributionsetId) { log.debug("Unassign ds {} for ds tag {}", distributionsetId, distributionsetTagId); this.distributionSetManagement.unassignTag(List.of(distributionsetId), distributionsetTagId); return ResponseEntity.ok().build(); @@ -183,9 +167,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @Override @AuditLog(entity = "DistributionSetTag", type = AuditLog.Type.UPDATE, description = "Unassign Distribution Sets From Tag") - public ResponseEntity unassignDistributionSets( - final Long distributionsetTagId, - final List distributionsetIds) { + public ResponseEntity unassignDistributionSets(final Long distributionsetTagId, final List distributionsetIds) { log.debug("Unassign DistributionSet {} for ds tag {}", distributionsetIds.size(), distributionsetTagId); final List assignedDs = this.distributionSetManagement.unassignTag(distributionsetIds, distributionsetTagId); log.debug("Unassigned DistributionSet {}", assignedDs.size()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java index 399fdc6a9..9e0053b8c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeDistributionSetTypeSortParam; + import java.util.Collections; import java.util.List; @@ -20,10 +22,11 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDistributionSetTypeMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtSoftwareModuleTypeMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.SoftwareModuleTypeNotInDistributionSetTypeException; @@ -32,7 +35,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -57,12 +59,8 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> getDistributionSetTypes( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeDistributionSetTypeSortParam(sortParam); - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetTypeSortParam(sortParam)); final Slice findModuleTypessAll; long countModulesAll; if (rsqlParam != null) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java index 549e8b1b8..3f1de51e6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeRolloutSortParam; + import java.util.List; import java.util.Objects; import java.util.Optional; @@ -26,6 +28,8 @@ import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponse import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRolloutMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.EntityFactory; @@ -83,7 +87,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { public ResponseEntity> getRollouts( final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam, final String representationModeParam) { - final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sortParam); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeRolloutSortParam(sortParam)); final boolean isFullMode = parseRepresentationMode(representationModeParam) == MgmtRepresentationMode.FULL; final Page rollouts; @@ -205,7 +209,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { final Long rolloutId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam, final String representationModeParam) { - final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sortParam); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeRolloutSortParam(sortParam)); final boolean isFullMode = parseRepresentationMode(representationModeParam) == MgmtRepresentationMode.FULL; final Page rolloutGroups; @@ -247,8 +251,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { final Long rolloutId, final Long groupId, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { findRolloutOrThrowException(rolloutId); - final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sortParam); - + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeRolloutSortParam(sortParam)); final Page rolloutGroupTargets; if (rsqlParam == null) { rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java index a18152046..3f32a3b8d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java @@ -9,12 +9,13 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeSoftwareModuleSortParam; + import java.io.IOException; import java.io.InputStream; import java.text.MessageFormat; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Optional; import jakarta.validation.ValidationException; @@ -31,10 +32,10 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtSoftwareModuleMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareModuleManagement; import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement; import org.eclipse.hawkbit.repository.SystemManagement; @@ -48,7 +49,6 @@ import org.eclipse.hawkbit.rest.json.model.ResponseList; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -137,8 +137,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { final MgmtArtifact response = MgmtSoftwareModuleMapper.toResponse(module.getArtifact(artifactId).get()); if (!module.isDeleted()) { if (Boolean.TRUE.equals(useArtifactUrlHandler)) { - MgmtSoftwareModuleMapper.addLinks(module.getArtifact(artifactId).get(), response, artifactUrlHandler, - systemManagement); + MgmtSoftwareModuleMapper.addLinks(module.getArtifact(artifactId).get(), response, artifactUrlHandler, systemManagement); } else { MgmtSoftwareModuleMapper.addLinks(module.getArtifact(artifactId).get(), response); } @@ -158,13 +157,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { @Override public ResponseEntity> getSoftwareModules( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeSoftwareModuleSortParam(sortParam)); final Slice findModulesAll; final long countModulesAll; if (rsqlParam != null) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java index 8c3f07893..6e75d926d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeSoftwareModuleTypeSortParam; + import java.util.List; import org.eclipse.hawkbit.audit.AuditLog; @@ -17,16 +19,15 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModule import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPut; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtSoftwareModuleTypeMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -47,13 +48,8 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes @Override public ResponseEntity> getTypes( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeSoftwareModuleTypeSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeSoftwareModuleTypeSortParam(sortParam)); final Slice findModuleTypessAll; final long countModulesAll; if (rsqlParam != null) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java index a291714e6..957b9bb2f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeTargetFilterQuerySortParam; + import java.util.List; import lombok.extern.slf4j.Slf4j; @@ -20,9 +22,10 @@ import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQueryRequestBody; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetFilterQueryRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDistributionSetMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetFilterQueryMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.builder.AutoAssignDistributionSetUpdate; @@ -34,7 +37,6 @@ import org.eclipse.hawkbit.utils.TenantConfigHelper; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -72,13 +74,9 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA @Override public ResponseEntity> getFilters( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam, + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String representationModeParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetFilterQuerySortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTargetFilterQuerySortParam(sortParam)); final Slice findTargetFiltersAll; final long countTargetsAll; if (rsqlParam != null) { @@ -98,22 +96,18 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA } @Override - public ResponseEntity createFilter( - final MgmtTargetFilterQueryRequestBody filter) { - final TargetFilterQuery createdTarget = filterManagement - .create(MgmtTargetFilterQueryMapper.fromRequest(entityFactory, filter)); + public ResponseEntity createFilter(final MgmtTargetFilterQueryRequestBody filter) { + final TargetFilterQuery createdTarget = filterManagement.create(MgmtTargetFilterQueryMapper.fromRequest(entityFactory, filter)); - final MgmtTargetFilterQuery response = MgmtTargetFilterQueryMapper.toResponse(createdTarget, - tenantConfigHelper.isConfirmationFlowEnabled(), false); + final MgmtTargetFilterQuery response = MgmtTargetFilterQueryMapper.toResponse( + createdTarget, tenantConfigHelper.isConfirmationFlowEnabled(), false); MgmtTargetFilterQueryMapper.addLinks(response); return new ResponseEntity<>(response, HttpStatus.CREATED); } @Override - public ResponseEntity updateFilter( - final Long filterId, - final MgmtTargetFilterQueryRequestBody targetFilterRest) { + public ResponseEntity updateFilter(final Long filterId, final MgmtTargetFilterQueryRequestBody targetFilterRest) { log.debug("updating target filter query {}", filterId); final TargetFilterQuery updateFilter = filterManagement @@ -153,7 +147,6 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA @Override public ResponseEntity postAssignedDistributionSet( final Long filterId, final MgmtDistributionSetAutoAssignment autoAssignRequest) { - final boolean confirmationRequired = autoAssignRequest.getConfirmationRequired() == null ? tenantConfigHelper.isConfirmationFlowEnabled() : autoAssignRequest.getConfirmationRequired(); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java index a8a4e9047..3dfd9437f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java @@ -9,6 +9,10 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeActionSortParam; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeActionStatusSortParam; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeTargetSortParam; + import java.util.AbstractMap.SimpleEntry; import java.util.Collection; import java.util.Collections; @@ -43,11 +47,14 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirm; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDeploymentRequestMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDistributionSetMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTagMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.ConfirmationManagement; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -63,7 +70,6 @@ import org.eclipse.hawkbit.utils.TenantConfigHelper; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -107,12 +113,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @Override public ResponseEntity> getTargets( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTargetSortParam(sortParam)); final Slice findTargetsAll; final long countTargetsAll; if (rsqlParam != null) { @@ -130,11 +132,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @Override public ResponseEntity> createTargets(final List targets) { log.debug("creating {} targets", targets.size()); - final Collection createdTargets = this.targetManagement - .create(MgmtTargetMapper.fromRequest(entityFactory, targets)); + final Collection createdTargets = this.targetManagement.create(MgmtTargetMapper.fromRequest(entityFactory, targets)); log.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED); - return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets, tenantConfigHelper), - HttpStatus.CREATED); + return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets, tenantConfigHelper), HttpStatus.CREATED); } @Override @@ -156,7 +156,6 @@ public class MgmtTargetResource implements MgmtTargetRestApi { updateTarget = this.targetManagement.update(entityFactory.target().update(targetId) .name(targetRest.getName()).description(targetRest.getDescription()).address(targetRest.getAddress()) .securityToken(targetRest.getSecurityToken()).requestAttributes(targetRest.getRequestAttributes())); - } else { updateTarget = this.targetManagement.update( entityFactory.target().update(targetId).name(targetRest.getName()).description(targetRest.getDescription()) @@ -209,15 +208,11 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @Override public ResponseEntity> getActionHistory( - final String targetId, - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { + final String targetId, final String rsqlParam, + final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { findTargetWithExceptionIfNotFound(targetId); - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeActionSortParam(sortParam); - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionSortParam(sortParam)); final Slice activeActions; final long totalActionCount; if (rsqlParam != null) { @@ -264,8 +259,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } else { this.deploymentManagement.cancelAction(actionId); } - // both functions will throw an exception, when action is in wrong - // state, which is mapped by MgmtResponseExceptionHandler. + // both functions will throw an exception, when action is in wrong state, which is mapped by MgmtResponseExceptionHandler. return ResponseEntity.noContent().build(); } @@ -273,7 +267,6 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @Override @AuditLog(entity = "Target", type = AuditLog.Type.UPDATE, description = "Update Target Action") public ResponseEntity updateAction(final String targetId, final Long actionId, final MgmtActionRequestBodyPut actionUpdate) { - Action action = deploymentManagement.findAction(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getControllerId().equals(targetId)) { @@ -292,8 +285,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @Override @AuditLog(entity = "Target", type = AuditLog.Type.UPDATE, description = "Cancel Target Action Confirmation") - public ResponseEntity updateActionConfirmation(final String targetId, final Long actionId, - final MgmtActionConfirmationRequestBodyPut actionConfirmation) { + public ResponseEntity updateActionConfirmation( + final String targetId, final Long actionId, final MgmtActionConfirmationRequestBodyPut actionConfirmation) { log.debug("updateActionConfirmation with data [targetId={}, actionId={}]: {}", targetId, actionId, actionConfirmation); return getValidatedAction(targetId, actionId) @@ -346,13 +339,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { log.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), target.getId()); return ResponseEntity.notFound().build(); } - - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeActionStatusSortParam(sortParam); - - final Page statusList = this.deploymentManagement.findActionStatusByAction( - new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action.getId()); + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionStatusSortParam(sortParam)); + final Page statusList = this.deploymentManagement.findActionStatusByAction(pageable, action.getId()); return ResponseEntity.ok(new PagedList<>( MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement), @@ -365,14 +353,14 @@ public class MgmtTargetResource implements MgmtTargetRestApi { .map(ds -> { final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(ds); MgmtDistributionSetMapper.addLinks(ds, response); - return response; }).orElse(null); if (distributionSetRest == null) { return ResponseEntity.noContent().build(); + } else { + return ResponseEntity.ok(distributionSetRest); } - return ResponseEntity.ok(distributionSetRest); } @Override diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java index a83561190..bd8f9cb83 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeTagSortParam; + import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -20,9 +22,10 @@ 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.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTagMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetTagManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; @@ -33,7 +36,6 @@ import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.utils.TenantConfigHelper; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -62,12 +64,8 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { @Override public ResponseEntity> getTargetTags( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam)); final Page findTargetsAll; if (rsqlParam == null) { findTargetsAll = this.tagManagement.findAll(pageable); @@ -126,12 +124,8 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { @Override public ResponseEntity> getAssignedTargets( final Long targetTagId, - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); - - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam)); final Page findTargetsAll; if (rsqlParam == null) { findTargetsAll = targetManagement.findByTag(pageable, targetTagId); @@ -194,7 +188,6 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { } private TargetTag findTargetTagById(final Long targetTagId) { - return tagManagement.get(targetTagId) - .orElseThrow(() -> new EntityNotFoundException(TargetTag.class, targetTagId)); + return tagManagement.get(targetTagId).orElseThrow(() -> new EntityNotFoundException(TargetTag.class, targetTagId)); } } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java index b6a9f3783..60dd9e903 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitizeTargetTypeSortParam; + import java.util.List; import lombok.extern.slf4j.Slf4j; @@ -20,16 +22,16 @@ import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetType; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPut; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtDistributionSetTypeMapper; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetTypeMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.EntityFactory; -import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetTypeManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.TargetType; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -51,12 +53,8 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { @Override public ResponseEntity> getTargetTypes( - final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); - final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = PagingUtility.sanitizeTargetTypeSortParam(sortParam); - final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - + final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTargetTypeSortParam(sortParam)); final Slice findTargetTypesAll; long countTargetTypesAll; if (rsqlParam != null) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java index 27cf21a1a..67c9fd085 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java @@ -20,6 +20,7 @@ import org.eclipse.hawkbit.audit.AuditLog; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTenantManagementMapper; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException; diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtActionMapper.java similarity index 88% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtActionMapper.java index b39c2957f..7b2818cb8 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtActionMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2022 Bosch.IO GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import java.util.Collection; import java.util.Collections; @@ -43,7 +43,7 @@ public final class MgmtActionMapper { .toList()); } - static MgmtAction toResponse(final Action action, final MgmtRepresentationMode repMode) { + public static MgmtAction toResponse(final Action action, final MgmtRepresentationMode repMode) { final String controllerId = action.getTarget().getControllerId(); if (repMode == MgmtRepresentationMode.COMPACT) { return MgmtTargetMapper.toResponse(controllerId, action); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDeploymentRequestMapper.java similarity index 96% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDeploymentRequestMapper.java index ad1f22ae5..2e0db2460 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDeploymentRequestMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java similarity index 84% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java index 20fd53f4f..1c8cdb1a6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -48,12 +48,12 @@ public final class MgmtDistributionSetMapper { * @param sets to convert * @return converted list of {@link DistributionSet}s */ - static List dsFromRequest( + public static List dsFromRequest( final Collection sets, final EntityFactory entityFactory) { return sets.stream().map(dsRest -> fromRequest(dsRest, entityFactory)).toList(); } - static MgmtDistributionSet toResponse(final DistributionSet distributionSet) { + public static MgmtDistributionSet toResponse(final DistributionSet distributionSet) { if (distributionSet == null) { return null; } @@ -81,7 +81,7 @@ public final class MgmtDistributionSetMapper { return response; } - static void addLinks(final DistributionSet distributionSet, final MgmtDistributionSet response) { + public static void addLinks(final DistributionSet distributionSet, final MgmtDistributionSet response) { response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getAssignedSoftwareModules(response.getId(), MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null)) @@ -94,7 +94,7 @@ public final class MgmtDistributionSetMapper { .withRel("metadata").expand()); } - static MgmtTargetAssignmentResponseBody toResponse(final DistributionSetAssignmentResult dsAssignmentResult) { + public static MgmtTargetAssignmentResponseBody toResponse(final DistributionSetAssignmentResult dsAssignmentResult) { final MgmtTargetAssignmentResponseBody result = new MgmtTargetAssignmentResponseBody(); result.setAlreadyAssigned(dsAssignmentResult.getAlreadyAssigned()); result.setAssignedActions(dsAssignmentResult.getAssignedEntity().stream() @@ -102,8 +102,7 @@ public final class MgmtDistributionSetMapper { return result; } - static MgmtTargetAssignmentResponseBody toResponse( - final List dsAssignmentResults) { + public static MgmtTargetAssignmentResponseBody toResponse(final List dsAssignmentResults) { final MgmtTargetAssignmentResponseBody result = new MgmtTargetAssignmentResponseBody(); final int alreadyAssigned = dsAssignmentResults.stream() .mapToInt(DistributionSetAssignmentResult::getAlreadyAssigned).sum(); @@ -116,34 +115,32 @@ public final class MgmtDistributionSetMapper { return result; } - // TODO - to be made package visible when hawkbit-mgmt-rest-deprecated is removed public static List toResponseDistributionSets(final Collection sets) { if (sets == null) { return Collections.emptyList(); } - return new ResponseList<>( - sets.stream().map(MgmtDistributionSetMapper::toResponse).toList()); + return new ResponseList<>(sets.stream().map(MgmtDistributionSetMapper::toResponse).toList()); } - static MgmtMetadata toResponseDsMetadata(final String key, String value) { + public static MgmtMetadata toResponseDsMetadata(final String key, String value) { final MgmtMetadata metadataRest = new MgmtMetadata(); metadataRest.setKey(key); metadataRest.setValue(value); return metadataRest; } - static Map fromRequestDsMetadata(final List metadata) { + public static Map fromRequestDsMetadata(final List metadata) { return metadata == null ? Collections.emptyMap() : metadata.stream().collect(Collectors.toMap(MgmtMetadata::getKey, MgmtMetadata::getValue)); } - static List toResponseDsMetadata(final Map metadata) { + public static List toResponseDsMetadata(final Map metadata) { return metadata.entrySet().stream().map(e -> toResponseDsMetadata(e.getKey(), e.getValue())).toList(); } - static List toResponseFromDsList(final List sets) { + public static List toResponseFromDsList(final List sets) { if (sets == null) { return Collections.emptyList(); } @@ -157,8 +154,7 @@ public final class MgmtDistributionSetMapper { * @param dsRest to convert * @return converted {@link DistributionSet} */ - private static DistributionSetCreate fromRequest(final MgmtDistributionSetRequestBodyPost dsRest, - final EntityFactory entityFactory) { + private static DistributionSetCreate fromRequest(final MgmtDistributionSetRequestBodyPost dsRest, final EntityFactory entityFactory) { final List modules = new ArrayList<>(); if (dsRest.getOs() != null) { modules.add(dsRest.getOs().getId()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java similarity index 82% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java index 7593af52a..29979a764 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -17,6 +17,8 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment; @@ -28,17 +30,12 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.rest.json.model.ResponseList; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ -final class MgmtDistributionSetTypeMapper { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class MgmtDistributionSetTypeMapper { - // private constructor, utility class - private MgmtDistributionSetTypeMapper() { - - } - - static List smFromRequest(final EntityFactory entityFactory, final Collection smTypesRest) { + public static List smFromRequest(final EntityFactory entityFactory, final Collection smTypesRest) { if (smTypesRest == null) { return Collections.emptyList(); } @@ -46,14 +43,14 @@ final class MgmtDistributionSetTypeMapper { return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).toList(); } - static List toListResponse(final Collection types) { + public static List toListResponse(final Collection types) { if (types == null) { return Collections.emptyList(); } return new ResponseList<>(types.stream().map(MgmtDistributionSetTypeMapper::toResponse).toList()); } - static MgmtDistributionSetType toResponse(final DistributionSetType type) { + public static MgmtDistributionSetType toResponse(final DistributionSetType type) { final MgmtDistributionSetType result = new MgmtDistributionSetType(); MgmtRestModelMapper.mapTypeToType(result, type); @@ -65,7 +62,7 @@ final class MgmtDistributionSetTypeMapper { return result; } - static void addLinks(final MgmtDistributionSetType result) { + public static void addLinks(final MgmtDistributionSetType result) { result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getId())) .withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES).expand()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtRestModelMapper.java similarity index 97% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtRestModelMapper.java index e1ca61ee7..df3392d53 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtRestModelMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtRolloutMapper.java similarity index 90% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtRolloutMapper.java index 1b6807b6d..28848ad12 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtRolloutMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE; @@ -55,15 +55,15 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; * A mapper which maps repository model to RESTful model representation and back. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -final class MgmtRolloutMapper { +public final class MgmtRolloutMapper { private static final String NOT_SUPPORTED = " is not supported"; - static List toResponseRollout(final List rollouts) { + public static List toResponseRollout(final List rollouts) { return toResponseRollout(rollouts, false); } - static List toResponseRolloutWithDetails(final List rollouts) { + public static List toResponseRolloutWithDetails(final List rollouts) { return toResponseRollout(rollouts, true); } @@ -75,7 +75,7 @@ final class MgmtRolloutMapper { return rollouts.stream().map(rollout -> toResponseRollout(rollout, withDetails)).toList(); } - static MgmtRolloutResponseBody toResponseRollout(final Rollout rollout, final boolean withDetails) { + public static MgmtRolloutResponseBody toResponseRollout(final Rollout rollout, final boolean withDetails) { final MgmtRolloutResponseBody body = new MgmtRolloutResponseBody(); body.setCreatedAt(rollout.getCreatedAt()); body.setCreatedBy(rollout.getCreatedBy()); @@ -125,8 +125,8 @@ final class MgmtRolloutMapper { return body; } - static RolloutCreate fromRequest(final EntityFactory entityFactory, final MgmtRolloutRestRequestBodyPost restRequest, - final DistributionSet distributionSet) { + public static RolloutCreate fromRequest( + final EntityFactory entityFactory, final MgmtRolloutRestRequestBodyPost restRequest, final DistributionSet distributionSet) { return entityFactory.rollout().create() .name(restRequest.getName()) .description(restRequest.getDescription()) @@ -138,13 +138,14 @@ final class MgmtRolloutMapper { .dynamic(restRequest.isDynamic()); } - static RolloutUpdate fromRequest(final EntityFactory entityFactory, final MgmtRolloutRestRequestBodyPut restRequest, final long rolloutId) { + public static RolloutUpdate fromRequest( + final EntityFactory entityFactory, final MgmtRolloutRestRequestBodyPut restRequest, final long rolloutId) { return entityFactory.rollout().update(rolloutId) .name(restRequest.getName()) .description(restRequest.getDescription()); } - static RolloutCreate fromRetriedRollout(final EntityFactory entityFactory, final Rollout rollout) { + public static RolloutCreate fromRetriedRollout(final EntityFactory entityFactory, final Rollout rollout) { return entityFactory.rollout().create() .name(rollout.getName().concat("_retry")) .description(rollout.getDescription()) @@ -156,13 +157,13 @@ final class MgmtRolloutMapper { .weight(null); } - static RolloutGroupCreate fromRequest(final EntityFactory entityFactory, final MgmtRolloutGroup restRequest) { + public static RolloutGroupCreate fromRequest(final EntityFactory entityFactory, final MgmtRolloutGroup restRequest) { return entityFactory.rolloutGroup().create().name(restRequest.getName()) .description(restRequest.getDescription()).targetFilterQuery(restRequest.getTargetFilterQuery()) .targetPercentage(restRequest.getTargetPercentage()).conditions(fromRequest(restRequest, false)); } - static DynamicRolloutGroupTemplate fromRequest(final MgmtDynamicRolloutGroupTemplate restRequest) { + public static DynamicRolloutGroupTemplate fromRequest(final MgmtDynamicRolloutGroupTemplate restRequest) { if (restRequest == null) { return null; } @@ -172,8 +173,7 @@ final class MgmtRolloutMapper { .build(); } - static RolloutGroupConditions fromRequest(final AbstractMgmtRolloutConditionsEntity restRequest, - final boolean withDefaults) { + public static RolloutGroupConditions fromRequest(final AbstractMgmtRolloutConditionsEntity restRequest, final boolean withDefaults) { final RolloutGroupConditionBuilder conditions = new RolloutGroupConditionBuilder(); if (withDefaults) { @@ -201,7 +201,7 @@ final class MgmtRolloutMapper { return conditions.build(); } - static List toResponseRolloutGroup( + public static List toResponseRolloutGroup( final List rollouts, final boolean confirmationFlowEnabled, final boolean withDetails) { if (rollouts == null) { return Collections.emptyList(); @@ -210,8 +210,8 @@ final class MgmtRolloutMapper { return rollouts.stream().map(group -> toResponseRolloutGroup(group, withDetails, confirmationFlowEnabled)).toList(); } - static MgmtRolloutGroupResponseBody toResponseRolloutGroup(final RolloutGroup rolloutGroup, - final boolean withDetailedStatus, final boolean confirmationFlowEnabled) { + public static MgmtRolloutGroupResponseBody toResponseRolloutGroup( + final RolloutGroup rolloutGroup, final boolean withDetailedStatus, final boolean confirmationFlowEnabled) { final MgmtRolloutGroupResponseBody body = new MgmtRolloutGroupResponseBody(); body.setCreatedAt(rolloutGroup.getCreatedAt()); body.setCreatedBy(rolloutGroup.getCreatedBy()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java similarity index 79% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java index 9828a03ca..406acdc88 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -30,6 +30,8 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; +import org.eclipse.hawkbit.mgmt.rest.resource.MgmtDownloadArtifactResource; +import org.eclipse.hawkbit.mgmt.rest.resource.MgmtSoftwareModuleResource; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.builder.SoftwareModuleCreate; @@ -39,6 +41,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.rest.json.model.ResponseList; import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; /** * A mapper which maps repository model to RESTful model representation and back. @@ -46,8 +49,8 @@ import org.springframework.hateoas.Link; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtSoftwareModuleMapper { - static List fromRequestSwMetadata(final EntityFactory entityFactory, - final Long softwareModuleId, final Collection metadata) { + public static List fromRequestSwMetadata( + final EntityFactory entityFactory, final Long softwareModuleId, final Collection metadata) { if (metadata == null) { return Collections.emptyList(); } @@ -59,8 +62,8 @@ public final class MgmtSoftwareModuleMapper { .toList(); } - static List smFromRequest(final EntityFactory entityFactory, - final Collection smsRest) { + public static List smFromRequest( + final EntityFactory entityFactory, final Collection smsRest) { if (smsRest == null) { return Collections.emptyList(); } @@ -68,7 +71,7 @@ public final class MgmtSoftwareModuleMapper { return smsRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).toList(); } - static List toResponse(final Collection softwareModules) { + public static List toResponse(final Collection softwareModules) { if (softwareModules == null) { return Collections.emptyList(); } @@ -76,7 +79,7 @@ public final class MgmtSoftwareModuleMapper { return new ResponseList<>(softwareModules.stream().map(MgmtSoftwareModuleMapper::toResponse).toList()); } - static List toResponseSwMetadata(final Collection metadata) { + public static List toResponseSwMetadata(final Collection metadata) { if (metadata == null) { return Collections.emptyList(); } @@ -84,7 +87,7 @@ public final class MgmtSoftwareModuleMapper { return metadata.stream().map(MgmtSoftwareModuleMapper::toResponseSwMetadata).toList(); } - static MgmtSoftwareModuleMetadata toResponseSwMetadata(final SoftwareModuleMetadata metadata) { + public static MgmtSoftwareModuleMetadata toResponseSwMetadata(final SoftwareModuleMetadata metadata) { final MgmtSoftwareModuleMetadata metadataRest = new MgmtSoftwareModuleMetadata(); metadataRest.setKey(metadata.getKey()); metadataRest.setValue(metadata.getValue()); @@ -92,7 +95,7 @@ public final class MgmtSoftwareModuleMapper { return metadataRest; } - static MgmtSoftwareModule toResponse(final SoftwareModule softwareModule) { + public static MgmtSoftwareModule toResponse(final SoftwareModule softwareModule) { if (softwareModule == null) { return null; } @@ -114,16 +117,16 @@ public final class MgmtSoftwareModuleMapper { return response; } - static void addLinks(final SoftwareModule softwareModule, final MgmtSoftwareModule response) { + public static void addLinks(final SoftwareModule softwareModule, final MgmtSoftwareModule response) { response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getId(), null, null)) .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT).expand()); response.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(softwareModule.getType().getId())) .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE).expand()); - response.add(linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getId())) + response.add(WebMvcLinkBuilder.linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getId())) .withRel("metadata").expand()); } - static MgmtArtifact toResponse(final Artifact artifact) { + public static MgmtArtifact toResponse(final Artifact artifact) { final MgmtArtifact artifactRest = new MgmtArtifact(); artifactRest.setId(artifact.getId()); artifactRest.setSize(artifact.getSize()); @@ -140,13 +143,13 @@ public final class MgmtSoftwareModuleMapper { return artifactRest; } - static void addLinks(final Artifact artifact, final MgmtArtifact response) { - response.add(linkTo(methodOn(MgmtDownloadArtifactResource.class) + public static void addLinks(final Artifact artifact, final MgmtArtifact response) { + response.add(WebMvcLinkBuilder.linkTo(methodOn(MgmtDownloadArtifactResource.class) .downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withRel("download") .expand()); } - static void addLinks(final Artifact artifact, final MgmtArtifact response, + public static void addLinks(final Artifact artifact, final MgmtArtifact response, final ArtifactUrlHandler artifactUrlHandler, final SystemManagement systemManagement) { final List urls = artifactUrlHandler.getUrls( new URLPlaceholder(systemManagement.getTenantMetadata().getTenant(), diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleTypeMapper.java similarity index 84% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleTypeMapper.java index 4fce851aa..bc9c3faaa 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleTypeMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -30,9 +30,9 @@ import org.eclipse.hawkbit.rest.json.model.ResponseList; * A mapper which maps repository model to RESTful model representation and back. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -final class MgmtSoftwareModuleTypeMapper { +public final class MgmtSoftwareModuleTypeMapper { - static List smFromRequest(final EntityFactory entityFactory, + public static List smFromRequest(final EntityFactory entityFactory, final Collection smTypesRest) { if (smTypesRest == null) { return Collections.emptyList(); @@ -41,7 +41,7 @@ final class MgmtSoftwareModuleTypeMapper { return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).toList(); } - static List toTypesResponse(final Collection types) { + public static List toTypesResponse(final Collection types) { if (types == null) { return Collections.emptyList(); } @@ -49,7 +49,7 @@ final class MgmtSoftwareModuleTypeMapper { return new ResponseList<>(types.stream().map(MgmtSoftwareModuleTypeMapper::toResponse).toList()); } - static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { + public static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType(); MgmtRestModelMapper.mapTypeToType(result, type); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTagMapper.java similarity index 77% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTagMapper.java index 200394c77..2d2b6a045 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTagMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -34,9 +34,9 @@ import org.eclipse.hawkbit.rest.json.model.ResponseList; * A mapper which maps repository model to RESTful model representation and back. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -final class MgmtTagMapper { +public final class MgmtTagMapper { - static List toResponse(final List targetTags) { + public static List toResponse(final List targetTags) { final List tagsRest = new ArrayList<>(); if (targetTags == null) { return tagsRest; @@ -50,7 +50,7 @@ final class MgmtTagMapper { return new ResponseList<>(tagsRest); } - static MgmtTag toResponse(final TargetTag targetTag) { + public static MgmtTag toResponse(final TargetTag targetTag) { final MgmtTag response = new MgmtTag(); if (targetTag == null) { return response; @@ -63,14 +63,14 @@ final class MgmtTagMapper { return response; } - static void addLinks(final TargetTag targetTag, final MgmtTag response) { + public static void addLinks(final TargetTag targetTag, final MgmtTag response) { response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getAssignedTargets(targetTag.getId(), - MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, - MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("assignedTargets") + null, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, + MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null)).withRel("assignedTargets") .expand()); } - static List toResponseDistributionSetTag(final List distributionSetTags) { + public static List toResponseDistributionSetTag(final List distributionSetTags) { final List tagsRest = new ArrayList<>(); if (distributionSetTags == null) { return tagsRest; @@ -84,7 +84,7 @@ final class MgmtTagMapper { return new ResponseList<>(tagsRest); } - static MgmtTag toResponse(final DistributionSetTag distributionSetTag) { + public static MgmtTag toResponse(final DistributionSetTag distributionSetTag) { final MgmtTag response = new MgmtTag(); if (distributionSetTag == null) { return null; @@ -99,14 +99,14 @@ final class MgmtTagMapper { return response; } - static void addLinks(final DistributionSetTag distributionSetTag, final MgmtTag response) { + public static void addLinks(final DistributionSetTag distributionSetTag, final MgmtTag response) { response.add(linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets( - distributionSetTag.getId(), MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, - MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)) + distributionSetTag.getId(), null, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, + MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null)) .withRel("assignedDistributionSets").expand()); } - static List mapTagFromRequest(final EntityFactory entityFactory, final Collection tags) { + public static List mapTagFromRequest(final EntityFactory entityFactory, final Collection tags) { return tags.stream() .map(tagRest -> entityFactory.tag().create().name(tagRest.getName()) .description(tagRest.getDescription()).colour(tagRest.getColour())) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetFilterQueryMapper.java similarity index 86% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetFilterQueryMapper.java index bda7383c7..d1fd81e3c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetFilterQueryMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -37,7 +37,7 @@ import org.springframework.util.CollectionUtils; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtTargetFilterQueryMapper { - static List toResponse( + public static List toResponse( final List filters, final boolean confirmationFlowEnabled, final boolean isRepresentationFull) { if (CollectionUtils.isEmpty(filters)) { return Collections.emptyList(); @@ -45,8 +45,8 @@ public final class MgmtTargetFilterQueryMapper { return filters.stream().map(filter -> toResponse(filter, confirmationFlowEnabled, isRepresentationFull)).toList(); } - static MgmtTargetFilterQuery toResponse(final TargetFilterQuery filter, final boolean confirmationFlowEnabled, - final boolean isRepresentationFull) { + public static MgmtTargetFilterQuery toResponse( + final TargetFilterQuery filter, final boolean confirmationFlowEnabled, final boolean isRepresentationFull) { final MgmtTargetFilterQuery targetRest = new MgmtTargetFilterQuery(); targetRest.setId(filter.getId()); targetRest.setName(filter.getName()); @@ -81,16 +81,16 @@ public final class MgmtTargetFilterQueryMapper { return targetRest; } - static void addLinks(final MgmtTargetFilterQuery targetRest) { + public static void addLinks(final MgmtTargetFilterQuery targetRest) { targetRest.add(linkTo(methodOn(MgmtTargetFilterQueryRestApi.class) .postAssignedDistributionSet(targetRest.getId(), null)).withRel("autoAssignDS").expand()); } - static TargetFilterQueryCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetFilterQueryRequestBody filterRest) { + public static TargetFilterQueryCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetFilterQueryRequestBody filterRest) { return entityFactory.targetFilterQuery().create().name(filterRest.getName()).query(filterRest.getQuery()); } - static AutoAssignDistributionSetUpdate fromRequest(final EntityFactory entityFactory, final long filterId, + public static AutoAssignDistributionSetUpdate fromRequest(final EntityFactory entityFactory, final long filterId, final MgmtDistributionSetAutoAssignment assignRest) { final ActionType type = MgmtRestModelMapper.convertActionType(assignRest.getType()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java similarity index 91% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java index a031c279b..92c9a21b2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -75,9 +75,9 @@ public final class MgmtTargetMapper { .withRel(MgmtRestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET).expand()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAttributes(response.getControllerId())) .withRel(MgmtRestConstants.TARGET_V1_ATTRIBUTES).expand()); - response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), 0, + response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), null, 0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, - ActionFields.ID.getJpaEntityFieldName() + ":" + SortDirection.DESC, null)) + ActionFields.ID.getJpaEntityFieldName() + ":" + SortDirection.DESC)) .withRel(MgmtRestConstants.TARGET_V1_ACTIONS).expand()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).getMetadata(response.getControllerId())) .withRel("metadata").expand()); @@ -130,8 +130,8 @@ public final class MgmtTargetMapper { * @param target the target * @return the response */ - public static MgmtTarget toResponse(final Target target, final TenantConfigHelper configHelper, - final Function pollStatusResolver) { + public static MgmtTarget toResponse( + final Target target, final TenantConfigHelper configHelper, final Function pollStatusResolver) { if (target == null) { return null; } @@ -176,31 +176,28 @@ public final class MgmtTargetMapper { targetRest.setAutoConfirmActive(target.getAutoConfirmationStatus() != null); } - targetRest.add( - linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withSelfRel().expand()); + targetRest.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withSelfRel().expand()); addPollStatus(target, targetRest, pollStatusResolver == null ? configHelper.pollStatusResolver() : pollStatusResolver); return targetRest; } - static List fromRequest(final EntityFactory entityFactory, - final Collection targetsRest) { + public static List fromRequest(final EntityFactory entityFactory, final Collection targetsRest) { if (targetsRest == null) { return Collections.emptyList(); } - return targetsRest.stream().map(targetRest -> fromRequest(entityFactory, targetRest)) - .toList(); + return targetsRest.stream().map(targetRest -> fromRequest(entityFactory, targetRest)).toList(); } - static Map fromRequestMetadata(final List metadata) { + public static Map fromRequestMetadata(final List metadata) { return metadata == null ? Collections.emptyMap() : metadata.stream().collect(Collectors.toMap(MgmtMetadata::getKey, MgmtMetadata::getValue)); } - static List toActionStatusRestResponse( + public static List toActionStatusRestResponse( final Collection actionStatus, final DeploymentManagement deploymentManagement) { if (actionStatus == null) { return Collections.emptyList(); @@ -214,7 +211,7 @@ public final class MgmtTargetMapper { .toList(); } - static MgmtAction toResponse(final String targetId, final Action action) { + public static MgmtAction toResponse(final String targetId, final Action action) { final MgmtAction result = new MgmtAction(); result.setId(action.getId()); @@ -263,7 +260,7 @@ public final class MgmtTargetMapper { return result; } - static MgmtAction toResponseWithLinks(final String controllerId, final Action action) { + public static MgmtAction toResponseWithLinks(final String controllerId, final Action action) { final MgmtAction result = toResponse(controllerId, action); if (action.isCancelingOrCanceled()) { @@ -293,7 +290,7 @@ public final class MgmtTargetMapper { return result; } - static List toResponse(final String targetId, final Collection actions) { + public static List toResponse(final String targetId, final Collection actions) { if (actions == null) { return Collections.emptyList(); } @@ -301,14 +298,14 @@ public final class MgmtTargetMapper { return actions.stream().map(action -> toResponse(targetId, action)).toList(); } - static MgmtMetadata toResponseMetadata(final String key, final String value) { + public static MgmtMetadata toResponseMetadata(final String key, final String value) { final MgmtMetadata metadataRest = new MgmtMetadata(); metadataRest.setKey(key); metadataRest.setValue(value); return metadataRest; } - static List toResponseMetadata(final Map metadata) { + public static List toResponseMetadata(final Map metadata) { return metadata.entrySet().stream().map(e -> toResponseMetadata(e.getKey(), e.getValue())).toList(); } @@ -341,7 +338,7 @@ public final class MgmtTargetMapper { return null; } - private static MgmtActionStatus toResponse(final ActionStatus actionStatus, final List messages) { + public static MgmtActionStatus toResponse(final ActionStatus actionStatus, final List messages) { final MgmtActionStatus result = new MgmtActionStatus(); result.setMessages(messages); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java similarity index 89% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java index bce2a8e2c..c3982824e 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Bosch.IO GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -35,7 +35,7 @@ import org.eclipse.hawkbit.rest.json.model.ResponseList; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtTargetTypeMapper { - static List targetFromRequest( + public static List targetFromRequest( final EntityFactory entityFactory, final Collection targetTypesRest) { if (targetTypesRest == null) { return Collections.emptyList(); @@ -45,14 +45,14 @@ public final class MgmtTargetTypeMapper { .toList(); } - static List toListResponse(final List types) { + public static List toListResponse(final List types) { if (types == null) { return Collections.emptyList(); } return new ResponseList<>(types.stream().map(MgmtTargetTypeMapper::toResponse).toList()); } - static MgmtTargetType toResponse(final TargetType type) { + public static MgmtTargetType toResponse(final TargetType type) { final MgmtTargetType result = new MgmtTargetType(); MgmtRestModelMapper.mapTypeToType(result, type); @@ -62,7 +62,7 @@ public final class MgmtTargetTypeMapper { return result; } - static void addLinks(final MgmtTargetType result) { + public static void addLinks(final MgmtTargetType result) { result.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getCompatibleDistributionSets(result.getId())) .withRel(MgmtRestConstants.TARGETTYPE_V1_DS_TYPES).expand()); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTenantManagementMapper.java similarity index 83% rename from hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java rename to hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTenantManagementMapper.java index 3b03de51e..a51da4c61 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTenantManagementMapper.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others + * Copyright (c) 2025 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.hawkbit.mgmt.rest.resource; +package org.eclipse.hawkbit.mgmt.rest.resource.mapper; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; @@ -15,7 +15,9 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue; +import org.eclipse.hawkbit.mgmt.rest.resource.MgmtTenantManagementResource; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; /** * A mapper which maps repository model to RESTful model representation and back. @@ -34,7 +36,7 @@ public final class MgmtTenantManagementMapper { restConfValue.setCreatedBy(repoConfValue.getCreatedBy()); restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt()); restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy()); - restConfValue.add(linkTo(methodOn(MgmtTenantManagementResource.class).getTenantConfigurationValue(key)).withSelfRel().expand()); + restConfValue.add(WebMvcLinkBuilder.linkTo(methodOn(MgmtTenantManagementResource.class).getTenantConfigurationValue(key)).withSelfRel().expand()); return restConfValue; } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java index 685045a7f..11e6c382a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java @@ -35,22 +35,6 @@ import org.springframework.data.domain.Sort.Direction; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class PagingUtility { - public static int sanitizeOffsetParam(final int offset) { - if (offset < 0) { - return MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE; - } - return offset; - } - - public static int sanitizePageLimitParam(final int pageLimit) { - if (pageLimit < 1) { - return MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE; - } else if (pageLimit > MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT) { - return MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT; - } - return pageLimit; - } - public static Sort sanitizeTargetSortParam(final String sortParam) { if (sortParam == null) { // default @@ -149,10 +133,25 @@ public final class PagingUtility { return Sort.by(SortUtility.parse(RolloutGroupFields.class, sortParam)); } - public static Pageable toPageable(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { + public static Pageable toPageable(final int pagingOffsetParam, final int pagingLimitParam, final Sort sort) { final int sanitizedOffsetParam = sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = sanitizePageLimitParam(pagingLimitParam); - final Sort sorting = sanitizeRolloutSortParam(sortParam); - return new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + return new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sort); + } + + private static int sanitizeOffsetParam(final int offset) { + if (offset < 0) { + return MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE; + } + return offset; + } + + private static int sanitizePageLimitParam(final int pageLimit) { + if (pageLimit < 1) { + return MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE; + } else if (pageLimit > MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT) { + return MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT; + } + return pageLimit; } } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index 52dd45f09..f1a5ab311 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -41,6 +41,7 @@ import org.awaitility.Awaitility; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper; import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java index 2c0504e9d..cd047aa55 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java @@ -33,6 +33,7 @@ import io.qameta.allure.Story; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility; import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.exception.DeletedException; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/RolloutRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/RolloutRepository.java index 6632ef826..27d0f904b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/RolloutRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/RolloutRepository.java @@ -29,8 +29,7 @@ import org.springframework.transaction.annotation.Transactional; * The repository interface for the {@link Rollout} model. */ @Transactional(readOnly = true) -public interface RolloutRepository - extends BaseEntityRepository { +public interface RolloutRepository extends BaseEntityRepository { /** * Retrieves all {@link Rollout} for given status. @@ -38,8 +37,7 @@ public interface RolloutRepository * @param status the status of the rollouts to find * @return the list of {@link Rollout} for specific status */ - // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 - @Query("SELECT sm.id FROM JpaRollout sm WHERE sm.status IN ?1") + @Query("SELECT sm.id FROM JpaRollout sm WHERE sm.status IN ?1 ORDER BY sm.id ASC") List findByStatusIn(Collection status); /** @@ -64,8 +62,7 @@ public interface RolloutRepository void deleteByTenant(@Param("tenant") String tenant); /** - * Retrieves all {@link Rollout}s for a specific {@link DistributionSet} in - * a given {@link RolloutStatus}. + * Retrieves all {@link Rollout}s for a specific {@link DistributionSet} in a given {@link RolloutStatus}. * * @param set the distribution set * @param status the status of the rollout @@ -82,4 +79,4 @@ public interface RolloutRepository * @return the count */ long countByDistributionSetIdAndStatusIn(long distributionSetId, Collection status); -} +} \ No newline at end of file diff --git a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java index 29b5ed9ee..295e6820b 100644 --- a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java +++ b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java @@ -120,14 +120,14 @@ public class DistributionSetView extends TableView { type.setItemLabelGenerator(MgmtDistributionSetType::getName); type.setItems(Optional.ofNullable( hawkbitClient.getDistributionSetTypeRestApi() - .getDistributionSetTypes(0, 20, Constants.NAME_ASC, null) + .getDistributionSetTypes(null, 0, 20, Constants.NAME_ASC) .getBody()) .map(PagedList::getContent) .orElseGet(Collections::emptyList)); tag.setItemLabelGenerator(MgmtTag::getName); tag.setItems(Optional.ofNullable( hawkbitClient.getDistributionSetTagRestApi() - .getDistributionSetTags(0, 20, Constants.NAME_ASC, null) + .getDistributionSetTags(null, 0, 20, Constants.NAME_ASC) .getBody()) .map(PagedList::getContent) .orElseGet(Collections::emptyList)); @@ -215,7 +215,7 @@ public class DistributionSetView extends TableView { this::readyToCreate, Optional.ofNullable( hawkbitClient.getDistributionSetTypeRestApi() - .getDistributionSetTypes(0, 30, Constants.NAME_ASC, null) + .getDistributionSetTypes(null, 0, 30, Constants.NAME_ASC) .getBody()) .map(body -> body.getContent().toArray(new MgmtDistributionSetType[0])) .orElseGet(() -> new MgmtDistributionSetType[0])); diff --git a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/RolloutView.java b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/RolloutView.java index 82e47741e..3275e06d7 100644 --- a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/RolloutView.java +++ b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/RolloutView.java @@ -307,7 +307,7 @@ public class RolloutView extends TableView { this::readyToCreate, Optional.ofNullable( hawkbitClient.getTargetFilterQueryRestApi() - .getFilters(0, 30, Constants.NAME_ASC, null, null) + .getFilters(null, 0, 30, Constants.NAME_ASC, null) .getBody()) .map(body -> body.getContent().toArray(new MgmtTargetFilterQuery[0])) .orElseGet(() -> new MgmtTargetFilterQuery[0])); diff --git a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/SoftwareModuleView.java b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/SoftwareModuleView.java index c8dd5d4be..16acbe915 100644 --- a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/SoftwareModuleView.java +++ b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/SoftwareModuleView.java @@ -94,7 +94,7 @@ public class SoftwareModuleView extends TableView { }, (query, rsqlFilter) -> Optional.ofNullable( hawkbitClient.getSoftwareModuleRestApi() - .getSoftwareModules(query.getOffset(), query.getPageSize(), Constants.NAME_ASC, rsqlFilter) + .getSoftwareModules(rsqlFilter, query.getOffset(), query.getPageSize(), Constants.NAME_ASC) .getBody()) .stream().map(PagedList::getContent).flatMap(List::stream), isParent ? v -> new CreateDialog(hawkbitClient).result() : null, @@ -133,7 +133,7 @@ public class SoftwareModuleView extends TableView { type.setItemLabelGenerator(MgmtSoftwareModuleType::getName); type.setItems(Optional.ofNullable( hawkbitClient.getSoftwareModuleTypeRestApi() - .getTypes(0, 20, Constants.NAME_ASC, null) + .getTypes(null, 0, 20, Constants.NAME_ASC) .getBody()) .map(PagedList::getContent) .orElseGet(Collections::emptyList)); @@ -221,7 +221,7 @@ public class SoftwareModuleView extends TableView { this::readyToCreate, Optional.ofNullable( hawkbitClient.getSoftwareModuleTypeRestApi() - .getTypes(0, 30, Constants.NAME_ASC, null) + .getTypes(null, 0, 30, Constants.NAME_ASC) .getBody()) .map(body -> body.getContent().toArray(new MgmtSoftwareModuleType[0])) .orElseGet(() -> new MgmtSoftwareModuleType[0])); @@ -254,7 +254,7 @@ public class SoftwareModuleView extends TableView { distType.setItems( Optional.ofNullable( hawkbitClient.getDistributionSetTypeRestApi() - .getDistributionSetTypes(0, 30, Constants.NAME_ASC, null) + .getDistributionSetTypes(null, 0, 30, Constants.NAME_ASC) .getBody()) .map(body -> body.getContent().toArray(new MgmtDistributionSetType[0])) .orElseGet(() -> new MgmtDistributionSetType[0])); diff --git a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/TargetView.java b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/TargetView.java index 43275400e..b4ae9139d 100644 --- a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/TargetView.java +++ b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/TargetView.java @@ -82,7 +82,6 @@ import org.eclipse.hawkbit.ui.simple.view.util.Filter; import org.eclipse.hawkbit.ui.simple.view.util.SelectionGrid; import org.eclipse.hawkbit.ui.simple.view.util.TableView; import org.eclipse.hawkbit.ui.simple.view.util.Utils; -import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.util.ObjectUtils; @@ -113,7 +112,7 @@ public class TargetView extends TableView { } }, (query, filter) -> hawkbitClient.getTargetRestApi() - .getTargets(query.getOffset(), query.getPageSize(), Constants.NAME_ASC, filter) + .getTargets(filter, query.getOffset(), query.getPageSize(), Constants.NAME_ASC) .getBody() .getContent() .stream(), @@ -162,11 +161,11 @@ public class TargetView extends TableView { public List components() { final List components = new LinkedList<>(); components.add(controllerId); - type.setItems(hawkbitClient.getTargetTypeRestApi().getTargetTypes(0, 20, Constants.NAME_ASC, null).getBody().getContent()); + type.setItems(hawkbitClient.getTargetTypeRestApi().getTargetTypes(null, 0, 20, Constants.NAME_ASC).getBody().getContent()); if (!type.getValue().isEmpty()) { components.add(type); } - tag.setItems(hawkbitClient.getTargetTagRestApi().getTargetTags(0, 20, Constants.NAME_ASC, null).getBody().getContent()); + tag.setItems(hawkbitClient.getTargetTagRestApi().getTargetTags(null, 0, 20, Constants.NAME_ASC).getBody().getContent()); if (!tag.isEmpty()) { components.add(tag); } @@ -231,7 +230,7 @@ public class TargetView extends TableView { return Optional .ofNullable( hawkbitClient.getTargetFilterQueryRestApi() - .getFilters(0, 30, null, null, null) + .getFilters(null, 0, 30, null, null) .getBody() .getContent()) .orElse(Collections.emptyList()); @@ -535,7 +534,7 @@ public class TargetView extends TableView { int offset = 0; do { List page = Optional.ofNullable( - hawkbitClient.getTargetTagRestApi().getTargetTags(offset, 50, Constants.NAME_ASC, null).getBody()) + hawkbitClient.getTargetTagRestApi().getTargetTags(null, offset, 50, Constants.NAME_ASC).getBody()) .map(PagedList::getContent) .orElse(Collections.emptyList()); tags.addAll(page); @@ -572,7 +571,7 @@ public class TargetView extends TableView { } private List fetchActions() { - return hawkbitClient.getTargetRestApi().getActionHistory(target.getControllerId(), 0, 30, null, null) + return hawkbitClient.getTargetRestApi().getActionHistory(target.getControllerId(), null, 0, 30, null) .getBody() .getContent() .stream() @@ -757,7 +756,7 @@ public class TargetView extends TableView { "Type", e -> {}, hawkbitClient.getTargetTypeRestApi() - .getTargetTypes(0, 30, Constants.NAME_ASC, null) + .getTargetTypes(null, 0, 30, Constants.NAME_ASC) .getBody() .getContent() .toArray(new MgmtTargetType[0])