From 6fafbb768d8b9c7907e3916e4b04487b3be44a58 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Sun, 17 Nov 2024 18:24:54 +0200 Subject: [PATCH] DDI resource - remove dupplicated annotations (MgmtDistributionsSetTypeResource) (#2059) Signed-off-by: Avgustin Marinov --- .../api/MgmtDistributionSetTypeRestApi.java | 19 ++++--- .../MgmtDistributionSetTypeResource.java | 49 ++++++++----------- 2 files changed, 34 insertions(+), 34 deletions(-) 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 b48968818..b83f4d4c7 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 @@ -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; /** @@ -202,7 +203,7 @@ public interface MgmtDistributionSetTypeRestApi { produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateDistributionSetType( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, - MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); + @RequestBody MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); /** * Handles the POST request of creating new DistributionSetTypes. The request body must always be a list of types. @@ -242,7 +243,7 @@ public interface MgmtDistributionSetTypeRestApi { consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSetTypes( - List distributionSetTypes); + @RequestBody List distributionSetTypes); /** * Handles the GET request of retrieving the list of mandatory software module types in that distribution set type. @@ -421,7 +422,8 @@ public interface MgmtDistributionSetTypeRestApi { }) @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}") - ResponseEntity removeMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, + ResponseEntity removeMandatoryModule( + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** @@ -457,7 +459,8 @@ public interface MgmtDistributionSetTypeRestApi { }) @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}") - ResponseEntity removeOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, + ResponseEntity removeOptionalModule( + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** @@ -500,7 +503,9 @@ public interface MgmtDistributionSetTypeRestApi { @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, MgmtId smtId); + ResponseEntity addMandatoryModule( + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, + @RequestBody MgmtId smtId); /** * Handles the POST request for adding an optional software module type to a distribution set type. @@ -542,5 +547,7 @@ public interface MgmtDistributionSetTypeRestApi { @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, MgmtId smtId); + ResponseEntity addOptionalModule( + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, + @RequestBody MgmtId smtId); } \ No newline at end of file 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 deb26a313..3f7ae8c62 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 @@ -19,7 +19,6 @@ 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.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.EntityFactory; @@ -35,9 +34,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; /** @@ -60,11 +56,10 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> getDistributionSetTypes( - @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.sanitizeDistributionSetTypeSortParam(sortParam); @@ -86,8 +81,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity getDistributionSetType( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { - + final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); final MgmtDistributionSetType response = MgmtDistributionSetTypeMapper.toResponse(foundType); @@ -97,7 +91,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR } @Override - public ResponseEntity deleteDistributionSetType(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { + public ResponseEntity deleteDistributionSetType(final Long distributionSetTypeId) { distributionSetTypeManagement.delete(distributionSetTypeId); return ResponseEntity.ok().build(); @@ -105,8 +99,8 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity updateDistributionSetType( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) { + final Long distributionSetTypeId, + final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) { final DistributionSetType updated = distributionSetTypeManagement.update(entityFactory.distributionSetType() .update(distributionSetTypeId).description(restDistributionSetType.getDescription()) .colour(restDistributionSetType.getColour())); @@ -119,7 +113,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> createDistributionSetTypes( - @RequestBody final List distributionSetTypes) { + final List distributionSetTypes) { final List createdSoftwareModules = distributionSetTypeManagement .create(MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes)); @@ -129,15 +123,15 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> getMandatoryModules( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { + final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getMandatoryModuleTypes())); } @Override public ResponseEntity getMandatoryModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { + final Long distributionSetTypeId, + final Long softwareModuleTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); @@ -150,8 +144,8 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity getOptionalModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { + final Long distributionSetTypeId, + final Long softwareModuleTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); @@ -164,15 +158,15 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> getOptionalModules( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { + final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getOptionalModuleTypes())); } @Override public ResponseEntity removeMandatoryModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { + final Long distributionSetTypeId, + final Long softwareModuleTypeId) { distributionSetTypeManagement.unassignSoftwareModuleType(distributionSetTypeId, softwareModuleTypeId); return ResponseEntity.ok().build(); @@ -180,21 +174,20 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity removeOptionalModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { + final Long distributionSetTypeId, + final Long softwareModuleTypeId) { return removeMandatoryModule(distributionSetTypeId, softwareModuleTypeId); } @Override - public ResponseEntity addMandatoryModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtId smtId) { + public ResponseEntity addMandatoryModule(final Long distributionSetTypeId, final MgmtId smtId) { distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(distributionSetTypeId, Collections.singletonList(smtId.getId())); return ResponseEntity.ok().build(); } @Override public ResponseEntity addOptionalModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtId smtId) { + final Long distributionSetTypeId, final MgmtId smtId) { distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(distributionSetTypeId, Collections.singletonList(smtId.getId())); return ResponseEntity.ok().build();