DDI resource - remove dupplicated annotations (MgmtRolloutRestResource) (#2062)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-11-17 18:42:01 +02:00
committed by GitHub
parent c3632ef272
commit 9154891573
2 changed files with 37 additions and 38 deletions

View File

@@ -169,7 +169,8 @@ public interface MgmtRolloutRestApi {
@PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtRolloutResponseBody> create(MgmtRolloutRestRequestBodyPost rolloutCreateBody); ResponseEntity<MgmtRolloutResponseBody> create(
@RequestBody MgmtRolloutRestRequestBodyPost rolloutRequestBody);
/** /**
* Handles the POST request for creating rollout. * Handles the POST request for creating rollout.
@@ -440,7 +441,8 @@ public interface MgmtRolloutRestApi {
}) })
@GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups",
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtRolloutGroupResponseBody>> getRolloutGroups(@PathVariable("rolloutId") Long rolloutId, ResponseEntity<PagedList<MgmtRolloutGroupResponseBody>> getRolloutGroups(
@PathVariable("rolloutId") Long rolloutId,
@RequestParam( @RequestParam(
value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET,
defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET)
@@ -625,5 +627,5 @@ public interface MgmtRolloutRestApi {
}) })
@PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/retry", @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/retry",
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtRolloutResponseBody> retryRollout(@PathVariable("rolloutId") final Long rolloutId); ResponseEntity<MgmtRolloutResponseBody> retryRollout(@PathVariable("rolloutId") Long rolloutId);
} }

View File

@@ -52,9 +52,6 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; 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; import org.springframework.web.bind.annotation.RestController;
/** /**
@@ -87,10 +84,10 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Override @Override
public ResponseEntity<PagedList<MgmtRolloutResponseBody>> getRollouts( public ResponseEntity<PagedList<MgmtRolloutResponseBody>> getRollouts(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam, final String rsqlParam,
final String representationModeParam) { final String representationModeParam) {
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
@@ -120,7 +117,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
} }
@Override @Override
public ResponseEntity<MgmtRolloutResponseBody> getRollout(@PathVariable("rolloutId") final Long rolloutId) { public ResponseEntity<MgmtRolloutResponseBody> getRollout(final Long rolloutId) {
final Rollout findRolloutById = rolloutManagement.getWithDetailedStatus(rolloutId) final Rollout findRolloutById = rolloutManagement.getWithDetailedStatus(rolloutId)
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId)); .orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
@@ -129,9 +126,8 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Override @Override
public ResponseEntity<MgmtRolloutResponseBody> create( public ResponseEntity<MgmtRolloutResponseBody> create(
@RequestBody final MgmtRolloutRestRequestBodyPost rolloutRequestBody) { final MgmtRolloutRestRequestBodyPost rolloutRequestBody) {
// first check the given RSQL query if it's well-formed, otherwise and // first check the given RSQL query if it's well-formed, otherwise and exception is thrown
// exception is thrown
final String targetFilterQuery = rolloutRequestBody.getTargetFilterQuery(); final String targetFilterQuery = rolloutRequestBody.getTargetFilterQuery();
if (targetFilterQuery == null) { if (targetFilterQuery == null) {
// Use RSQLParameterSyntaxException due to backwards compatibility // Use RSQLParameterSyntaxException due to backwards compatibility
@@ -175,56 +171,55 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Override @Override
public ResponseEntity<MgmtRolloutResponseBody> update( public ResponseEntity<MgmtRolloutResponseBody> update(
@PathVariable("rolloutId") final Long rolloutId, final Long rolloutId,
@RequestBody final MgmtRolloutRestRequestBodyPut rolloutUpdateBody) { final MgmtRolloutRestRequestBodyPut rolloutUpdateBody) {
final Rollout updated = final Rollout updated = rolloutManagement.update(MgmtRolloutMapper.fromRequest(entityFactory, rolloutUpdateBody, rolloutId));
rolloutManagement.update(MgmtRolloutMapper.fromRequest(entityFactory, rolloutUpdateBody, rolloutId));
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(updated, true)); return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(updated, true));
} }
@Override @Override
public ResponseEntity<Void> approve(@PathVariable("rolloutId") final Long rolloutId, final String remark) { public ResponseEntity<Void> approve(final Long rolloutId, final String remark) {
rolloutManagement.approveOrDeny(rolloutId, Rollout.ApprovalDecision.APPROVED, remark); rolloutManagement.approveOrDeny(rolloutId, Rollout.ApprovalDecision.APPROVED, remark);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> deny(@PathVariable("rolloutId") final Long rolloutId, final String remark) { public ResponseEntity<Void> deny(final Long rolloutId, final String remark) {
rolloutManagement.approveOrDeny(rolloutId, Rollout.ApprovalDecision.DENIED, remark); rolloutManagement.approveOrDeny(rolloutId, Rollout.ApprovalDecision.DENIED, remark);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId) { public ResponseEntity<Void> start(final Long rolloutId) {
this.rolloutManagement.start(rolloutId); this.rolloutManagement.start(rolloutId);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> pause(@PathVariable("rolloutId") final Long rolloutId) { public ResponseEntity<Void> pause(final Long rolloutId) {
this.rolloutManagement.pauseRollout(rolloutId); this.rolloutManagement.pauseRollout(rolloutId);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> delete(@PathVariable("rolloutId") final Long rolloutId) { public ResponseEntity<Void> delete(final Long rolloutId) {
this.rolloutManagement.delete(rolloutId); this.rolloutManagement.delete(rolloutId);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> resume(@PathVariable("rolloutId") final Long rolloutId) { public ResponseEntity<Void> resume(final Long rolloutId) {
this.rolloutManagement.resumeRollout(rolloutId); this.rolloutManagement.resumeRollout(rolloutId);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<PagedList<MgmtRolloutGroupResponseBody>> getRolloutGroups( public ResponseEntity<PagedList<MgmtRolloutGroupResponseBody>> getRolloutGroups(
@PathVariable("rolloutId") final Long rolloutId, final Long rolloutId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam, final String rsqlParam,
final String representationModeParam) { final String representationModeParam) {
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
@@ -256,8 +251,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
} }
@Override @Override
public ResponseEntity<MgmtRolloutGroupResponseBody> getRolloutGroup(@PathVariable("rolloutId") final Long rolloutId, public ResponseEntity<MgmtRolloutGroupResponseBody> getRolloutGroup(
@PathVariable("groupId") final Long groupId) { final Long rolloutId,
final Long groupId) {
findRolloutOrThrowException(rolloutId); findRolloutOrThrowException(rolloutId);
final RolloutGroup rolloutGroup = rolloutGroupManagement.getWithDetailedStatus(groupId) final RolloutGroup rolloutGroup = rolloutGroupManagement.getWithDetailedStatus(groupId)
@@ -272,12 +268,13 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
} }
@Override @Override
public ResponseEntity<PagedList<MgmtTarget>> getRolloutGroupTargets(@PathVariable("rolloutId") final Long rolloutId, public ResponseEntity<PagedList<MgmtTarget>> getRolloutGroupTargets(
@PathVariable("groupId") final Long groupId, final Long rolloutId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final Long groupId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final String sortParam,
final String rsqlParam) {
findRolloutOrThrowException(rolloutId); findRolloutOrThrowException(rolloutId);
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
@@ -298,7 +295,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
} }
@Override @Override
public ResponseEntity<Void> triggerNextGroup(@PathVariable("rolloutId") final Long rolloutId) { public ResponseEntity<Void> triggerNextGroup(final Long rolloutId) {
this.rolloutManagement.triggerNextGroup(rolloutId); this.rolloutManagement.triggerNextGroup(rolloutId);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }