From b3718be9486ea6752b713851de282c3a479433de Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Sun, 17 Nov 2024 19:09:24 +0200 Subject: [PATCH] DDI resource - remove dupplicated annotations (MgmtTargetTypeRestResource) (#2068) Signed-off-by: Avgustin Marinov --- .../mgmt/rest/api/MgmtTargetTypeRestApi.java | 13 +++++--- .../rest/resource/MgmtTargetTypeResource.java | 31 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) 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 dc4bef565..b73df1303 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 @@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** @@ -200,7 +201,7 @@ public interface MgmtTargetTypeRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateTargetType( @PathVariable("targetTypeId") Long targetTypeId, - MgmtTargetTypeRequestBodyPut restTargetType); + @RequestBody MgmtTargetTypeRequestBodyPut restTargetType); /** * Handles the POST request of creating new Target Types. The request body must always be a list of types. @@ -240,7 +241,7 @@ public interface MgmtTargetTypeRestApi { @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createTargetTypes(List targetTypes); + ResponseEntity> createTargetTypes(@RequestBody List targetTypes); /** * Handles the GET request of retrieving the list of compatible distribution set types in that target type. @@ -273,7 +274,8 @@ public interface MgmtTargetTypeRestApi { }) @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getCompatibleDistributionSets(@PathVariable("targetTypeId") Long targetTypeId); + ResponseEntity> getCompatibleDistributionSets( + @PathVariable("targetTypeId") Long targetTypeId); /** * Handles DELETE request for removing the compatibility of a distribution set type from the target type. @@ -349,6 +351,7 @@ public interface MgmtTargetTypeRestApi { }) @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addCompatibleDistributionSets(@PathVariable("targetTypeId") final Long targetTypeId, - final List distributionSetTypeIds); + ResponseEntity addCompatibleDistributionSets( + @PathVariable("targetTypeId") Long targetTypeId, + @RequestBody List distributionSetTypeIds); } \ 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 5a9c56c8c..77b57ff62 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 @@ -33,9 +33,6 @@ 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.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -55,10 +52,10 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { @Override public ResponseEntity> getTargetTypes( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + 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); @@ -79,7 +76,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { } @Override - public ResponseEntity getTargetType(@PathVariable("targetTypeId") final Long targetTypeId) { + public ResponseEntity getTargetType(final Long targetTypeId) { final TargetType foundType = findTargetTypeWithExceptionIfNotFound(targetTypeId); final MgmtTargetType response = MgmtTargetTypeMapper.toResponse(foundType); MgmtTargetTypeMapper.addLinks(response); @@ -87,7 +84,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { } @Override - public ResponseEntity deleteTargetType(@PathVariable("targetTypeId") final Long targetTypeId) { + public ResponseEntity deleteTargetType(final Long targetTypeId) { log.debug("Delete {} target type", targetTypeId); targetTypeManagement.delete(targetTypeId); return ResponseEntity.ok().build(); @@ -95,8 +92,8 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { @Override public ResponseEntity updateTargetType( - @PathVariable("targetTypeId") final Long targetTypeId, - @RequestBody final MgmtTargetTypeRequestBodyPut restTargetType) { + final Long targetTypeId, + final MgmtTargetTypeRequestBodyPut restTargetType) { final TargetType updated = targetTypeManagement .update(entityFactory.targetType().update(targetTypeId).name(restTargetType.getName()) .description(restTargetType.getDescription()).colour(restTargetType.getColour())); @@ -106,7 +103,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { } @Override - public ResponseEntity> createTargetTypes(@RequestBody final List targetTypes) { + public ResponseEntity> createTargetTypes(final List targetTypes) { final List createdTargetTypes = targetTypeManagement .create(MgmtTargetTypeMapper.targetFromRequest(entityFactory, targetTypes)); @@ -115,23 +112,23 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { @Override public ResponseEntity> getCompatibleDistributionSets( - @PathVariable("targetTypeId") final Long targetTypeId) { + final Long targetTypeId) { final TargetType foundType = findTargetTypeWithExceptionIfNotFound(targetTypeId); return ResponseEntity.ok(MgmtDistributionSetTypeMapper.toListResponse(foundType.getCompatibleDistributionSetTypes())); } @Override public ResponseEntity removeCompatibleDistributionSet( - @PathVariable("targetTypeId") final Long targetTypeId, - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { + final Long targetTypeId, + final Long distributionSetTypeId) { targetTypeManagement.unassignDistributionSetType(targetTypeId, distributionSetTypeId); return ResponseEntity.ok().build(); } @Override public ResponseEntity addCompatibleDistributionSets( - @PathVariable("targetTypeId") final Long targetTypeId, - @RequestBody final List distributionSetTypeIds) { + final Long targetTypeId, + final List distributionSetTypeIds) { targetTypeManagement.assignCompatibleDistributionSetTypes( targetTypeId, distributionSetTypeIds.stream().map(MgmtDistributionSetTypeAssignment::getId).collect(Collectors.toList())); return ResponseEntity.ok().build();