diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java index f39e0d0e3..377eedebf 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java @@ -169,7 +169,8 @@ public interface MgmtRolloutRestApi { @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity create(MgmtRolloutRestRequestBodyPost rolloutCreateBody); + ResponseEntity create( + @RequestBody MgmtRolloutRestRequestBodyPost rolloutRequestBody); /** * Handles the POST request for creating rollout. @@ -440,7 +441,8 @@ public interface MgmtRolloutRestApi { }) @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getRolloutGroups(@PathVariable("rolloutId") Long rolloutId, + ResponseEntity> getRolloutGroups( + @PathVariable("rolloutId") Long rolloutId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @@ -625,5 +627,5 @@ public interface MgmtRolloutRestApi { }) @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/retry", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity retryRollout(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity retryRollout(@PathVariable("rolloutId") Long rolloutId); } \ No newline at end of file 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 eda9d0cb4..9fb132cad 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 @@ -52,9 +52,6 @@ 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.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -87,10 +84,10 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { @Override public ResponseEntity> getRollouts( - @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 String representationModeParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -120,7 +117,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { } @Override - public ResponseEntity getRollout(@PathVariable("rolloutId") final Long rolloutId) { + public ResponseEntity getRollout(final Long rolloutId) { final Rollout findRolloutById = rolloutManagement.getWithDetailedStatus(rolloutId) .orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId)); @@ -129,9 +126,8 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { @Override public ResponseEntity create( - @RequestBody final MgmtRolloutRestRequestBodyPost rolloutRequestBody) { - // first check the given RSQL query if it's well-formed, otherwise and - // exception is thrown + final MgmtRolloutRestRequestBodyPost rolloutRequestBody) { + // first check the given RSQL query if it's well-formed, otherwise and exception is thrown final String targetFilterQuery = rolloutRequestBody.getTargetFilterQuery(); if (targetFilterQuery == null) { // Use RSQLParameterSyntaxException due to backwards compatibility @@ -175,56 +171,55 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { @Override public ResponseEntity update( - @PathVariable("rolloutId") final Long rolloutId, - @RequestBody final MgmtRolloutRestRequestBodyPut rolloutUpdateBody) { - final Rollout updated = - rolloutManagement.update(MgmtRolloutMapper.fromRequest(entityFactory, rolloutUpdateBody, rolloutId)); + final Long rolloutId, + final MgmtRolloutRestRequestBodyPut rolloutUpdateBody) { + final Rollout updated = rolloutManagement.update(MgmtRolloutMapper.fromRequest(entityFactory, rolloutUpdateBody, rolloutId)); return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(updated, true)); } @Override - public ResponseEntity approve(@PathVariable("rolloutId") final Long rolloutId, final String remark) { + public ResponseEntity approve(final Long rolloutId, final String remark) { rolloutManagement.approveOrDeny(rolloutId, Rollout.ApprovalDecision.APPROVED, remark); return ResponseEntity.ok().build(); } @Override - public ResponseEntity deny(@PathVariable("rolloutId") final Long rolloutId, final String remark) { + public ResponseEntity deny(final Long rolloutId, final String remark) { rolloutManagement.approveOrDeny(rolloutId, Rollout.ApprovalDecision.DENIED, remark); return ResponseEntity.ok().build(); } @Override - public ResponseEntity start(@PathVariable("rolloutId") final Long rolloutId) { + public ResponseEntity start(final Long rolloutId) { this.rolloutManagement.start(rolloutId); return ResponseEntity.ok().build(); } @Override - public ResponseEntity pause(@PathVariable("rolloutId") final Long rolloutId) { + public ResponseEntity pause(final Long rolloutId) { this.rolloutManagement.pauseRollout(rolloutId); return ResponseEntity.ok().build(); } @Override - public ResponseEntity delete(@PathVariable("rolloutId") final Long rolloutId) { + public ResponseEntity delete(final Long rolloutId) { this.rolloutManagement.delete(rolloutId); return ResponseEntity.ok().build(); } @Override - public ResponseEntity resume(@PathVariable("rolloutId") final Long rolloutId) { + public ResponseEntity resume(final Long rolloutId) { this.rolloutManagement.resumeRollout(rolloutId); return ResponseEntity.ok().build(); } @Override public ResponseEntity> getRolloutGroups( - @PathVariable("rolloutId") final Long rolloutId, - @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 Long rolloutId, + 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); @@ -256,8 +251,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { } @Override - public ResponseEntity getRolloutGroup(@PathVariable("rolloutId") final Long rolloutId, - @PathVariable("groupId") final Long groupId) { + public ResponseEntity getRolloutGroup( + final Long rolloutId, + final Long groupId) { findRolloutOrThrowException(rolloutId); final RolloutGroup rolloutGroup = rolloutGroupManagement.getWithDetailedStatus(groupId) @@ -272,12 +268,13 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { } @Override - public ResponseEntity> getRolloutGroupTargets(@PathVariable("rolloutId") final Long rolloutId, - @PathVariable("groupId") final Long groupId, - @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) { + public ResponseEntity> getRolloutGroupTargets( + final Long rolloutId, + final Long groupId, + final int pagingOffsetParam, + final int pagingLimitParam, + final String sortParam, + final String rsqlParam) { findRolloutOrThrowException(rolloutId); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -298,7 +295,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { } @Override - public ResponseEntity triggerNextGroup(@PathVariable("rolloutId") final Long rolloutId) { + public ResponseEntity triggerNextGroup(final Long rolloutId) { this.rolloutManagement.triggerNextGroup(rolloutId); return ResponseEntity.ok().build(); }