diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java deleted file mode 100644 index ff5c2a72b..000000000 --- a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2015 Bosch Software Innovations GmbH and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.hawkbit.ddi.rest.api; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; - -/** - * Constants for the direct device integration rest resources. - */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class DdiRestConstants { - - /** - * The base URL mapping of the direct device integration rest resources. - */ - public static final String BASE_V1_REQUEST_MAPPING = "/{tenant}/controller/v1"; - - /** - * Deployment action resources. - */ - public static final String DEPLOYMENT_BASE = "deploymentBase"; - /** - * Confirmation base resource. - */ - public static final String CONFIRMATION_BASE = "confirmationBase"; - /** - * Installed action resources. - */ - public static final String INSTALLED_BASE = "installedBase"; - /** - * Feedback channel. - */ - public static final String FEEDBACK = "feedback"; - /** - * Cancel action resources. - */ - public static final String CANCEL_ACTION = "cancelAction"; - /** - * Config data action resources. - */ - public static final String CONFIG_DATA = "configData"; - /** - * Activate auto-confirm - */ - public static final String ACTIVATE_AUTO_CONFIRM = "activateAutoConfirm"; - /** - * Deactivate auto-confirm - */ - public static final String DEACTIVATE_AUTO_CONFIRM = "deactivateAutoConfirm"; - - /** - * Media type for CBOR content. - */ - public static final String MEDIA_TYPE_APPLICATION_CBOR = "application/cbor"; - - /** - * File suffix for MDH hash download (see Linux md5sum). - */ - public static final String ARTIFACT_MD5_DOWNLOAD_SUFFIX = ".MD5SUM"; - /** - * Default value specifying that no action history to be sent as part of response to deploymentBase - * {@link DdiRootControllerRestApi#getControllerDeploymentBaseAction}, {@link DdiRootControllerRestApi#getConfirmationBaseAction}. - */ - public static final String NO_ACTION_HISTORY = "0"; -} \ No newline at end of file diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java index 973de28e6..881087ac1 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java @@ -9,10 +9,6 @@ */ package org.eclipse.hawkbit.ddi.rest.api; -import static org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants.BASE_V1_REQUEST_MAPPING; -import static org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants.DEPLOYMENT_BASE; -import static org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants.FEEDBACK; -import static org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GONE_410; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.INTERNAL_SERVER_ERROR_500; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.METHOD_NOT_ALLOWED_405; @@ -66,6 +62,57 @@ import org.springframework.web.bind.annotation.RequestParam; @Tag(name = "DDI Root Controller", description = "REST resource handling for root controller CRUD operations") public interface DdiRootControllerRestApi { + /** + * The base URL mapping of the direct device integration rest resources. + */ + String CONTROLLER_V1 = "/{tenant}/controller/v1"; + + /** + * Deployment action resources. + */ + String DEPLOYMENT_BASE = "deploymentBase"; + /** + * Confirmation base resource. + */ + String CONFIRMATION_BASE = "confirmationBase"; + /** + * Installed action resources. + */ + String INSTALLED_BASE = "installedBase"; + /** + * Feedback channel. + */ + String FEEDBACK = "feedback"; + /** + * Cancel action resources. + */ + String CANCEL_ACTION = "cancelAction"; + /** + * Config data action resources. + */ + String CONFIG_DATA = "configData"; + /** + * Activate auto-confirm + */ + String ACTIVATE_AUTO_CONFIRM = "activateAutoConfirm"; + /** + * Deactivate auto-confirm + */ + String DEACTIVATE_AUTO_CONFIRM = "deactivateAutoConfirm"; + /** + * Media type for CBOR content. + */ + String MEDIA_TYPE_APPLICATION_CBOR = "application/cbor"; + /** + * File suffix for MDH hash download (see Linux md5sum). + */ + String ARTIFACT_MD5_DOWNLOAD_SUFFIX = ".MD5SUM"; + /** + * Default value specifying that no action history to be sent as part of response to deploymentBase + * {@link DdiRootControllerRestApi#getControllerDeploymentBaseAction}, {@link DdiRootControllerRestApi#getConfirmationBaseAction}. + */ + String NO_ACTION_HISTORY = "0"; + /** * Returns all artifacts of a given software module and target. * @@ -77,7 +124,7 @@ public interface DdiRootControllerRestApi { @Operation(summary = "Return all artifacts of a given software module and target", description = "Returns all artifacts that are assigned to the software module") @GetIfExistResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts", + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity> getSoftwareModulesArtifacts( @PathVariable("tenant") String tenant, @@ -100,7 +147,7 @@ public interface DdiRootControllerRestApi { Note: deployments have to be confirmed in order to move on to the next action. Cancellations have to be confirmed or rejected.""") @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}", + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity getControllerBase( @PathVariable("tenant") String tenant, @@ -117,15 +164,15 @@ public interface DdiRootControllerRestApi { * @return response of the servlet which in case of success is status code * {@link HttpStatus#OK} or in case of partial download {@link HttpStatus#PARTIAL_CONTENT}. */ - @Operation(summary = "Artifact download", description = "Handles GET DdiArtifact download request. This could be " + - "full or partial (as specified by RFC7233 (Range Requests)) download request.") + @Operation(summary = "Artifact download", + description = "Handles GET DdiArtifact download request. This could be full or partial (as specified by RFC7233 (Range Requests)) " + + "download request.") @GetResponses @ApiResponses(value = { @ApiResponse(responseCode = INTERNAL_SERVER_ERROR_500, description = "Artifact download or decryption failed", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = BASE_V1_REQUEST_MAPPING + - "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}") + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}") ResponseEntity downloadArtifact( @PathVariable("tenant") String tenant, @PathVariable("controllerId") String controllerId, @@ -144,8 +191,8 @@ public interface DdiRootControllerRestApi { @Operation(summary = "MD5 checksum download", description = "Handles GET {@link DdiArtifact} MD5 checksum file download request.") @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}" + - DdiRestConstants.ARTIFACT_MD5_DOWNLOAD_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE) + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}" + ARTIFACT_MD5_DOWNLOAD_SUFFIX, + produces = MediaType.TEXT_PLAIN_VALUE) ResponseEntity downloadArtifactMd5( @PathVariable("tenant") String tenant, @PathVariable("controllerId") String controllerId, @@ -176,14 +223,14 @@ public interface DdiRootControllerRestApi { runtime. """) @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DEPLOYMENT_BASE + "/{actionId}", + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/" + DEPLOYMENT_BASE + "/{actionId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity getControllerDeploymentBaseAction( @PathVariable("tenant") String tenant, @PathVariable("controllerId") @NotEmpty String controllerId, @PathVariable("actionId") @NotNull Long actionId, @RequestParam(value = "c", required = false, defaultValue = "-1") int resource, - @RequestParam(value = "actionHistory", defaultValue = DdiRestConstants.NO_ACTION_HISTORY) + @RequestParam(value = "actionHistory", defaultValue = NO_ACTION_HISTORY) @Schema(description = """ (Optional) GET parameter to retrieve a given number of messages which are previously provided by the device. Useful if the devices sent state information to the feedback channel and never stored them @@ -208,7 +255,7 @@ public interface DdiRootControllerRestApi { @ApiResponse(responseCode = GONE_410, description = "Action is not active anymore.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DEPLOYMENT_BASE + + @PostMapping(value = CONTROLLER_V1 + "/{controllerId}/" + DEPLOYMENT_BASE + "/{actionId}/" + FEEDBACK, consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity postDeploymentBaseActionFeedback( @Valid @RequestBody DdiActionFeedback feedback, @@ -229,7 +276,7 @@ public interface DdiRootControllerRestApi { information that will allow the server to identify the device on a hardware level (e.g. hardware revision, mac address, serial number etc.).""") @PutResponses - @PutMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIG_DATA, + @PutMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CONFIG_DATA, consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity putConfigData( @Valid @RequestBody DdiConfigData configData, @@ -248,7 +295,7 @@ public interface DdiRootControllerRestApi { The Hawkbit server might cancel an operation, e.g. an unfinished update has a successor. It is up to the provisioning target to decide to accept the cancellation or reject it.""") @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CANCEL_ACTION + "/{actionId}", + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CANCEL_ACTION + "/{actionId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity getControllerCancelAction( @PathVariable("tenant") String tenant, @@ -272,7 +319,7 @@ public interface DdiRootControllerRestApi { @ApiResponses(value = { @ApiResponse(responseCode = METHOD_NOT_ALLOWED_405, description = "Software module is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CANCEL_ACTION + "/{actionId}/" + + @PostMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CANCEL_ACTION + "/{actionId}/" + FEEDBACK, consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity postCancelActionFeedback( @Valid @RequestBody DdiActionFeedback feedback, @@ -305,13 +352,13 @@ public interface DdiRootControllerRestApi { runtime. """) @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.INSTALLED_BASE + "/{actionId}", + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/" + INSTALLED_BASE + "/{actionId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity getControllerInstalledAction( @PathVariable("tenant") String tenant, @PathVariable("controllerId") @NotEmpty String controllerId, @PathVariable("actionId") @NotNull Long actionId, - @RequestParam(value = "actionHistory", defaultValue = DdiRestConstants.NO_ACTION_HISTORY) Integer actionHistoryMessageCount); + @RequestParam(value = "actionHistory", defaultValue = NO_ACTION_HISTORY) Integer actionHistoryMessageCount); /** * Returns the confirmation base with the current auto-confirmation state for a given controllerId and toggle links. In case there are @@ -328,7 +375,7 @@ public interface DdiRootControllerRestApi { Reference links to switch the auto-confirmation state are exposed as well. """) @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE, + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CONFIRMATION_BASE, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity getConfirmationBase( @PathVariable("tenant") String tenant, @@ -360,14 +407,14 @@ public interface DdiRootControllerRestApi { runtime. """) @GetResponses - @GetMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/{actionId}", + @GetMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CONFIRMATION_BASE + "/{actionId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity getConfirmationBaseAction( @PathVariable("tenant") String tenant, @PathVariable("controllerId") @NotEmpty String controllerId, @PathVariable("actionId") @NotNull Long actionId, @RequestParam(value = "c", required = false, defaultValue = "-1") int resource, - @RequestParam(value = "actionHistory", defaultValue = DdiRestConstants.NO_ACTION_HISTORY) Integer actionHistoryMessageCount); + @RequestParam(value = "actionHistory", defaultValue = NO_ACTION_HISTORY) Integer actionHistoryMessageCount); /** * This is the feedback channel for the {@link DdiConfirmationBaseAction} action. @@ -388,8 +435,7 @@ public interface DdiRootControllerRestApi { @ApiResponse(responseCode = GONE_410, description = "Action is not active anymore.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/{actionId}/" + - FEEDBACK, + @PostMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CONFIRMATION_BASE + "/{actionId}/" + FEEDBACK, consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity postConfirmationActionFeedback( @Valid @RequestBody DdiConfirmationFeedback feedback, @@ -413,8 +459,8 @@ public interface DdiRootControllerRestApi { be automatically confirmed, as long as auto-confirmation is active. """) @PostUpdateResponses - @PostMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/" + - DdiRestConstants.ACTIVATE_AUTO_CONFIRM, consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) + @PostMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CONFIRMATION_BASE + "/" + ACTIVATE_AUTO_CONFIRM, + consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity activateAutoConfirmation( @PathVariable("tenant") String tenant, @PathVariable("controllerId") @NotEmpty String controllerId, @@ -432,8 +478,7 @@ public interface DdiRootControllerRestApi { while all future actions need to be confirmed, before processing with the deployment. """) @PostUpdateResponses - @PostMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/" + - DdiRestConstants.DEACTIVATE_AUTO_CONFIRM) + @PostMapping(value = CONTROLLER_V1 + "/{controllerId}/" + CONFIRMATION_BASE + "/" + DEACTIVATE_AUTO_CONFIRM) ResponseEntity deactivateAutoConfirmation( @PathVariable("tenant") String tenant, @PathVariable("controllerId") @NotEmpty String controllerId); @@ -455,7 +500,7 @@ public interface DdiRootControllerRestApi { @ApiResponse(responseCode = GONE_410, description = "Action is not active anymore.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.INSTALLED_BASE, + @PutMapping(value = CONTROLLER_V1 + "/{controllerId}/" + INSTALLED_BASE, consumes = { APPLICATION_JSON_VALUE, MEDIA_TYPE_APPLICATION_CBOR }) ResponseEntity setAssignedOfflineVersion( @Valid @RequestBody DdiAssignedVersion ddiAssignedVersion, diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java index 2e4fa3910..1ef235662 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java @@ -26,7 +26,7 @@ import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationBase; import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase; import org.eclipse.hawkbit.ddi.json.model.DdiMetadata; import org.eclipse.hawkbit.ddi.json.model.DdiPolling; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.model.Action; @@ -54,19 +54,19 @@ public final class DataConversionHelper { confirmationBase.add(WebMvcLinkBuilder .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, AccessContext.tenant()) .deactivateAutoConfirmation(AccessContext.tenant(), controllerId)) - .withRel(DdiRestConstants.DEACTIVATE_AUTO_CONFIRM).expand()); + .withRel(DdiRootControllerRestApi.DEACTIVATE_AUTO_CONFIRM).expand()); } else { confirmationBase.add(WebMvcLinkBuilder .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, AccessContext.tenant()) .activateAutoConfirmation(AccessContext.tenant(), controllerId, null)) - .withRel(DdiRestConstants.ACTIVATE_AUTO_CONFIRM).expand()); + .withRel(DdiRootControllerRestApi.ACTIVATE_AUTO_CONFIRM).expand()); } if (activeAction != null && activeAction.isWaitingConfirmation()) { confirmationBase.add(WebMvcLinkBuilder .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, AccessContext.tenant()) .getConfirmationBaseAction(AccessContext.tenant(), controllerId, activeAction.getId(), calculateEtag(activeAction), null)) - .withRel(DdiRestConstants.CONFIRMATION_BASE).expand()); + .withRel(DdiRootControllerRestApi.CONFIRMATION_BASE).expand()); } return confirmationBase; @@ -84,14 +84,14 @@ public final class DataConversionHelper { .methodOn(DdiRootController.class, AccessContext.tenant()) .getConfirmationBaseAction(AccessContext.tenant(), target.getControllerId(), activeAction.getId(), calculateEtag(activeAction), null)) - .withRel(DdiRestConstants.CONFIRMATION_BASE).expand()); + .withRel(DdiRootControllerRestApi.CONFIRMATION_BASE).expand()); } else if (activeAction.isCancelingOrCanceled()) { result.add(WebMvcLinkBuilder .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, AccessContext.tenant()) .getControllerCancelAction(AccessContext.tenant(), target.getControllerId(), activeAction.getId())) - .withRel(DdiRestConstants.CANCEL_ACTION).expand()); + .withRel(DdiRootControllerRestApi.CANCEL_ACTION).expand()); } else { // we need to add the hashcode here of the actionWithStatus because the action might // have changed from 'soft' to 'forced' type, and we need to change the payload of the @@ -101,7 +101,7 @@ public final class DataConversionHelper { .getControllerDeploymentBaseAction( AccessContext.tenant(), target.getControllerId(), activeAction.getId(), calculateEtag(activeAction), null)) - .withRel(DdiRestConstants.DEPLOYMENT_BASE).expand()); + .withRel(DdiRootControllerRestApi.DEPLOYMENT_BASE).expand()); } } @@ -111,7 +111,7 @@ public final class DataConversionHelper { .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, AccessContext.tenant()) .getControllerInstalledAction(AccessContext.tenant(), target.getControllerId(), installedAction.getId(), null)) - .withRel(DdiRestConstants.INSTALLED_BASE).expand()); + .withRel(DdiRootControllerRestApi.INSTALLED_BASE).expand()); } if (target.isRequestControllerAttributes()) { @@ -120,7 +120,7 @@ public final class DataConversionHelper { .methodOn(DdiRootController.class, AccessContext.tenant()) // doesn't really call the putConfigData with null, just create the link .putConfigData(null, AccessContext.tenant(), target.getControllerId())) - .withRel(DdiRestConstants.CONFIG_DATA).expand()); + .withRel(DdiRootControllerRestApi.CONFIG_DATA).expand()); } return result; diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java index 72c196946..66ea0b6f5 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java @@ -45,7 +45,6 @@ import org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType; import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase; import org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult; import org.eclipse.hawkbit.ddi.json.model.DdiUpdateMode; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ConfirmationManagement; @@ -581,7 +580,7 @@ public class DdiRootController implements DdiRootControllerRestApi { final byte[] content = (md5Hash + " " + filename).getBytes(StandardCharsets.US_ASCII); response.setContentType("text/plain"); response.setContentLength(content.length); - response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename + DdiRestConstants.ARTIFACT_MD5_DOWNLOAD_SUFFIX); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename + DdiRootControllerRestApi.ARTIFACT_MD5_DOWNLOAD_SUFFIX); response.getOutputStream().write(content); } @@ -740,7 +739,7 @@ public class DdiRootController implements DdiRootControllerRestApi { private Optional generateDdiActionHistory(final Action action, final Integer actionHistoryMessageCount) { final List actionHistoryMessages = controllerManagement.getActionHistoryMessages( action.getId(), - actionHistoryMessageCount == null ? Integer.parseInt(DdiRestConstants.NO_ACTION_HISTORY) : actionHistoryMessageCount); + actionHistoryMessageCount == null ? Integer.parseInt(DdiRootControllerRestApi.NO_ACTION_HISTORY) : actionHistoryMessageCount); return actionHistoryMessages.isEmpty() ? Optional.empty() : Optional.of(new DdiActionHistory(action.getStatus().name(), actionHistoryMessages)); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index 6a8c41e02..75d511e5c 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -28,7 +28,7 @@ import java.util.List; import org.eclipse.hawkbit.context.AccessContext; import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiStatus; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; @@ -68,10 +68,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final byte[] result = mvc .perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId(), AccessContext.tenant()) - .accept(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR)) + .accept(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) - .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR)) + .andExpect(content().contentType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR)) .andReturn().getResponse() .getContentAsByteArray(); assertThat(JsonPathUtils. evaluate(cborToJson(result), "$.id")) @@ -83,7 +83,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId() + "/feedback", AccessContext.tenant()) .content(jsonToCbor(getJsonProceedingCancelActionFeedback())) - .contentType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR).accept(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR)) + .contentType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR).accept(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java index 65b5934ce..b97009432 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.hawkbit.context.AccessContext; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException; @@ -65,7 +65,7 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest { mvc.perform(put(TARGET1_CONFIG_DATA_PATH, AccessContext.tenant()) .content(jsonToCbor(JsonBuilder.configData(attributes).toString())) - .contentType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR)) + .contentType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); assertThat(targetManagement.getControllerAttributes(TARGET1_ID)).isEqualTo(attributes); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java index ff3591f4e..9fb55f4c8 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java @@ -26,7 +26,7 @@ import java.util.stream.Stream; import org.eclipse.hawkbit.context.AccessContext; import org.eclipse.hawkbit.ddi.json.model.DdiActivateAutoConfirmation; import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationFeedback; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; @@ -150,11 +150,11 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0); // get confirmation base - performGet(CONFIRMATION_BASE_ACTION, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), + performGet(CONFIRMATION_BASE_ACTION, MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), AccessContext.tenant(), target.getControllerId(), action.getId().toString()); // get artifacts - performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), + performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), AccessContext.tenant(), target.getControllerId(), String.valueOf(softwareModuleId)); } diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 4936acf4c..d2d41a83f 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -30,7 +30,7 @@ import org.assertj.core.api.Condition; import org.eclipse.hawkbit.context.AccessContext; import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiStatus; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; @@ -96,17 +96,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0); // get deployment base - performGet(DEPLOYMENT_BASE, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), + performGet(DEPLOYMENT_BASE, MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), AccessContext.tenant(), target.getControllerId(), action.getId().toString()); // get artifacts - performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), + performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), AccessContext.tenant(), target.getControllerId(), String.valueOf(softwareModuleId)); final byte[] feedback = jsonToCbor(getJsonProceedingDeploymentActionFeedback()); postDeploymentFeedback( - MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), target.getControllerId(), action.getId(), feedback, + MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), target.getControllerId(), action.getId(), feedback, status().isOk()); } diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java index 911149131..df89bff9b 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java @@ -30,7 +30,7 @@ import java.util.stream.Stream; import org.eclipse.hawkbit.context.AccessContext; import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiStatus; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent; @@ -90,11 +90,11 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { postDeploymentFeedback(target.getControllerId(), actionId, getJsonClosedDeploymentActionFeedback(), status().isOk()); // get installed base - performGet(INSTALLED_BASE, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), + performGet(INSTALLED_BASE, MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), AccessContext.tenant(), target.getControllerId(), actionId.toString()); // get artifacts - performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR), + performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.parseMediaType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR), status().isOk(), AccessContext.tenant(), target.getControllerId(), String.valueOf(softwareModuleId)); } diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java index 7e83c1d87..ab21e1a38 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java @@ -41,7 +41,7 @@ import org.eclipse.hawkbit.auth.SpPermission; import org.eclipse.hawkbit.context.AccessContext; import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiStatus; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent; @@ -94,9 +94,9 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { */ @Test void rootPollResourceCbor() throws Exception { - mvc.perform(get(CONTROLLER_BASE, AccessContext.tenant(), 4711).accept(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR)) + mvc.perform(get(CONTROLLER_BASE, AccessContext.tenant(), 4711).accept(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR)) .andDo(MockMvcResultPrinter.print()) - .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_APPLICATION_CBOR)) + .andExpect(content().contentType(DdiRootControllerRestApi.MEDIA_TYPE_APPLICATION_CBOR)) .andExpect(status().isOk()); } diff --git a/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerDownloadSecurityConfiguration.java b/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerDownloadSecurityConfiguration.java index 4e8943cab..92c93b799 100644 --- a/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerDownloadSecurityConfiguration.java +++ b/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerDownloadSecurityConfiguration.java @@ -13,7 +13,7 @@ import java.util.List; import lombok.extern.slf4j.Slf4j; import org.eclipse.hawkbit.context.Mdc; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.rest.SecurityManagedConfiguration; import org.eclipse.hawkbit.rest.security.DosFilter; @@ -44,7 +44,7 @@ import org.springframework.security.web.access.intercept.AuthorizationFilter; class ControllerDownloadSecurityConfiguration { private static final String DDI_DL_ANT_MATCHER = - DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/*"; + DdiRootControllerRestApi.CONTROLLER_V1 + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/*"; private final ControllerManagement controllerManagement; private final DdiSecurityProperties ddiSecurityConfiguration; diff --git a/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java b/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java index 09cfb1829..80b20d2b2 100644 --- a/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java +++ b/hawkbit-ddi/hawkbit-ddi-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/ddi/ControllerSecurityConfiguration.java @@ -13,7 +13,7 @@ import java.util.List; import lombok.extern.slf4j.Slf4j; import org.eclipse.hawkbit.context.Mdc; -import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; +import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.rest.SecurityManagedConfiguration; import org.eclipse.hawkbit.rest.security.DosFilter; @@ -46,7 +46,7 @@ import org.springframework.security.web.access.intercept.AuthorizationFilter; @EnableWebSecurity class ControllerSecurityConfiguration { - private static final String[] DDI_ANT_MATCHERS = { DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/**" }; + private static final String[] DDI_ANT_MATCHERS = { DdiRootControllerRestApi.CONTROLLER_V1 + "/**" }; private final ControllerManagement controllerManagement; private final DdiSecurityProperties ddiSecurityConfiguration; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java index 74769bcd6..6d4d3c517 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTarget.java @@ -86,6 +86,22 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus; }""") public class MgmtTarget extends MgmtNamedEntity { + /** + * The target URL mapping, href link for assigned target type. + */ + public static final String TARGET_TYPE = "targetType"; + /** + * The target URL mapping, href link for autoConfirm state of a target. + */ + public static final String AUTO_CONFIRM = "autoConfirm"; + /** + * The target URL mapping, href link for target actions. + */ + public static final String TARGET_V1_ACTIONS = "actions"; + /** + * The target URL mapping, href link for canceled actions. + */ + public static final String TARGET_V1_ACTION_STATUS = "status"; @JsonProperty(required = true) @Schema(description = "Controller ID", example = "123") private String controllerId; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirm.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirm.java index ea1a8fbfc..46bf7177b 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirm.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirm.java @@ -48,6 +48,14 @@ import org.springframework.hateoas.RepresentationModel; }""") public class MgmtTargetAutoConfirm extends RepresentationModel { + /** + * The target URL mapping, href link activate auto-confirm on a target. + */ + public static final String ACTIVATE = "activate"; + /** + * The target URL mapping, href link deactivate auto-confirm on a target. + */ + public static final String DEACTIVATE = "deactivate"; @NotNull @Schema(description = "Flag if auto confirm is active", example = "true") private boolean active; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java index 76f878d28..33a9875f2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java @@ -10,9 +10,17 @@ package org.eclipse.hawkbit.mgmt.rest.api; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ACTION_ORDER; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -24,8 +32,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -37,11 +43,12 @@ import org.springframework.web.bind.annotation.RequestParam; * REST API providing (read-only) access to actions. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Actions", description = "REST API providing (read-only) access to actions.", +@Tag(name = "Actions", description = "REST API providing (read-only) access to actions.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = ACTION_ORDER))) public interface MgmtActionRestApi { + String ACTIONS_V1 = MgmtRestConstants.REST_V1 + "/actions"; + /** * Handles the GET request of retrieving all actions. * @@ -56,33 +63,23 @@ public interface MgmtActionRestApi { */ @Operation(summary = "Return all actions", description = "Handles the GET request of retrieving all actions.") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ACTIONS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getActions( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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_REPRESENTATION_MODE, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) + @RequestParam(value = REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) @Schema(description = """ The representation mode. Can be "full" or "compact". Defaults to "compact" """) @@ -94,11 +91,9 @@ public interface MgmtActionRestApi { * @param actionId The ID of the requested action * @return the {@link MgmtAction} */ - @Operation(summary = "Return action by id", - description = "Handles the GET request of retrieving a single action by actionId.") + @Operation(summary = "Return action by id", description = "Handles the GET request of retrieving a single action by actionId.") @GetResponses - @GetMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ACTIONS_V1 + "/{actionId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAction(@PathVariable("actionId") Long actionId); /** @@ -109,7 +104,7 @@ public interface MgmtActionRestApi { */ @Operation(summary = "Delete a single action by id", description = "Handles the DELETE request for single action within Bosch IoT Rollouts. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}") + @DeleteMapping(value = ACTIONS_V1 + "/{actionId}") ResponseEntity deleteAction(@PathVariable("actionId") Long actionId); /** @@ -121,12 +116,10 @@ public interface MgmtActionRestApi { */ @Operation(summary = "Delete multiple actions by list OR rsql filter", description = "Handles the DELETE request for multiple actions within Bosch IoT Rollouts. Either action id list OR rsql filter SHOULD be provided. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) + @DeleteMapping(value = ACTIONS_V1) ResponseEntity deleteActions( @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false, defaultValue = "") - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") + @Schema(description = "Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for available fields.") String rsqlParam, @Schema(description = "List of action ids to be deleted", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "[253, 255]") @RequestBody(required = false) diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java index 69026a22a..4290f3ae0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java @@ -11,33 +11,34 @@ package org.eclipse.hawkbit.mgmt.rest.api; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.BASIC_AUTH_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import io.swagger.v3.oas.annotations.extensions.Extension; import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.auth.MgmtUserInfo; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; /** - * Api for handling basic authentication user validation + * REST API for handling basic authentication user validation */ @SuppressWarnings("squid:S1609") -@Tag( - name = "Basic Authentication", description = "API for basic authentication user validation.", +@Tag(name = "Basic Authentication", description = "API for basic authentication user validation.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = BASIC_AUTH_ORDER))) // no request mapping specified here to avoid CVE-2021-22044 in Feign client public interface MgmtBasicAuthRestApi { + String USERINFO_V1 = MgmtRestConstants.REST_V1 + "/userinfo"; + /** * Handles the GET request of basic auth. * * @return the userinfo with status OK. */ @GetResponses - @GetMapping(value = MgmtRestConstants.AUTH_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = USERINFO_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity validateBasicAuth(); } \ No newline at end of file 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 a5dce5d37..2df7b3df0 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 @@ -10,6 +10,10 @@ package org.eclipse.hawkbit.mgmt.rest.api; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTION_SET_ORDER; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; @@ -19,6 +23,8 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.NOT_FOUND_404; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutNoContentResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -49,8 +55,6 @@ import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateNoContentResponses; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -61,14 +65,15 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** - * REST Resource handling for DistributionSet CRUD operations. + * REST API for DistributionSet CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Distribution Sets", description = "REST Resource handling for DistributionSet CRUD operations.", +@Tag(name = "Distribution Sets", description = "REST Resource handling for DistributionSet CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DISTRIBUTION_SET_ORDER))) public interface MgmtDistributionSetRestApi { + String DISTRIBUTIONSETS_V1 = MgmtRestConstants.REST_V1 + "/distributionsets"; + /** * Handles the GET request of retrieving all DistributionSets . * @@ -80,33 +85,24 @@ public interface MgmtDistributionSetRestApi { * @return a list of all set for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Return all Distribution Sets", description = "Handles the GET request of retrieving all " + - "distribution sets. Required permission: READ_REPOSITORY") + @Operation(summary = "Return all Distribution Sets", + description = "Handles the GET request of retrieving all distribution sets. Required permission: READ_REPOSITORY") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSets( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -115,11 +111,10 @@ public interface MgmtDistributionSetRestApi { * @param distributionSetId the ID of the set to retrieve * @return a single DistributionSet with status OK. */ - @Operation(summary = "Return single Distribution Set", description = "Handles the GET request of retrieving a " + - "single distribution set. Required permission: READ_REPOSITORY") + @Operation(summary = "Return single Distribution Set", + description = "Handles the GET request of retrieving a single distribution set. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** @@ -133,9 +128,8 @@ public interface MgmtDistributionSetRestApi { "distribution sets within Hawkbit. The request body must always be a list of sets. " + "Required permission: CREATE_REPOSITORY") @PostCreateResponses - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETS_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSets(@RequestBody List sets); /** @@ -144,10 +138,10 @@ public interface MgmtDistributionSetRestApi { * @param distributionSetId the ID of the DistributionSet to delete * @return status OK if delete as successful. */ - @Operation(summary = "Delete Distribution Set by Id", description = "Handles the DELETE request for a single " + - "Distribution Set. Required permission: DELETE_REPOSITORY") + @Operation(summary = "Delete Distribution Set by Id", + description = "Handles the DELETE request for a single Distribution Set. Required permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}") + @DeleteMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}") ResponseEntity deleteDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** @@ -157,12 +151,11 @@ public interface MgmtDistributionSetRestApi { * @param toUpdate with the data that needs updating * @return status OK if update as successful with updated content. */ - @Operation(summary = "Update Distribution Set", description = "Handles the UPDATE request for a single " + - "Distribution Set. Required permission: UPDATE_REPOSITORY") + @Operation(summary = "Update Distribution Set", + description = "Handles the UPDATE request for a single Distribution Set. Required permission: UPDATE_REPOSITORY") @PutResponses - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PutMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }) ResponseEntity updateDistributionSet( @PathVariable("distributionSetId") Long distributionSetId, @RequestBody MgmtDistributionSetRequestBodyPut toUpdate); @@ -182,31 +175,23 @@ public interface MgmtDistributionSetRestApi { "request for retrieving assigned targets of a single distribution set. " + "Required permissions: READ_REPOSITORY and READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedTargets", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/assignedTargets", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedTargets( @PathVariable("distributionSetId") Long distributionSetId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -224,31 +209,23 @@ public interface MgmtDistributionSetRestApi { "request for retrieving installed targets of a single distribution set. " + "Required permissions: READ_REPOSITORY and READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/installedTargets", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/installedTargets", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getInstalledTargets( @PathVariable("distributionSetId") Long distributionSetId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -266,31 +243,23 @@ public interface MgmtDistributionSetRestApi { description = "Handles the GET request for retrieving assigned target filter queries of a single " + "distribution set. Required permissions: READ_REPOSITORY and READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/autoAssignTargetFilters", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/autoAssignTargetFilters", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getAutoAssignTargetFilterQueries( @PathVariable("distributionSetId") Long distributionSetId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -307,10 +276,8 @@ public interface MgmtDistributionSetRestApi { "target IDs. Non-existing targets are silently ignored resulting in a valid response. " + "Required permissions: READ_REPOSITORY and UPDATE_TARGET") @PostUpdateResponses - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/assignedTargets", consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/assignedTargets", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity createAssignedTarget( @PathVariable("distributionSetId") Long distributionSetId, @RequestBody List assignments, @@ -329,8 +296,7 @@ public interface MgmtDistributionSetRestApi { @ApiResponse(responseCode = NOT_FOUND_404, description = "Distribution Set not found.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", - consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata", consumes = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }) ResponseEntity createMetadata( @PathVariable("distributionSetId") Long distributionSetId, @RequestBody List metadataRest); @@ -344,8 +310,7 @@ public interface MgmtDistributionSetRestApi { @Operation(summary = "Return meta data for Distribution Set", description = "Get a paged list of meta data for a " + "distribution set. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getMetadata(@PathVariable("distributionSetId") Long distributionSetId); /** @@ -358,8 +323,7 @@ public interface MgmtDistributionSetRestApi { @Operation(summary = "Return single meta data value for a specific key of a Distribution Set", description = "Get a single meta data value for a meta data key. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadataKey}", - produces = { MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata/{metadataKey}", produces = { APPLICATION_JSON_VALUE }) ResponseEntity getMetadataValue( @PathVariable("distributionSetId") Long distributionSetId, @PathVariable("metadataKey") String metadataKey); @@ -367,30 +331,30 @@ public interface MgmtDistributionSetRestApi { /** * Updates a single meta-data value of a distribution set. * - * @param distributionSetId the ID of the distribution set to update the meta data entry + * @param distributionSetId the ID of the distribution set to update the meta-data entry * @param metadataKey the key of the meta-data to update the value * @param metadata update body */ - @Operation(summary = "Update single meta data value of a distribution set", description = "Update a single meta " + - "data value for speficic key. Required permission: UPDATE_REPOSITORY") + @Operation(summary = "Update single meta data value of a distribution set", + description = "Update a single meta data value for speficic key. Required permission: UPDATE_REPOSITORY") @PutNoContentResponses - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadataKey}", - consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PutMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata/{metadataKey}", + consumes = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }) ResponseEntity updateMetadata( @PathVariable("distributionSetId") Long distributionSetId, @PathVariable("metadataKey") String metadataKey, @RequestBody MgmtMetadataBodyPut metadata); /** - * Deletes a single meta data entry from the distribution set. + * Deletes a single meta-data entry from the distribution set. * - * @param distributionSetId the ID of the distribution set to delete the meta data entry - * @param metadataKey the key of the meta data to delete + * @param distributionSetId the ID of the distribution set to delete the meta-data entry + * @param metadataKey the key of the meta-data to delete */ - @Operation(summary = "Delete a single meta data entry from the distribution set", description = "Delete a single " + - "meta data. Required permission: UPDATE_REPOSITORY") + @Operation(summary = "Delete a single meta data entry from the distribution set", + description = "Delete a single meta data. Required permission: UPDATE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadataKey}") + @DeleteMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata/{metadataKey}") ResponseEntity deleteMetadata( @PathVariable("distributionSetId") Long distributionSetId, @PathVariable("metadataKey") String metadataKey); @@ -408,11 +372,11 @@ public interface MgmtDistributionSetRestApi { """) @PostUpdateNoContentResponses @ApiResponses(value = { - @ApiResponse(responseCode = LOCKED_423, description = "Software module is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = LOCKED_423, description = "Software module is locked", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", - consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/assignedSM", + consumes = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity assignSoftwareModules( @PathVariable("distributionSetId") Long distributionSetId, @RequestBody List softwareModuleIDs); @@ -428,9 +392,10 @@ public interface MgmtDistributionSetRestApi { description = "Delete an assignment. Required permission: UPDATE_REPOSITORY") @DeleteResponses @ApiResponses(value = { - @ApiResponse(responseCode = LOCKED_423, description = "Distribution set is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = LOCKED_423, description = "Distribution set is locked", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM/{softwareModuleId}") + @DeleteMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/assignedSM/{softwareModuleId}") ResponseEntity deleteAssignSoftwareModules( @PathVariable("distributionSetId") Long distributionSetId, @PathVariable("softwareModuleId") Long softwareModuleId); @@ -447,29 +412,21 @@ public interface MgmtDistributionSetRestApi { * @return a list of the assigned software modules of a distribution set with status OK, if none is assigned than {@code null} */ @Operation(summary = "Return the assigned software modules of a specific distribution set", - description = "Handles the GET request of retrieving a single distribution set. " + - "Required permission: READ_REPOSITORY") + description = "Handles the GET request of retrieving a single distribution set. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/assignedSM", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedSoftwareModules( @PathVariable("distributionSetId") Long distributionSetId, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -478,26 +435,25 @@ public interface MgmtDistributionSetRestApi { * @param distributionSetId the ID of the set to retrieve * @return a DistributionSetStatistics with status OK. */ - @Operation(summary = "Return Rollouts count by status for Distribution Set", description = "Handles the GET " + - "request of retrieving Rollouts count by Status for Distribution Set") + @Operation(summary = "Return Rollouts count by status for Distribution Set", + description = "Handles the GET request of retrieving Rollouts count by Status for Distribution Set") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics/rollouts", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/statistics/rollouts", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getRolloutsCountByStatusForDistributionSet( @PathVariable("distributionSetId") Long distributionSetId); /** - * Handles the GET request of retrieving Actions count by Status - * for Distribution Set. + * Handles the GET request of retrieving Actions count by Status for Distribution Set. * * @param distributionSetId the ID of the set to retrieve * @return a DistributionSetStatistics with status OK. */ - @Operation(summary = "Return Actions count by status for Distribution Set", description = "Handles the GET " + - "request of retrieving Actions count by Status for Distribution Set") + @Operation(summary = "Return Actions count by status for Distribution Set", + description = "Handles the GET request of retrieving Actions count by Status for Distribution Set") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics/actions", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/statistics/actions", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getActionsCountByStatusForDistributionSet( @PathVariable("distributionSetId") Long distributionSetId); @@ -507,11 +463,11 @@ public interface MgmtDistributionSetRestApi { * @param distributionSetId the ID of the set to retrieve * @return a DistributionSetStatistics with status OK. */ - @Operation(summary = "Return Auto Assignments count for Distribution Set", description = "Handles the GET " + - "request of retrieving Auto Assignments count for Distribution Set") + @Operation(summary = "Return Auto Assignments count for Distribution Set", + description = "Handles the GET request of retrieving Auto Assignments count for Distribution Set") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics/autoassignments", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/statistics/autoassignments", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAutoAssignmentsCountForDistributionSet( @PathVariable("distributionSetId") Long distributionSetId); @@ -522,11 +478,9 @@ public interface MgmtDistributionSetRestApi { * @return a DistributionSetStatistics with status OK. */ @Operation(summary = "Return Rollouts, Actions and Auto Assignments counts by Status for Distribution Set", - description = "Handles the GET request of retrieving Rollouts, Actions and Auto Assignments counts by " + - "Status for Distribution Set") + description = "Handles the GET request of retrieving Rollouts, Actions and Auto Assignments counts by Status for Distribution Set") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/statistics", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getStatisticsForDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** @@ -544,13 +498,14 @@ public interface MgmtDistributionSetRestApi { """) @PostUpdateNoContentResponses @ApiResponses(value = { - @ApiResponse(responseCode = METHOD_NOT_ALLOWED_405, description = "Software module is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))), - @ApiResponse(responseCode = LOCKED_423, description = "Distribution set is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = METHOD_NOT_ALLOWED_405, description = "Software module is locked", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))), + @ApiResponse(responseCode = LOCKED_423, description = "Distribution set is locked", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/invalidate", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETS_V1 + "/{distributionSetId}/invalidate", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity invalidateDistributionSet( @PathVariable("distributionSetId") Long distributionSetId, @Valid @RequestBody MgmtInvalidateDistributionSetRequestBody invalidateRequestBody); -} +} \ No newline at end of file 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 01145e7a7..899b17856 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 @@ -10,12 +10,18 @@ package org.eclipse.hawkbit.mgmt.rest.api; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTION_SET_TAG_ORDER; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateNoContentResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -30,8 +36,6 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateNoContentResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -42,14 +46,16 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** - * REST Resource handling for DistributionSetTag CRUD operations. + * REST API for DistributionSetTag CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Distribution Set Tags", description = "REST Resource handling for DistributionSetTag CRUD operations.", +@Tag(name = "Distribution Set Tags", description = "REST Resource handling for DistributionSetTag CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DISTRIBUTION_SET_TAG_ORDER))) public interface MgmtDistributionSetTagRestApi { + String DISTRIBUTIONSETTAGS_V1 = MgmtRestConstants.REST_V1 + "/distributionsettags"; + String DISTRIBUTIONSET_TAG_ID_ASSIGNED = "/{distributionsetTagId}/assigned"; + /** * Handles the GET request of retrieving all DistributionSet tags. * @@ -61,33 +67,24 @@ public interface MgmtDistributionSetTagRestApi { * @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. */ - @Operation(summary = "Return all Distribution Set Tags", description = "Handles the GET request of retrieving " + - "all distribution set tags.") + @Operation(summary = "Return all Distribution Set Tags", + description = "Handles the GET request of retrieving all distribution set tags.") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTAGS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTags( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -99,8 +96,7 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Return single Distribution Set Tag", description = "Handles the GET request of retrieving a single distribution set tag.") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTAGS_V1 + "/{distributionsetTagId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId); /** @@ -113,9 +109,8 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Creates new Distribution Set Tags", description = "Handles the POST request of creating " + "new distribution set tag. The request body must always be a list of distribution set tags.") @PostCreateResponses - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETTAGS_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSetTags(@RequestBody List tags); /** @@ -128,9 +123,8 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Update Distribution Set Tag", description = "Handles the PUT request of updating a distribution set tag.") @PutResponses - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = DISTRIBUTIONSETTAGS_V1 + "/{distributionsetTagId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateDistributionSetTag( @PathVariable("distributionsetTagId") Long distributionsetTagId, @RequestBody MgmtTagRequestBodyPut restDSTagRest); @@ -144,7 +138,7 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Delete a single distribution set tag", description = "Handles the DELETE request of deleting a single distribution set tag.") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}") + @DeleteMapping(value = DISTRIBUTIONSETTAGS_V1 + "/{distributionsetTagId}") ResponseEntity deleteDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId); /** @@ -161,31 +155,22 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Return all assigned distribution sets by given tag Id", description = "Handles the GET request of retrieving a list of assigned distributions.") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_ID_ASSIGNED, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTAGS_V1 + DISTRIBUTIONSET_TAG_ID_ASSIGNED, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedDistributionSets( @PathVariable("distributionsetTagId") Long distributionsetTagId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -198,7 +183,7 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Assign distribution set to the given tag id", description = "Handles the POST request of distribution assignment. Already assigned distribution will be ignored.") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_ID_ASSIGNED + "/{distributionsetId}") + @PostMapping(value = DISTRIBUTIONSETTAGS_V1 + DISTRIBUTIONSET_TAG_ID_ASSIGNED + "/{distributionsetId}") ResponseEntity assignDistributionSet( @PathVariable("distributionsetTagId") Long distributionsetTagId, @PathVariable("distributionsetId") Long distributionsetId); @@ -213,9 +198,8 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Assign distribution sets to the given tag id", description = "Handles the POST request of distribution assignment. Already assigned distribution will be ignored.") @PostUpdateNoContentResponses - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_ID_ASSIGNED, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETTAGS_V1 + DISTRIBUTIONSET_TAG_ID_ASSIGNED, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity assignDistributionSets( @PathVariable("distributionsetTagId") Long distributionsetTagId, @RequestBody List distributionsetIds); @@ -230,8 +214,7 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Unassign one distribution set from the given tag id", description = "Handles the DELETE request of unassign the given distribution.") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + - MgmtRestConstants.DISTRIBUTIONSET_TAG_ID_ASSIGNED + "/{distributionsetId}") + @DeleteMapping(value = DISTRIBUTIONSETTAGS_V1 + DISTRIBUTIONSET_TAG_ID_ASSIGNED + "/{distributionsetId}") ResponseEntity unassignDistributionSet( @PathVariable("distributionsetTagId") Long distributionsetTagId, @PathVariable("distributionsetId") Long distributionsetId); @@ -246,8 +229,7 @@ public interface MgmtDistributionSetTagRestApi { @Operation(summary = "Unassign multiple distribution sets from the given tag id", description = "Handles the DELETE request of unassign the given distribution.") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + - MgmtRestConstants.DISTRIBUTIONSET_TAG_ID_ASSIGNED) + @DeleteMapping(value = DISTRIBUTIONSETTAGS_V1 + DISTRIBUTIONSET_TAG_ID_ASSIGNED) ResponseEntity unassignDistributionSets( @PathVariable("distributionsetTagId") Long distributionsetTagId, @RequestBody List distributionsetIds); 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 09e920220..811a0f0b5 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 @@ -10,6 +10,10 @@ package org.eclipse.hawkbit.mgmt.rest.api; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTION_SET_TYPE_ORDER; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; @@ -17,6 +21,8 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.NOT_FOUND_404; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateNoContentResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -35,8 +41,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.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -47,14 +51,17 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** - * REST Resource handling for DistributionSetType CRUD operations. + * REST API for DistributionSetType CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Distribution Set Types", description = "REST Resource handling for DistributionSetType CRUD operations.", +@Tag(name = "Distribution Set Types", description = "REST Resource handling for DistributionSetType CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = DISTRIBUTION_SET_TYPE_ORDER))) public interface MgmtDistributionSetTypeRestApi { + String DISTRIBUTIONSETTYPES_V1 = MgmtRestConstants.REST_V1 + "/distributionsettypes"; + String MANDATORYMODULETYPES = "mandatorymoduletypes"; + String OPTIONALMODULETYPES = "optionalmoduletypes"; + /** * Handles the GET request of retrieving all DistributionSetTypes. * @@ -69,30 +76,21 @@ public interface MgmtDistributionSetTypeRestApi { @Operation(summary = "Return all Distribution Set Types", description = "Handles the GET request of " + "retrieving all distribution set types. Required Permission: READ_REPOSITORY") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTYPES_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTypes( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -104,8 +102,7 @@ public interface MgmtDistributionSetTypeRestApi { @Operation(summary = "Return single Distribution Set Type", description = "Handles the GET request of retrieving a " + "single distribution set type. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSetType( @PathVariable("distributionSetTypeId") Long distributionSetTypeId); @@ -115,10 +112,10 @@ public interface MgmtDistributionSetTypeRestApi { * @param distributionSetTypeId the ID of the module to retrieve * @return status OK if delete is successful. */ - @Operation(summary = "Delete Distribution Set Type by Id", description = "Handles the DELETE request for a single" + - " distribution set type. Required Permission: DELETE_REPOSITORY") + @Operation(summary = "Delete Distribution Set Type by Id", + description = "Handles the DELETE request for a single distribution set type. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}") + @DeleteMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}") ResponseEntity deleteDistributionSetType(@PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** @@ -128,12 +125,11 @@ public interface MgmtDistributionSetTypeRestApi { * @param restDistributionSetType the DS type to be updated. * @return status OK if update is successful */ - @Operation(summary = "Update Distribution Set Type", description = "Handles the PUT request for a single " + - "distribution set type. Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Update Distribution Set Type", + description = "Handles the PUT request for a single distribution set type. Required Permission: UPDATE_REPOSITORY") @PutResponses - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateDistributionSetType( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @RequestBody MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); @@ -149,9 +145,8 @@ public interface MgmtDistributionSetTypeRestApi { "new distribution set types. The request body must always be a list of types. " + "Required Permission: CREATE_REPOSITORY") @PostCreateResponses - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETTYPES_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSetTypes( @RequestBody List distributionSetTypes); @@ -165,9 +160,8 @@ public interface MgmtDistributionSetTypeRestApi { description = "Handles the GET request of retrieving the list of mandatory software module types in that " + "distribution set type. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.MANDATORYMODULETYPES, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + MANDATORYMODULETYPES, + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getMandatoryModules( @PathVariable("distributionSetTypeId") Long distributionSetTypeId); @@ -183,9 +177,8 @@ public interface MgmtDistributionSetTypeRestApi { description = "Handles the GET request of retrieving the single mandatory software module type in that " + "distribution set type. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.MANDATORYMODULETYPES + "/{softwareModuleTypeId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + MANDATORYMODULETYPES + "/{softwareModuleTypeId}", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getMandatoryModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -201,9 +194,8 @@ public interface MgmtDistributionSetTypeRestApi { description = "Handles the GET request of retrieving the single optional software module type in that " + "distribution set type. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.OPTIONALMODULETYPES + "/{softwareModuleTypeId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + OPTIONALMODULETYPES + "/{softwareModuleTypeId}", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getOptionalModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -218,9 +210,8 @@ public interface MgmtDistributionSetTypeRestApi { description = "Handles the GET request of retrieving the list of optional software module types in that " + "distribution set type. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.OPTIONALMODULETYPES, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + OPTIONALMODULETYPES, + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getOptionalModules( @PathVariable("distributionSetTypeId") Long distributionSetTypeId); @@ -235,8 +226,7 @@ public interface MgmtDistributionSetTypeRestApi { description = "Handles the DELETE request for removing a software module type from a single " + "distribution set type. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.MANDATORYMODULETYPES + "/{softwareModuleTypeId}") + @DeleteMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + MANDATORYMODULETYPES + "/{softwareModuleTypeId}") ResponseEntity removeMandatoryModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -253,8 +243,7 @@ public interface MgmtDistributionSetTypeRestApi { "Note that a DS type cannot be changed after it has been used by a DS. " + "Required Permission: UPDATE_REPOSITORY and READ_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.OPTIONALMODULETYPES + "/{softwareModuleTypeId}") + @DeleteMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + OPTIONALMODULETYPES + "/{softwareModuleTypeId}") ResponseEntity removeOptionalModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -275,9 +264,8 @@ public interface MgmtDistributionSetTypeRestApi { @ApiResponse(responseCode = NOT_FOUND_404, description = "Distribution Set Type not found.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.MANDATORYMODULETYPES, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + MANDATORYMODULETYPES, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity addMandatoryModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @RequestBody MgmtId smtId); @@ -298,9 +286,8 @@ public interface MgmtDistributionSetTypeRestApi { @ApiResponse(responseCode = NOT_FOUND_404, description = "Distribution Set Type not found.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + - MgmtRestConstants.OPTIONALMODULETYPES, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}/" + OPTIONALMODULETYPES, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity addOptionalModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @RequestBody MgmtId smtId); diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java index 94465b1e4..db80a895e 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java @@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.ResponseBody; /** - * API to download artifacts + * REST API to download artifacts */ @FunctionalInterface @Tag( @@ -50,7 +50,7 @@ public interface MgmtDownloadArtifactRestApi { @ApiResponse(responseCode = INTERNAL_SERVER_ERROR_500, description = "Artifact download or decryption failed", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}/download") + @GetMapping(value = MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts/{artifactId}/download") @ResponseBody ResponseEntity downloadArtifact( @PathVariable("softwareModuleId") Long softwareModuleId, diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java index 90972cbb6..ebadd2827 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java @@ -18,7 +18,6 @@ import java.util.Optional; public enum MgmtRepresentationMode { FULL("full"), - COMPACT("compact"); private final String mode; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java index 303f27450..937805bb4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java @@ -18,158 +18,41 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtRestConstants { + /** + * The base URL mapping of the rest resources. + */ + public static final String REST = "/rest"; /** * API version definition. We are using only major versions. */ - public static final String API_VERSION = "v1"; + public static final String API_VERSION_1 = "v1"; /** - * The base URL mapping of the SP rest resources. + * The base URL mapping of the rest V1 resources. */ - public static final String BASE_REST_MAPPING = "/rest"; + public static final String REST_V1 = REST + "/" + API_VERSION_1; + /** - * The base URL mapping of the SP rest resources. + * The request parameter for searching. The value of the search parameter must be in the FIQL syntax. */ - public static final String BASE_V1_REQUEST_MAPPING = BASE_REST_MAPPING + "/v1"; + public static final String REQUEST_PARAMETER_SEARCH = "q"; /** - * The software module URL mapping rest resource. + * The request parameter for specifying the representation mode. The value of this parameter can either be "full" or "compact". */ - public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules"; + public static final String REQUEST_PARAMETER_REPRESENTATION_MODE = "representation"; /** - * The target URL mapping rest resource. + * The default representation mode. */ - public static final String TARGET_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targets"; + public static final String REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT = "compact"; /** - * The tag URL mapping rest resource. - */ - public static final String TARGET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targettags"; - /** - * The target type URL mapping rest resource. - */ - public static final String TARGETTYPE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targettypes"; - /** - * The target group URL mapping rest resource. - */ - public static final String TARGET_GROUP_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targetgroups"; - /** - * The tag URL mapping rest resource. - */ - public static final String DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING - + "/distributionsettags"; - /** - * The target URL mapping rest resource. - */ - public static final String TARGET_FILTER_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targetfilters"; - /** - * The action URL mapping rest resource. - */ - public static final String ACTION_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/actions"; - /** - * The software module type URL mapping rest resource. - */ - public static final String SOFTWAREMODULETYPE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremoduletypes"; - /** - * The distributon set base resource. - */ - public static final String DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING - + "/distributionsettypes"; - /** - * The software module URL mapping rest resource. - */ - public static final String DISTRIBUTIONSET_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/distributionsets"; - /** - * The rollout URL mapping rest resource. - */ - public static final String ROLLOUT_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/rollouts"; - /** - * The basic authentication validation mapping - */ - public static final String AUTH_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/userinfo"; - /** - * String representation of - * {@link #REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE}. + * String representation of {@link #REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE}. */ public static final String REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT = "50"; /** - * The default limit parameter in case the limit parameter is not present in - * the request. + * The default limit parameter in case the limit parameter is not present in the request. * * @see #REQUEST_PARAMETER_PAGING_LIMIT */ - public static final int REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE = Integer - .parseInt(REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT); - /** - * The base URL mapping for the spring acuator management context path. - */ - public static final String BASE_SYSTEM_MAPPING = "/system"; - public static final String SYSTEM_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + BASE_SYSTEM_MAPPING; - /** - * URL mapping for system admin operations. - */ - public static final String SYSTEM_ADMIN_MAPPING = BASE_SYSTEM_MAPPING + "/admin"; - /** - * The target URL mapping, href link for assigned target type. - */ - public static final String TARGET_V1_ASSIGNED_TARGET_TYPE = "targetType"; - /** - * The target URL mapping, href link for autoConfirm state of a target. - */ - public static final String TARGET_V1_AUTO_CONFIRM = "autoConfirm"; - /** - * The target URL mapping, href link activate auto-confirm on a target. - */ - public static final String TARGET_V1_ACTIVATE_AUTO_CONFIRM = "activate"; - /** - * The target URL mapping, href link deactivate auto-confirm on a target. - */ - public static final String TARGET_V1_DEACTIVATE_AUTO_CONFIRM = "deactivate"; - /** - * The target URL mapping, href link for assigned distribution set. - */ - public static final String TARGET_V1_ASSIGNED_DISTRIBUTION_SET = "assignedDS"; - /** - * The target URL mapping, href link for installed distribution set. - */ - public static final String TARGET_V1_INSTALLED_DISTRIBUTION_SET = "installedDS"; - /** - * The target URL mapping, href link for target attributes. - */ - public static final String TARGET_V1_ATTRIBUTES = "attributes"; - /** - * The target URL mapping, href link for target actions. - */ - public static final String TARGET_V1_ACTIONS = "actions"; - /** - * The target URL mapping, href link for canceled actions. - */ - public static final String TARGET_V1_CANCELED_ACTION = "canceledaction"; - /** - * The target URL mapping, href link for canceled actions. - */ - public static final String TARGET_V1_ACTION_STATUS = "status"; - /** - * The target URL mapping, href link for a rollout. - */ - public static final String TARGET_V1_ROLLOUT = "rollout"; - /** - * The target URL mapping rest resource. - */ - public static final String TARGET_TARGET_ID_TARGETTYPE = "/{targetId}/targettype"; - /** - * The target type URL mapping rest resource. - */ - public static final String COMPATIBLEDISTRIBUTIONSETTYPES = "compatibledistributionsettypes"; - /** - * The tag URL mapping rest resource. - */ - public static final String TARGET_TAG_ID_ASSIGNED = "/{targetTagId}/assigned"; - /** - * The tag URL mapping rest resource. - */ - public static final String DISTRIBUTIONSET_TAG_ID_ASSIGNED = "/{distributionsetTagId}/assigned"; - /** - * Target group URL mapping rest resource - */ - public static final String GROUP_ASSIGNED = "/{group}/assigned"; + public static final int REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE = Integer.parseInt(REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT); /** * The default offset parameter in case the offset parameter is not present in the request. * @@ -195,48 +78,12 @@ public final class MgmtRestConstants { */ public static final String REQUEST_PARAMETER_PAGING_OFFSET = "offset"; /** - * The request parameter for sorting. The value of the sort parameter must be in the following pattern. Example: - * http://www.bosch.com/iap/sp/rest/targets?sort=field_1:ASC,field_2:DESC,field_3:ASC + * The request parameter for sorting. The value of the sort parameter must be in the following pattern.
+ * Example: https://www.foo.com/iap/sp/rest/targets?sort=field_1:ASC,field_2:DESC,field_3:ASC */ public static final String REQUEST_PARAMETER_SORTING = "sort"; - /** - * The request parameter for searching. The value of the search parameter must be in the FIQL syntax. - */ - public static final String REQUEST_PARAMETER_SEARCH = "q"; - /** - * The request parameter for specifying the representation mode. The value of this parameter can either be "full" or "compact". - */ - public static final String REQUEST_PARAMETER_REPRESENTATION_MODE = "representation"; - /** - * The default representation mode. - */ - public static final String REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT = "compact"; - /** - * Request parameter for async - */ - public static final String REQUEST_PARAMETER_ASYNC = "async"; - /** - * The target URL mapping, href link for artifact download. - */ - public static final String SOFTWAREMODULE_V1_ARTIFACT = "artifacts"; - /** - * The target URL mapping, href link for software module access. - */ - public static final String DISTRIBUTIONSET_V1_MODULE = "modules"; - /** - * The target URL mapping, href link for type information. - */ - public static final String SOFTWAREMODULE_V1_TYPE = "type"; - public static final String OPTIONALMODULES = "optionalmodules"; - public static final String MANDATORYMODULES = "mandatorymodules"; - public static final String OPTIONALMODULETYPES = "optionalmoduletypes"; - public static final String MANDATORYMODULETYPES = "mandatorymoduletypes"; - /** - * Request parameter if the artifact url handler should be used - */ - public static final String REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER = "useartifacturlhandler"; - // Orders + // API Orders (used for sorting in OpenAPI doc / Swagger UI) public static final String TARGET_ORDER = "1000"; public static final String TARGET_TAG_ORDER = "2000"; public static final String TARGET_TYPE_ORDER = "3000"; 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 3cd37c463..234d487fc 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 @@ -9,6 +9,12 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ROLLOUT_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; @@ -17,6 +23,8 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.NOT_FOUND_404; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateNoContentResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.extensions.Extension; @@ -34,8 +42,6 @@ import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponse import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateNoContentResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -46,14 +52,15 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** - * REST Resource handling rollout CRUD operations. + * REST API for Rollout CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Rollouts", description = "REST API for Rollout CRUD operations.", +@Tag(name = "Rollouts", description = "REST API for Rollout CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = ROLLOUT_ORDER))) public interface MgmtRolloutRestApi { + String ROLLOUTS_V1 = MgmtRestConstants.REST_V1 + "/rollouts"; + /** * Handles the GET request of retrieving all rollouts. * @@ -66,36 +73,26 @@ public interface MgmtRolloutRestApi { * @return a list of all rollouts for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Return all Rollouts", description = "Handles the GET request of retrieving all rollouts. " + - "Required Permission: READ_ROLLOUT") + @Operation(summary = "Return all Rollouts", + description = "Handles the GET request of retrieving all rollouts. Required Permission: READ_ROLLOUT") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ROLLOUTS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getRollouts( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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_REPRESENTATION_MODE, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) + @RequestParam(value = REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam); /** @@ -104,11 +101,10 @@ public interface MgmtRolloutRestApi { * @param rolloutId the ID of the rollout to retrieve * @return a single rollout with status OK. */ - @Operation(summary = "Return single Rollout", description = "Handles the GET request of retrieving a single " + - "rollout. Required Permission: READ_ROLLOUT") + @Operation(summary = "Return single Rollout", + description = "Handles the GET request of retrieving a single rollout. Required Permission: READ_ROLLOUT") @GetResponses - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ROLLOUTS_V1 + "/{rolloutId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getRollout(@PathVariable("rolloutId") Long rolloutId); /** @@ -121,9 +117,8 @@ public interface MgmtRolloutRestApi { @Operation(summary = "Create a new Rollout", description = "Handles the POST request of creating new rollout. Required Permission: CREATE_ROLLOUT") @PostCreateResponses - @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 }) + @PostMapping(value = ROLLOUTS_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity create( @RequestBody MgmtRolloutRestRequestBodyPost rolloutRequestBody); @@ -134,12 +129,11 @@ public interface MgmtRolloutRestApi { * @return In case rollout could successful updated the ResponseEntity with status code 200 with the successfully created rollout. In any * failure the JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Update Rollout", description = "Handles the UPDATE request for a single " + - "Rollout. Required permission: UPDATE_ROLLOUT") + @Operation(summary = "Update Rollout", + description = "Handles the UPDATE request for a single Rollout. Required permission: UPDATE_ROLLOUT") @PutResponses - @PutMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PutMapping(value = ROLLOUTS_V1 + "/{rolloutId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }) ResponseEntity update( @PathVariable("rolloutId") Long rolloutId, @RequestBody MgmtRolloutRestRequestBodyPut rolloutUpdateBody); @@ -156,8 +150,7 @@ public interface MgmtRolloutRestApi { "workflow is enabled in system configuration and rollout is in state WAITING_FOR_APPROVAL. " + "Required Permission: APPROVE_ROLLOUT") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/approve", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity approve( @PathVariable("rolloutId") Long rolloutId, @RequestParam(value = "remark", required = false) String remark); @@ -173,8 +166,7 @@ public interface MgmtRolloutRestApi { "Only possible if approval workflow is enabled in system configuration and rollout is in state " + "WAITING_FOR_APPROVAL. Required Permission: APPROVE_ROLLOUT") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/deny", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity deny( @PathVariable("rolloutId") Long rolloutId, @RequestParam(value = "remark", required = false) String remark); @@ -185,11 +177,10 @@ public interface MgmtRolloutRestApi { * @param rolloutId the ID of the rollout to be started. * @return OK response (200) if rollout could be started. In case of any exception the corresponding errors occur. */ - @Operation(summary = "Start a Rollout", description = "Handles the POST request of starting a created rollout. " + - "Required Permission: HANDLE_ROLLOUT") + @Operation(summary = "Start a Rollout", + description = "Handles the POST request of starting a created rollout. Required Permission: HANDLE_ROLLOUT") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/start", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/start", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity start(@PathVariable("rolloutId") Long rolloutId); /** @@ -198,11 +189,10 @@ public interface MgmtRolloutRestApi { * @param rolloutId the ID of the rollout to be paused. * @return OK response (200) if rollout could be paused. In case of any exception the corresponding errors occur. */ - @Operation(summary = "Pause a Rollout", description = "Handles the POST request of pausing a running rollout. " + - "Required Permission: HANDLE_ROLLOUT") + @Operation(summary = "Pause a Rollout", + description = "Handles the POST request of pausing a running rollout. Required Permission: HANDLE_ROLLOUT") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/pause", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/pause", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity pause(@PathVariable("rolloutId") Long rolloutId); /** @@ -211,25 +201,22 @@ public interface MgmtRolloutRestApi { * @param rolloutId the ID of the rollout to be paused. * @return OK response (200) if rollout could be stopped. In case of any exception the corresponding errors occur. */ - @Operation(summary = "Stop a Rollout", description = "Handles the POST request of stopping a running rollout. " + - "Required Permission: HANDLE_ROLLOUT") + @Operation(summary = "Stop a Rollout", + description = "Handles the POST request of stopping a running rollout. Required Permission: HANDLE_ROLLOUT") @PostUpdateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/stop", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/stop", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity stop(@PathVariable("rolloutId") Long rolloutId); /** * Handles the DELETE request for deleting a rollout. * * @param rolloutId the ID of the rollout to be deleted. - * @return OK response (200) if rollout could be deleted. In case of any - * exception the corresponding errors occur. + * @return OK response (200) if rollout could be deleted. In case of any exception the corresponding errors occur. */ @Operation(summary = "Delete a Rollout", description = "Handles the DELETE request of deleting a rollout. " + "Required Permission: DELETE_ROLLOUT") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = ROLLOUTS_V1 + "/{rolloutId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity delete(@PathVariable("rolloutId") Long rolloutId); /** @@ -241,8 +228,7 @@ public interface MgmtRolloutRestApi { @Operation(summary = "Resume a Rollout", description = "Handles the POST request of resuming a paused rollout. " + "Required Permission: HANDLE_ROLLOUT") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/resume", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/resume", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity resume(@PathVariable("rolloutId") Long rolloutId); /** @@ -257,37 +243,27 @@ public interface MgmtRolloutRestApi { * @return a list of all rollout groups referred to a rollout for a defined or default page request with status OK. The response is always * paged. In any failure the JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Return all rollout groups referred to a Rollout", description = "Handles the GET request of " + - "retrieving all deploy groups of a specific rollout. Required Permission: READ_ROLLOUT") + @Operation(summary = "Return all rollout groups referred to a Rollout", + description = "Handles the GET request of retrieving all deploy groups of a specific rollout. Required Permission: READ_ROLLOUT") @GetResponses - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ROLLOUTS_V1 + "/{rolloutId}/deploygroups", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getRolloutGroups( @PathVariable("rolloutId") Long rolloutId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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_REPRESENTATION_MODE, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) + @RequestParam(value = REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam); /** @@ -297,11 +273,10 @@ public interface MgmtRolloutRestApi { * @param groupId the groupId to retrieve the rollout group * @return the OK response containing the MgmtRolloutGroupResponseBody */ - @Operation(summary = "Return single rollout group", description = "Handles the GET request of a single deploy " + - "group of a specific rollout. Required Permission: READ_ROLLOUT") + @Operation(summary = "Return single rollout group", + description = "Handles the GET request of a single deploy group of a specific rollout. Required Permission: READ_ROLLOUT") @GetResponses - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{groupId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ROLLOUTS_V1 + "/{rolloutId}/deploygroups/{groupId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getRolloutGroup( @PathVariable("rolloutId") Long rolloutId, @PathVariable("groupId") Long groupId); @@ -322,32 +297,23 @@ public interface MgmtRolloutRestApi { description = "Handles the GET request of retrieving all targets of a single deploy group of a specific " + "rollout. Required Permissions: READ_ROLLOUT, READ_TARGET.") @GetResponses - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{groupId}/targets", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = ROLLOUTS_V1 + "/{rolloutId}/deploygroups/{groupId}/targets", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getRolloutGroupTargets( @PathVariable("rolloutId") Long rolloutId, @PathVariable("groupId") Long groupId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -359,8 +325,7 @@ public interface MgmtRolloutRestApi { @Operation(summary = "Force trigger processing next group of a Rollout", description = "Handles the POST request " + "of triggering the next group of a rollout. Required Permission: UPDATE_ROLLOUT") @PostCreateNoContentResponses - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/triggerNextGroup", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/triggerNextGroup", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity triggerNextGroup(@PathVariable("rolloutId") Long rolloutId); /** @@ -376,7 +341,6 @@ public interface MgmtRolloutRestApi { @ApiResponse(responseCode = NOT_FOUND_404, description = "Rollout not found.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/retry", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = ROLLOUTS_V1 + "/{rolloutId}/retry", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity retryRollout(@PathVariable("rolloutId") Long rolloutId); } \ No newline at end of file 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 0df607250..d756b834f 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 @@ -9,6 +9,10 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.SOFTWARE_MODULE_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GONE_410; @@ -19,6 +23,9 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.LOCKED_423; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.NOT_FOUND_404; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; import java.util.List; @@ -38,8 +45,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleMeta import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -53,15 +58,16 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; /** - * REST Resource handling for SoftwareModule and related Artifact CRUD - * operations. + * REST API for SoftwareModule and related Artifact CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Software Modules", description = "REST API for SoftwareModule and related Artifact CRUD operations.", +@Tag(name = "Software Modules", description = "REST API for SoftwareModule and related Artifact CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = SOFTWARE_MODULE_ORDER))) public interface MgmtSoftwareModuleRestApi { + String SOFTWAREMODULES_V1 = MgmtRestConstants.REST_V1 + "/softwaremodules"; + String REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER = "useartifacturlhandler"; + /** * Handles POST request for artifact upload. * @@ -83,10 +89,11 @@ public interface MgmtSoftwareModuleRestApi { content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))), @ApiResponse(responseCode = LOCKED_423, description = "Software module is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))), - @ApiResponse(responseCode = INTERNAL_SERVER_ERROR_500, description = "Upload / store to storage or encryption failed", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = INTERNAL_SERVER_ERROR_500, description = "Upload / store to storage or encryption failed", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", - consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts", + consumes = MULTIPART_FORM_DATA_VALUE, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity uploadArtifact( @PathVariable("softwareModuleId") Long softwareModuleId, @RequestPart("file") MultipartFile file, @@ -107,14 +114,14 @@ public interface MgmtSoftwareModuleRestApi { "software module. Required Permission: READ_REPOSITORY") @GetResponses @ApiResponses(value = { - @ApiResponse(responseCode = GONE_410, description = "Artifact binary no longer exists", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = GONE_410, description = "Artifact binary no longer exists", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getArtifacts( @PathVariable("softwareModuleId") Long softwareModuleId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) Boolean useArtifactUrlHandler); + @RequestParam(value = REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) Boolean useArtifactUrlHandler); /** * Handles the GET request of retrieving a single Artifact metadata request. @@ -123,18 +130,20 @@ public interface MgmtSoftwareModuleRestApi { * @param artifactId of the related artifact * @return responseEntity with status ok if successful */ - @Operation(summary = "Return single Artifact metadata", description = "Handles the GET request of retrieving a single Artifact metadata request. Required Permission: READ_REPOSITORY") + @Operation(summary = "Return single Artifact metadata", + description = "Handles the GET request of retrieving a single Artifact metadata request. Required Permission: READ_REPOSITORY") @GetResponses @ApiResponses(value = { - @ApiResponse(responseCode = GONE_410, description = "Artifact binary no longer exists", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = GONE_410, description = "Artifact binary no longer exists", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts/{artifactId}", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) @ResponseBody ResponseEntity getArtifact( @PathVariable("softwareModuleId") Long softwareModuleId, @PathVariable("artifactId") Long artifactId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) Boolean useArtifactUrlHandler); + @RequestParam(value = REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) Boolean useArtifactUrlHandler); /** * Handles the DELETE request for a single SoftwareModule. @@ -143,7 +152,8 @@ public interface MgmtSoftwareModuleRestApi { * @param artifactId of the artifact to be deleted * @return status OK if delete as successful. */ - @Operation(summary = "Delete artifact by Id", description = "Handles the DELETE request for a single Artifact assigned to a SoftwareModule. Required Permission: DELETE_REPOSITORY") + @Operation(summary = "Delete artifact by Id", + description = "Handles the DELETE request for a single Artifact assigned to a SoftwareModule. Required Permission: DELETE_REPOSITORY") @DeleteResponses @ApiResponses(value = { @ApiResponse(responseCode = LOCKED_423, description = "Software module is locked", @@ -151,7 +161,7 @@ public interface MgmtSoftwareModuleRestApi { @ApiResponse(responseCode = INTERNAL_SERVER_ERROR_500, description = "Artifact delete failed with internal server error", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}") + @DeleteMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts/{artifactId}") @ResponseBody ResponseEntity deleteArtifact( @PathVariable("softwareModuleId") Long softwareModuleId, @@ -168,32 +178,24 @@ public interface MgmtSoftwareModuleRestApi { * @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. */ - @Operation(summary = "Return all Software modules", description = "Handles the GET request of retrieving all softwaremodules. Required Permission: READ_REPOSITORY") + @Operation(summary = "Return all Software modules", + description = "Handles the GET request of retrieving all softwaremodules. Required Permission: READ_REPOSITORY") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULES_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getSoftwareModules( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -204,8 +206,7 @@ public interface MgmtSoftwareModuleRestApi { */ @Operation(summary = "Return Software Module by id", description = "Handles the GET request of retrieving a single softwaremodule. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getSoftwareModule(@PathVariable("softwareModuleId") Long softwareModuleId); /** @@ -215,15 +216,15 @@ public interface MgmtSoftwareModuleRestApi { * @return In case all modules could successful created the ResponseEntity with status code 201 - Created but without ResponseBody. In any * failure the JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Create Software Module(s)", description = "Handles the POST request of creating new software modules. The request body must always be a list of modules. Required Permission: CREATE_REPOSITORY") + @Operation(summary = "Create Software Module(s)", + description = "Handles the POST request of creating new software modules. The request body must always be a list of modules. Required Permission: CREATE_REPOSITORY") @PostCreateResponses @ApiResponses(value = { @ApiResponse(responseCode = INTERNAL_SERVER_ERROR_500, description = "Artifact encryption failed", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = SOFTWAREMODULES_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createSoftwareModules(@RequestBody List softwareModules); /** @@ -233,11 +234,11 @@ public interface MgmtSoftwareModuleRestApi { * @param restSoftwareModule the modules to be updated. * @return status OK if update was successful */ - @Operation(summary = "Update Software Module", description = "Handles the PUT request for a single softwaremodule within Hawkbit. Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Update Software Module", + description = "Handles the PUT request for a single softwaremodule within Hawkbit. Required Permission: UPDATE_REPOSITORY") @PutResponses - @PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateSoftwareModule( @PathVariable("softwareModuleId") Long softwareModuleId, @RequestBody MgmtSoftwareModuleRequestBodyPut restSoftwareModule); @@ -248,9 +249,10 @@ public interface MgmtSoftwareModuleRestApi { * @param softwareModuleId the ID of the module to retrieve * @return status OK if delete was successful. */ - @Operation(summary = "Delete Software Module by Id", description = "Handles the DELETE request for a single softwaremodule within Hawkbit. Required Permission: DELETE_REPOSITORY") + @Operation(summary = "Delete Software Module by Id", + description = "Handles the DELETE request for a single softwaremodule within Hawkbit. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}") + @DeleteMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}") ResponseEntity deleteSoftwareModule(@PathVariable("softwareModuleId") Long softwareModuleId); /** @@ -260,14 +262,14 @@ public interface MgmtSoftwareModuleRestApi { * @param metadataRest the list of metadata entries to create * @return status created if post request is successful with the value of the created metadata */ - @Operation(summary = "Creates a list of metadata for a specific Software Module", description = "Create a list of metadata entries Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Creates a list of metadata for a specific Software Module", + description = "Create a list of metadata entries Required Permission: UPDATE_REPOSITORY") @PostCreateResponses @ApiResponses(value = { @ApiResponse(responseCode = NOT_FOUND_404, description = "Software Module not found", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PostMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata", consumes = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }) ResponseEntity createMetadata(@PathVariable("softwareModuleId") Long softwareModuleId, @RequestBody List metadataRest); @@ -279,8 +281,7 @@ public interface MgmtSoftwareModuleRestApi { */ @Operation(summary = "Return metadata for a Software Module", description = "Get a paged list of metadata for a software module. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getMetadata(@PathVariable("softwareModuleId") Long softwareModuleId); /** @@ -290,10 +291,11 @@ public interface MgmtSoftwareModuleRestApi { * @param metadataKey the key of the metadata entry to retrieve the value from * @return status OK if get request is successful with the value of the metadata */ - @Operation(summary = "Return single metadata value for a specific key of a Software Module", description = "Get a single metadata value for a metadata key. Required Permission: READ_REPOSITORY") + @Operation(summary = "Return single metadata value for a specific key of a Software Module", + description = "Get a single metadata value for a metadata key. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata/{metadataKey}", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getMetadataValue( @PathVariable("softwareModuleId") Long softwareModuleId, @PathVariable("metadataKey") String metadataKey); @@ -305,9 +307,10 @@ public interface MgmtSoftwareModuleRestApi { * @param metadataKey the key of the metadata to update the value * @param metadata body to update */ - @Operation(summary = "Update a single metadata value of a Software Module", description = "Update a single metadata value for speficic key. Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Update a single metadata value of a Software Module", + description = "Update a single metadata value for specific key. Required Permission: UPDATE_REPOSITORY") @PutResponses - @PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}") + @PutMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata/{metadataKey}") ResponseEntity updateMetadata( @PathVariable("softwareModuleId") Long softwareModuleId, @PathVariable("metadataKey") String metadataKey, @@ -319,9 +322,10 @@ public interface MgmtSoftwareModuleRestApi { * @param softwareModuleId the ID of the software module to delete the metadata entry * @param metadataKey the key of the metadata to delete */ - @Operation(summary = "Delete single metadata entry from the software module", description = "Delete a single metadata. Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Delete single metadata entry from the software module", + description = "Delete a single metadata. Required Permission: UPDATE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}") + @DeleteMapping(value = SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata/{metadataKey}") ResponseEntity deleteMetadata(@PathVariable("softwareModuleId") Long softwareModuleId, @PathVariable("metadataKey") String metadataKey); } \ No newline at end of file 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 a059f9572..ba2acf8bc 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 @@ -9,6 +9,10 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.SOFTWARE_MODULE_TYPE_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; @@ -44,15 +48,15 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** - * REST Resource handling for SoftwareModule and related Artifact CRUD - * operations. + * REST API for SoftwareModule and related Artifact CRUD operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Software Module Types", description = "REST API for SoftwareModuleTypes CRUD operations.", +@Tag(name = "Software Module Types", description = "REST API for SoftwareModuleTypes CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = SOFTWARE_MODULE_TYPE_ORDER))) public interface MgmtSoftwareModuleTypeRestApi { + String SOFTWAREMODULETYPES_V1 = MgmtRestConstants.REST_V1 + "/softwaremoduletypes"; + /** * Handles the GET request of retrieving all SoftwareModuleTypes . * @@ -67,30 +71,21 @@ public interface MgmtSoftwareModuleTypeRestApi { @Operation(summary = "Return all Software Module Types", description = "Handles the GET request of retrieving all software module types. Required Permission: READ_REPOSITORY") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SOFTWAREMODULETYPES_V1, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTypes( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -102,7 +97,7 @@ public interface MgmtSoftwareModuleTypeRestApi { @Operation(summary = "Return single Software Module Type", description = "Handles the GET request of retrieving a single software module type. Required Permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeId}", + @GetMapping(value = SOFTWAREMODULETYPES_V1 + "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getSoftwareModuleType( @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -116,7 +111,7 @@ public interface MgmtSoftwareModuleTypeRestApi { @Operation(summary = "Delete Software Module Type by Id", description = "Handles the DELETE request for a single software module type. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeId}") + @DeleteMapping(value = SOFTWAREMODULETYPES_V1 + "/{softwareModuleTypeId}") ResponseEntity deleteSoftwareModuleType( @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -130,7 +125,7 @@ public interface MgmtSoftwareModuleTypeRestApi { @Operation(summary = "Update Software Module Type", description = "Handles the PUT request for a single software module type. Required Permission: UPDATE_REPOSITORY") @PutResponses - @PutMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeId}", + @PutMapping(value = SOFTWAREMODULETYPES_V1 + "/{softwareModuleTypeId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateSoftwareModuleType( @@ -152,7 +147,7 @@ public interface MgmtSoftwareModuleTypeRestApi { @ApiResponse(responseCode = NOT_FOUND_404, description = "Software Module not found", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, + @PostMapping(value = SOFTWAREMODULETYPES_V1, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createSoftwareModuleTypes( 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 6e832f610..e7cb1b65c 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 @@ -9,12 +9,20 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_FILTER_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.extensions.Extension; @@ -28,8 +36,6 @@ import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQueryRequestBody; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -40,14 +46,15 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; /** - * Api for handling target operations. + * REST API for target operations. */ // no request mapping specified here to avoid CVE-2021-22044 in Feign client -@Tag( - name = "Target Filter Queries", description = "REST API for Target Filter Queries CRUD operations.", +@Tag(name = "Target Filter Queries", description = "REST API for Target Filter Queries CRUD operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_FILTER_ORDER))) public interface MgmtTargetFilterQueryRestApi { + String TARGETFILTERS_V1 = MgmtRestConstants.REST_V1 + "/targetfilters"; + /** * Handles the GET request of retrieving a single target filter. * @@ -55,11 +62,10 @@ public interface MgmtTargetFilterQueryRestApi { * @return a single target with status OK. */ - @Operation(summary = "Return target filter query by id", description = "Handles the GET request of retrieving a " + - "single target filter query. Required permission: READ_TARGET") + @Operation(summary = "Return target filter query by id", + description = "Handles the GET request of retrieving a single target filter query. Required permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETFILTERS_V1 + "/{filterId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getFilter(@PathVariable("filterId") Long filterId); /** @@ -73,34 +79,27 @@ public interface MgmtTargetFilterQueryRestApi { * @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. */ - @Operation(summary = "Return all target filter queries", description = "Handles the GET request of retrieving all target filter queries. Required permission: READ_TARGET") + @Operation(summary = "Return all target filter queries", + description = "Handles the GET request of retrieving all target filter queries. Required permission: READ_TARGET") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETFILTERS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getFilters( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam); + @RequestParam(value = REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) + String representationModeParam); /** * Handles the POST request of creating new target filters. The request body must always be a list of target filters. @@ -109,11 +108,11 @@ public interface MgmtTargetFilterQueryRestApi { * @return In case all filters were successfully created the ResponseEntity with status code 201 with a list of successfully created entities * is returned. In any failure the JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Create target filter", description = "Handles the POST request to create a new target filter query. Required permission: CREATE_TARGET") + @Operation(summary = "Create target filter", + description = "Handles the POST request to create a new target filter query. Required permission: CREATE_TARGET") @PostCreateResponses - @PostMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETFILTERS_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity createFilter( @RequestBody MgmtTargetFilterQueryRequestBody filter); @@ -128,9 +127,8 @@ public interface MgmtTargetFilterQueryRestApi { */ @Operation(summary = "Updates target filter query by id", description = "Handles the PUT request of updating a target filter query. Required permission: UPDATE_TARGET") @PutResponses - @PutMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = TARGETFILTERS_V1 + "/{filterId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateFilter( @PathVariable("filterId") Long filterId, @RequestBody MgmtTargetFilterQueryRequestBody targetFilterRest); @@ -144,8 +142,7 @@ public interface MgmtTargetFilterQueryRestApi { */ @Operation(summary = "Delete target filter by id", description = "Handles the DELETE request of deleting a target filter query. Required permission: DELETE_TARGET") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = TARGETFILTERS_V1 + "/{filterId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity deleteFilter(@PathVariable("filterId") Long filterId); /** @@ -156,8 +153,7 @@ public interface MgmtTargetFilterQueryRestApi { */ @Operation(summary = "Return distribution set for auto assignment of a specific target filter", description = "Handles the GET request of retrieving the auto assign distribution set. Required permission: READ_TARGET") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETFILTERS_V1 + "/{filterId}/autoAssignDS", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAssignedDistributionSet(@PathVariable("filterId") Long filterId); /** @@ -171,9 +167,8 @@ public interface MgmtTargetFilterQueryRestApi { description = "Handles the POST request of setting the auto assign distribution set for a target filter " + "query. Required permissions: UPDATE_TARGET and READ_REPOSITORY") @PostUpdateResponses - @PostMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETFILTERS_V1 + "/{filterId}/autoAssignDS", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity postAssignedDistributionSet( @PathVariable("filterId") Long filterId, @RequestBody MgmtDistributionSetAutoAssignment autoAssignRequest); @@ -188,6 +183,6 @@ public interface MgmtTargetFilterQueryRestApi { description = "Removes the auto assign distribution set from the target filter query. " + "Required permission: UPDATE_TARGET") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS") + @DeleteMapping(value = TARGETFILTERS_V1 + "/{filterId}/autoAssignDS") ResponseEntity deleteAssignedDistributionSet(@PathVariable("filterId") Long filterId); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetGroupRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetGroupRestApi.java index e15b8adbd..c1bedc6cd 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetGroupRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetGroupRestApi.java @@ -9,10 +9,16 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_GROUP_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutNoContentResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -24,8 +30,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -34,11 +38,12 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; -@Tag( - name = "Target Groups", description = "REST API for Target Groups operations.", +@Tag(name = "Target Groups", description = "REST API for Target Groups operations.", extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_GROUP_ORDER))) public interface MgmtTargetGroupRestApi { + String TARGETGROUPS_V1 = MgmtRestConstants.REST_V1 + "/targetgroups"; + /** * Handles the GET request of retrieving a list of assigned targets for a specific group. Complex grouping (subgroups) not supported here. * For complex grouping use the analogical resource with query parameter for target group. @@ -55,28 +60,21 @@ public interface MgmtTargetGroupRestApi { description = "Handles the GET request of retrieving a list of assigned targets for a specific group. Complex grouping (subgroups) not supported here." + "For complex grouping use the analogical resource with query parameter for target group.") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + MgmtRestConstants.GROUP_ASSIGNED, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETGROUPS_V1 + "/{group}/assigned", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedTargets( @PathVariable @Schema(description = "The target group of the targets") String group, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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 ); @@ -97,7 +95,7 @@ public interface MgmtTargetGroupRestApi { description = "Handles the GET request of retrieving a list of assigned targets for a specific group. Complex grouping (subgroups) is supported here." + "Search could be for specific group, complex group e.g Parent/Child or also for groups including its subgroups") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + @GetMapping(value = TARGETGROUPS_V1 + "/assigned") ResponseEntity> getAssignedTargetsWithSubgroups( @RequestParam(value = "group") @Schema(description = "Target Group or Filter based on target groups. ") @@ -105,22 +103,16 @@ public interface MgmtTargetGroupRestApi { @RequestParam(value = "subgroups", defaultValue = "false") @Schema(description = " Possibility to search for subgroups with wildcard or not - e.g. ParentGroup/*") boolean subgroups, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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 ); @@ -136,7 +128,7 @@ public interface MgmtTargetGroupRestApi { description = "Handles the POST request of target assignment. Already assigned target will be ignored. " + "For complex groups use analogical method with query parameters.") @PutNoContentResponses - @PutMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + @PutMapping(value = TARGETGROUPS_V1 + "/assigned") ResponseEntity assignTargetsToGroupWithSubgroups( @RequestParam("group") @Schema(description = "The target group to be set. Sub-grouping is allowed here - '/' could be used for subgroups") String group, @@ -154,7 +146,7 @@ public interface MgmtTargetGroupRestApi { description = "Handles the PUT request of target assignment." + "Subgroups are NOT allowed here - e.g. Parent/Child") @PutNoContentResponses - @PutMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + MgmtRestConstants.GROUP_ASSIGNED) + @PutMapping(value = TARGETGROUPS_V1 + "/{group}/assigned") ResponseEntity assignTargetsToGroup( @PathVariable(value = "group") @Schema(description = "The target group to be set. Sub-grouping not allowed here, for sub-grouping use the analogical method with query parameter.") @@ -173,17 +165,14 @@ public interface MgmtTargetGroupRestApi { * */ @Operation(summary = "Assign target(s) to given group by rsql", - description = "Handles the PUT request of target group assignment." + - "Subgroups are NOT allowed here - e.g. Parent/Child") + description = "Handles the PUT request of target group assignment. Subgroups are NOT allowed here - e.g. Parent/Child") @PutNoContentResponses - @PutMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/{group}") + @PutMapping(value = TARGETGROUPS_V1 + "/{group}") ResponseEntity assignTargetsToGroupWithRsql( @PathVariable String group, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") + @Schema(description = "Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for available fields.") String rsql ); @@ -195,7 +184,7 @@ public interface MgmtTargetGroupRestApi { @Operation(summary = "Unassign targets from their target groups", description = "Handles the DELETE request to unassign the given target(s).") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + @DeleteMapping(value = TARGETGROUPS_V1 + "/assigned") ResponseEntity unassignTargetsFromGroup( @RequestBody(required = false) @Schema(description = "List of controller ids to be unassigned from their groups", example = "[\"controllerId1\", \"controllerId2\"]") @@ -210,12 +199,10 @@ public interface MgmtTargetGroupRestApi { @Operation(summary = "Unassign targets from their target groups by filter", description = "Handles the DELETE request to unassign targets by RSQL filter.") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING) + @DeleteMapping(value = TARGETGROUPS_V1) ResponseEntity unassignTargetsFromGroupByRsql( @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.""") + @Schema(description = "Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for available fields.") String rsql ); @@ -226,8 +213,7 @@ public interface MgmtTargetGroupRestApi { @Operation(summary = "Return all assigned target groups", description = "Handles the GET request of retrieving a list of all target groups.") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETGROUPS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getTargetGroups(); /** @@ -240,14 +226,12 @@ public interface MgmtTargetGroupRestApi { description = "Assign targets matching a rsql filter to a provided target group" + "Subgroups are allowed - e.g. Parent/Child") @PutNoContentResponses - @PutMapping(value = MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING) + @PutMapping(value = TARGETGROUPS_V1) ResponseEntity assignTargetsToGroup( @RequestParam(name = "group") @Schema(description = "The target group to be set. Sub-grouping is allowed here - '/' could be used for subgroups") String group, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH) - @Schema(description = """ - Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for - available fields.""") + @Schema(description = "Query fields based on the Feed Item Query Language (FIQL). See Entity Definitions for available fields.") String rsqlParam); -} +} \ No newline at end of file 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 05a65cc69..104a433e6 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 @@ -9,6 +9,10 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GONE_410; @@ -19,6 +23,8 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.NOT_FOUND_404; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutNoContentResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -52,8 +58,6 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateNoContentResponses; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -72,6 +76,9 @@ import org.springframework.web.bind.annotation.RequestParam; extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_ORDER))) public interface MgmtTargetRestApi { + String TARGETS_V1 = MgmtRestConstants.REST_V1 + "/targets"; + String TARGET_ID_TARGETTYPE = "/{targetId}/targettype"; + /** * Handles the GET request of retrieving a single target. * @@ -81,8 +88,7 @@ public interface MgmtTargetRestApi { @Operation(summary = "Return target by id", description = "Handles the GET request of retrieving a single target. " + "Required Permission: READ_TARGET.") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getTarget(@PathVariable("targetId") String targetId); /** @@ -98,30 +104,21 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return all targets", description = "Handles the GET request of retrieving all targets. Required permission: READ_TARGET") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getTargets( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -133,9 +130,8 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Create target(s)", description = "Handles the POST request of creating new targets. The request body must always be a list of targets. Required Permission: CREATE_TARGET") @PostCreateResponses - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETS_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createTargets(@RequestBody List targets); /** @@ -149,9 +145,8 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Update target by id", description = "Handles the PUT request of updating a target. Required Permission: UPDATE_TARGET") @PutResponses - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = TARGETS_V1 + "/{targetId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateTarget( @PathVariable("targetId") String targetId, @RequestBody MgmtTargetRequestBody targetRest); @@ -165,7 +160,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Delete target by id", description = "Handles the DELETE request of deleting a single target. Required Permission: DELETE_TARGET") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}") + @DeleteMapping(value = TARGETS_V1 + "/{targetId}") ResponseEntity deleteTarget(@PathVariable("targetId") String targetId); /** @@ -177,7 +172,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Unassign target type from target.", description = "Remove the target type from a target. The target type will be set to null. Required permission: UPDATE_TARGET") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE) + @DeleteMapping(value = TARGETS_V1 + TARGET_ID_TARGETTYPE) ResponseEntity unassignTargetType(@PathVariable("targetId") String targetId); /** @@ -190,8 +185,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Assign target type to a target", description = "Assign or update the target type of a target. Required permission: UPDATE_TARGET") @PostUpdateNoContentResponses - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETS_V1 + TARGET_ID_TARGETTYPE, consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity assignTargetType(@PathVariable("targetId") String targetId, @RequestBody MgmtId targetTypeId); /** @@ -202,8 +196,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return attributes of a specific target", description = "Handles the GET request of retrieving the attributes of a specific target. Reponse is a key/value list. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/attributes", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/attributes", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAttributes(@PathVariable("targetId") String targetId); /** @@ -220,31 +213,22 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return actions for a specific target", description = "Handles the GET request of retrieving the full action history of a specific target. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/actions", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getActionHistory( @PathVariable("targetId") String targetId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -258,8 +242,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Deletes all actions for the provided target EXCEPT the latest N actions OR by provided action IDs list.", description = "Deletes/Purges the action history of the target except the last N actions OR deletes only the actions in the provided action ids list. Required Permission: DELETE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = TARGETS_V1 + "/{targetId}/actions", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity deleteActionsForTarget( @PathVariable("targetId") String targetId, @RequestParam(name = "keepLast", required = false, defaultValue = "-1") int keepLast, @@ -273,10 +256,10 @@ public interface MgmtTargetRestApi { * @param actionId to load * @return the action */ - @Operation(summary = "Return action by id of a specific target", description = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET") + @Operation(summary = "Return action by id of a specific target", + description = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/actions/{actionId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAction( @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId); @@ -289,12 +272,14 @@ public interface MgmtTargetRestApi { * @param force optional parameter, which indicates a force cancel * @return status no content in case cancellation was successful */ - @Operation(summary = "Cancel action for a specific target", description = "Cancels an active action, only active actions can be deleted. Required Permission: UPDATE_TARGET") + @Operation(summary = "Cancel action for a specific target", + description = "Cancels an active action, only active actions can be deleted. Required Permission: UPDATE_TARGET") @DeleteResponses @ApiResponses(value = { - @ApiResponse(responseCode = METHOD_NOT_ALLOWED_405, description = "Software module is locked", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = METHOD_NOT_ALLOWED_405, description = "Software module is locked", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}") + @DeleteMapping(value = TARGETS_V1 + "/{targetId}/actions/{actionId}") ResponseEntity cancelAction( @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, @@ -310,9 +295,8 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Switch an action from soft to forced", description = "Handles the PUT request to switch an action from soft to forced. Required Permission: UPDATE_TARGET.") @PutResponses - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = TARGETS_V1 + "/{targetId}/actions/{actionId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateAction( @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, @@ -332,9 +316,9 @@ public interface MgmtTargetRestApi { @ApiResponse(responseCode = GONE_410, description = "Action is not active anymore.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))), }) - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}/confirmation", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = TARGETS_V1 + "/{targetId}/actions/{actionId}/confirmation", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateActionConfirmation( @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, @@ -352,16 +336,20 @@ public interface MgmtTargetRestApi { * @return a list of all ActionStatus for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Return status of a specific action on a specific target", description = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET") + @Operation(summary = "Return status of a specific action on a specific target", + description = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}/status", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/actions/{actionId}/status", + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getActionStatusList( @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) String sortParam); + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) + int pagingOffsetParam, + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + int pagingLimitParam, + @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) + String sortParam); /** * Handles the GET request of retrieving the assigned distribution set of a specific target. @@ -371,8 +359,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return the assigned distribution set of a specific target", description = "Handles the GET request of retrieving the assigned distribution set of an specific target. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/assignedDS", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/assignedDS", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAssignedDistributionSet(@PathVariable("targetId") String targetId); /** @@ -386,9 +373,8 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Assigns a distribution set to a specific target", description = "Handles the POST request for assigning a distribution set to a specific target. Required Permission: READ_REPOSITORY and UPDATE_TARGET") @PostUpdateResponses - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/assignedDS", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETS_V1 + "/{targetId}/assignedDS", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity postAssignedDistributionSet( @PathVariable("targetId") String targetId, @RequestBody @Valid MgmtDistributionSetAssignments dsAssignments, @@ -408,8 +394,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return installed distribution set of a specific target", description = "Handles the GET request of retrieving the installed distribution set of an specific target. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/installedDS", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/installedDS", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getInstalledDistributionSet(@PathVariable("targetId") String targetId); /** @@ -419,8 +404,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return tags for specific target", description = "Get a paged list of tags for a target. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/tags", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/tags", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getTags(@PathVariable("targetId") String targetId); /** @@ -432,10 +416,11 @@ public interface MgmtTargetRestApi { @Operation(summary = "Create a list of metadata for a specific target", description = "Create a list of metadata entries Required permissions: READ_REPOSITORY and UPDATE_TARGET") @PostCreateResponses @ApiResponses(value = { - @ApiResponse(responseCode = NOT_FOUND_404, description = "Target not found", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) + @ApiResponse(responseCode = NOT_FOUND_404, description = "Target not found", + content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", - consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PostMapping(value = TARGETS_V1 + "/{targetId}/metadata", + consumes = { APPLICATION_JSON_VALUE, HAL_JSON_VALUE }) ResponseEntity createMetadata(@PathVariable("targetId") String targetId, @RequestBody List metadataRest); /** @@ -446,8 +431,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return metadata for specific target", description = "Get a paged list of metadata for a target. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/metadata", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getMetadata(@PathVariable("targetId") String targetId); /** @@ -457,10 +441,10 @@ public interface MgmtTargetRestApi { * @param metadataKey the key of the metadata entry to retrieve the value from * @return status OK if get request is successful with the value of the metadata */ - @Operation(summary = "Return single metadata value for a specific key of a target", description = "Get a single metadata value for a metadata key. Required permission: READ_REPOSITORY") + @Operation(summary = "Return single metadata value for a specific key of a target", + description = "Get a single metadata value for a metadata key. Required permission: READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}", - produces = { MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/metadata/{metadataKey}", produces = { APPLICATION_JSON_VALUE }) ResponseEntity getMetadataValue( @PathVariable("targetId") String targetId, @PathVariable("metadataKey") String metadataKey); @@ -472,9 +456,10 @@ public interface MgmtTargetRestApi { * @param metadataKey the key of the metadata to update the value * @param metadata update body */ - @Operation(summary = "Updates a single metadata value of a target", description = "Update a single metadata value for speficic key. Required permission: UPDATE_REPOSITORY") + @Operation(summary = "Updates a single metadata value of a target", + description = "Update a single metadata value for speficic key. Required permission: UPDATE_REPOSITORY") @PutNoContentResponses - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}") + @PutMapping(value = TARGETS_V1 + "/{targetId}/metadata/{metadataKey}") ResponseEntity updateMetadata( @PathVariable("targetId") String targetId, @PathVariable("metadataKey") String metadataKey, @@ -489,7 +474,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Deletes a single metadata entry from a target", description = "Delete a single metadata. Required permission: UPDATE_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}") + @DeleteMapping(value = TARGETS_V1 + "/{targetId}/metadata/{metadataKey}") ResponseEntity deleteMetadata( @PathVariable("targetId") String targetId, @PathVariable("metadataKey") String metadataKey); @@ -502,8 +487,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Return the current auto-confitm state for a specific target", description = "Handles the GET request to check the current auto-confirmation state of a target. Required Permission: READ_TARGET") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETS_V1 + "/{targetId}/autoConfirm", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getAutoConfirmStatus( @PathVariable("targetId") String targetId); @@ -516,7 +500,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Activate auto-confirm on a specific target", description = "Handles the POST request to activate auto-confirmation for a specific target. As a result all current active as well as future actions will automatically be confirmed by mentioning the initiator as triggered person. Actions will be automatically confirmed, as long as auto-confirmation is active. Required Permission: UPDATE_TARGET") @PostUpdateNoContentResponses - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm/activate") + @PostMapping(value = TARGETS_V1 + "/{targetId}/autoConfirm/activate") ResponseEntity activateAutoConfirm( @PathVariable("targetId") String targetId, @RequestBody(required = false) MgmtTargetAutoConfirmUpdate update); @@ -529,7 +513,7 @@ public interface MgmtTargetRestApi { */ @Operation(summary = "Deactivate auto-confirm on a specific target", description = "Handles the POST request to deactivate auto-confirmation for a specific target. All active actions will remain unchanged while all future actions need to be confirmed, before processing with the deployment. Required Permission: UPDATE_TARGET") @PostUpdateNoContentResponses - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm/deactivate") + @PostMapping(value = TARGETS_V1 + "/{targetId}/autoConfirm/deactivate") ResponseEntity deactivateAutoConfirm( @PathVariable("targetId") String targetId); } \ No newline at end of file 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 8f6135c33..755402122 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 @@ -9,13 +9,18 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_TAG_ORDER; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -30,8 +35,6 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateNoContentResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -50,6 +53,9 @@ import org.springframework.web.bind.annotation.RequestParam; extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_TAG_ORDER))) public interface MgmtTargetTagRestApi { + String TARGETTAGS_V1 = MgmtRestConstants.REST_V1 + "/targettags"; + String TARGET_TAG_ID_ASSIGNED = "/{targetTagId}/assigned"; + /** * Handles the GET request of retrieving all target tags. * @@ -61,33 +67,23 @@ public interface MgmtTargetTagRestApi { * @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. */ - @Operation(summary = "Return all target tags", - description = "Handles the GET request of retrieving all target tags.") + @Operation(summary = "Return all target tags", description = "Handles the GET request of retrieving all target tags.") @GetIfExistResponses - @GetMapping(value = TARGET_TAG_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETTAGS_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTags( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -96,11 +92,9 @@ public interface MgmtTargetTagRestApi { * @param targetTagId the ID of the target tag to retrieve * @return a single target tag with status OK. */ - @Operation(summary = "Return target tag by id", - description = "Handles the GET request of retrieving a single target tag.") + @Operation(summary = "Return target tag by id", description = "Handles the GET request of retrieving a single target tag.") @GetResponses - @GetMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETTAGS_V1 + "/{targetTagId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getTargetTag(@PathVariable("targetTagId") Long targetTagId); /** @@ -113,9 +107,8 @@ public interface MgmtTargetTagRestApi { @Operation(summary = "Create target tag(s)", description = "Handles the POST request of creating new target tag. " + "The request body must always be a list of target tags.") @PostCreateResponses - @PostMapping(value = TARGET_TAG_V1_REQUEST_MAPPING, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETTAGS_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createTargetTags(@RequestBody List tags); /** @@ -127,9 +120,8 @@ public interface MgmtTargetTagRestApi { */ @Operation(summary = "Update target tag by id", description = "Handles the PUT request of updating a target tag.") @PutResponses - @PutMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = TARGETTAGS_V1 + "/{targetTagId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateTargetTag( @PathVariable("targetTagId") Long targetTagId, @RequestBody MgmtTagRequestBodyPut restTargetTagRest); @@ -140,10 +132,9 @@ public interface MgmtTargetTagRestApi { * @param targetTagId the ID of the target tag * @return status OK if delete as successfully. */ - @Operation(summary = "Delete target tag by id", - description = "Handles the DELETE request of deleting a single target tag.") + @Operation(summary = "Delete target tag by id", description = "Handles the DELETE request of deleting a single target tag.") @DeleteResponses - @DeleteMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}") + @DeleteMapping(value = TARGETTAGS_V1 + "/{targetTagId}") ResponseEntity deleteTargetTag(@PathVariable("targetTagId") Long targetTagId); /** @@ -160,31 +151,22 @@ public interface MgmtTargetTagRestApi { @Operation(summary = "Return assigned targets for tag", description = "Handles the GET request of retrieving a list of assigned targets.") @GetResponses - @GetMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_ID_ASSIGNED, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETTAGS_V1 + TARGET_TAG_ID_ASSIGNED, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedTargets( @PathVariable("targetTagId") Long targetTagId, @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -197,7 +179,7 @@ public interface MgmtTargetTagRestApi { @Operation(summary = "Assign target(s) to given tagId", description = "Handles the POST request of target assignment. Already assigned target will be ignored.") @PostUpdateNoContentResponses - @PostMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_ID_ASSIGNED + "/{controllerId}") + @PostMapping(value = TARGETTAGS_V1 + TARGET_TAG_ID_ASSIGNED + "/{controllerId}") ResponseEntity assignTarget( @PathVariable("targetTagId") Long targetTagId, @PathVariable("controllerId") String controllerId); @@ -212,9 +194,7 @@ public interface MgmtTargetTagRestApi { @Operation(summary = "Assign target(s) to given tagId", description = "Handles the POST request of target assignment. Already assigned target will be ignored.") @PostUpdateNoContentResponses - @PostMapping( - value = TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_ID_ASSIGNED, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETTAGS_V1 + TARGET_TAG_ID_ASSIGNED, consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity assignTargets( @PathVariable("targetTagId") Long targetTagId, @Schema(description = "List of controller ids to be assigned", example = "[\"controllerId1\", \"controllerId2\"]") @@ -228,11 +208,9 @@ public interface MgmtTargetTagRestApi { * @param controllerId the ID of the target to unassign * @return http status code */ - @Operation(summary = "Unassign target from a given tagId", - description = "Handles the DELETE request to unassign the given target.") + @Operation(summary = "Unassign target from a given tagId", description = "Handles the DELETE request to unassign the given target.") @DeleteResponses - @DeleteMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + - MgmtRestConstants.TARGET_TAG_ID_ASSIGNED + "/{controllerId}") + @DeleteMapping(value = TARGETTAGS_V1 + TARGET_TAG_ID_ASSIGNED + "/{controllerId}") ResponseEntity unassignTarget( @PathVariable("targetTagId") Long targetTagId, @PathVariable("controllerId") String controllerId); @@ -244,11 +222,9 @@ public interface MgmtTargetTagRestApi { * @param controllerId the ID of the target to unassign * @return http status code */ - @Operation(summary = "Unassign targets from a given tagId", - description = "Handles the DELETE request to unassign the given targets.") + @Operation(summary = "Unassign targets from a given tagId", description = "Handles the DELETE request to unassign the given targets.") @DeleteResponses - @DeleteMapping(value = TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_ID_ASSIGNED, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = TARGETTAGS_V1 + TARGET_TAG_ID_ASSIGNED, consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity unassignTargets( @PathVariable("targetTagId") Long targetTagId, @RequestParam(value = "onNotFoundPolicy", required = false, defaultValue = "FAIL") OnNotFoundPolicy onNotFoundPolicy, 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 5d68efb28..b8d85e4c2 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 @@ -9,6 +9,10 @@ */ package org.eclipse.hawkbit.mgmt.rest.api; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_TYPE_ORDER; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; @@ -16,6 +20,8 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.NOT_FOUND_404; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PostCreateResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.List; @@ -35,8 +41,6 @@ import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyP import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPut; import org.eclipse.hawkbit.rest.ApiResponsesConstants.PostUpdateNoContentResponses; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -55,6 +59,9 @@ import org.springframework.web.bind.annotation.RequestParam; extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TARGET_TYPE_ORDER))) public interface MgmtTargetTypeRestApi { + String TARGETTYPES_V1 = MgmtRestConstants.REST_V1 + "/targettypes"; + String COMPATIBLEDISTRIBUTIONSETTYPES = "compatibledistributionsettypes"; + /** * Handles the GET request of retrieving all TargetTypes. * @@ -68,30 +75,21 @@ public interface MgmtTargetTypeRestApi { */ @Operation(summary = "Return all target types", description = "Handles the GET request of retrieving all target types.") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETTYPES_V1, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTypes( @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.""") + @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) + @RequestParam(value = REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @Schema(description = "The paging offset (default is 0)") int pagingOffsetParam, - @RequestParam( - value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) + @RequestParam(value = REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) @Schema(description = "The maximum number of entries in a page (default is 50)") int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) - @Schema(description = """ - The query parameter sort allows to define the sort order for the result of a query. A sort criteria - 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.""") + @Schema(description = "The query parameter sort allows to define the sort order for the result of a query. " + + "A sort criteria 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); /** @@ -100,11 +98,9 @@ public interface MgmtTargetTypeRestApi { * @param targetTypeId the ID of the target type to retrieve * @return a single target type with status OK. */ - @Operation(summary = "Return target type by id", - description = "Handles the GET request of retrieving a single target type") + @Operation(summary = "Return target type by id", description = "Handles the GET request of retrieving a single target type") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETTYPES_V1 + "/{targetTypeId}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getTargetType(@PathVariable("targetTypeId") Long targetTypeId); /** @@ -116,7 +112,7 @@ public interface MgmtTargetTypeRestApi { @Operation(summary = "Delete target type by id", description = "Handles the DELETE request for a single target type. Required Permission: DELETE_TARGET") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}") + @DeleteMapping(value = TARGETTYPES_V1 + "/{targetTypeId}") ResponseEntity deleteTargetType(@PathVariable("targetTypeId") Long targetTypeId); /** @@ -129,9 +125,8 @@ public interface MgmtTargetTypeRestApi { @Operation(summary = "Update target type by id", description = "Handles the PUT request for a single target type. Required Permission: UPDATE_TARGET") @PutResponses - @PutMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = TARGETTYPES_V1 + "/{targetTypeId}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity updateTargetType( @PathVariable("targetTypeId") Long targetTypeId, @RequestBody MgmtTargetTypeRequestBodyPut restTargetType); @@ -143,16 +138,16 @@ public interface MgmtTargetTypeRestApi { * @return In case all target types could be successfully created the ResponseEntity with status code 201 - Created but without * ResponseBody. In any failure the JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Create target types", description = "Handles the POST request for creating new target " + - "types. The request body must always be a list of types. Required Permission: CREATE_TARGET") + @Operation(summary = "Create target types", + description = "Handles the POST request for creating new target types. The request body must always be a list of types. " + + "Required Permission: CREATE_TARGET") @PostCreateResponses @ApiResponses(value = { @ApiResponse(responseCode = NOT_FOUND_404, description = "Target type not found.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @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 }) + @PostMapping(value = TARGETTYPES_V1, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> createTargetTypes(@RequestBody List targetTypes); /** @@ -165,8 +160,8 @@ public interface MgmtTargetTypeRestApi { "of retrieving the list of compatible distribution set types in that target type. " + "Required Permission: READ_TARGET, READ_REPOSITORY") @GetResponses - @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = TARGETTYPES_V1 + "/{targetTypeId}/" + COMPATIBLEDISTRIBUTIONSETTYPES, + produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getCompatibleDistributionSets(@PathVariable("targetTypeId") Long targetTypeId); /** @@ -180,8 +175,7 @@ public interface MgmtTargetTypeRestApi { description = "Handles the DELETE request for removing a distribution set type from a single target type. " + "Required Permission: UPDATE_TARGET and READ_REPOSITORY") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + - MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES + "/{distributionSetTypeId}") + @DeleteMapping(value = TARGETTYPES_V1 + "/{targetTypeId}/" + COMPATIBLEDISTRIBUTIONSETTYPES + "/{distributionSetTypeId}") ResponseEntity removeCompatibleDistributionSet( @PathVariable("targetTypeId") Long targetTypeId, @PathVariable("distributionSetTypeId") Long distributionSetTypeId); @@ -197,8 +191,8 @@ public interface MgmtTargetTypeRestApi { description = "Handles the POST request for adding compatible distribution set types to a target type. " + "Required Permission: UPDATE_TARGET and READ_REPOSITORY") @PostUpdateNoContentResponses - @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES, - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = TARGETTYPES_V1 + "/{targetTypeId}/" + COMPATIBLEDISTRIBUTIONSETTYPES, + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity addCompatibleDistributionSets( @PathVariable("targetTypeId") Long targetTypeId, @RequestBody List distributionSetTypeIds); diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java index 0882bae51..b55eb3e5c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java @@ -14,6 +14,8 @@ import static org.eclipse.hawkbit.rest.ApiResponsesConstants.DeleteResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetIfExistResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.GetResponses; import static org.eclipse.hawkbit.rest.ApiResponsesConstants.PutResponses; +import static org.springframework.hateoas.MediaTypes.HAL_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import java.util.Map; @@ -24,9 +26,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest; import org.eclipse.hawkbit.rest.OpenApi; -import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -44,16 +44,17 @@ import org.springframework.web.bind.annotation.ResponseStatus; extensions = @Extension(name = OpenApi.X_HAWKBIT, properties = @ExtensionProperty(name = "order", value = TENANT_ORDER))) public interface MgmtTenantManagementRestApi { + String SYSTEM_V1 = MgmtRestConstants.REST_V1 + "/system"; + /** * Handles the GET request for receiving all tenant specific configuration values. * * @return a map of all configuration values. */ - @Operation(summary = "Return all tenant specific configuration values", description = "The GET request returns " + - "a list of all possible configuration keys for the tenant. Required Permission: READ_TENANT_CONFIGURATION") + @Operation(summary = "Return all tenant specific configuration values", + description = "The GET request returns a list of all possible configuration keys for the tenant. Required Permission: READ_TENANT_CONFIGURATION") @GetIfExistResponses - @GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SYSTEM_V1 + "/configs", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity> getTenantConfiguration(); /** @@ -67,8 +68,7 @@ public interface MgmtTenantManagementRestApi { "configuration value of a specific configuration key for the tenant. " + "Required Permission: READ_TENANT_CONFIGURATION") @GetResponses - @GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = SYSTEM_V1 + "/configs/{keyName}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) ResponseEntity getTenantConfigurationValue(@PathVariable("keyName") String keyName); /** @@ -77,13 +77,12 @@ public interface MgmtTenantManagementRestApi { * @param keyName the name of the configuration key * @param configurationValueRest the new value for the configuration */ - @Operation(summary = "Update a tenant specific configuration value.", description = "The PUT request changes a " + - "configuration value of a specific configuration key for the tenant. " + - "Required Permission: TENANT_CONFIGURATION") + @Operation(summary = "Update a tenant specific configuration value.", + description = "The PUT request changes a configuration value of a specific configuration key for the tenant. " + + "Required Permission: TENANT_CONFIGURATION") @PutResponses - @PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = SYSTEM_V1 + "/configs/{keyName}", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.NO_CONTENT) void updateTenantConfigurationValue( @PathVariable("keyName") String keyName, @@ -94,12 +93,11 @@ public interface MgmtTenantManagementRestApi { * * @param configurationValueMap a Map of name - value pairs for the configurations */ - @Operation(summary = "Batch update of tenant configuration.", description = "The PUT request updates the whole " + - "configuration for the tenant. Required Permission: TENANT_CONFIGURATION") + @Operation(summary = "Batch update of tenant configuration.", + description = "The PUT request updates the whole configuration for the tenant. Required Permission: TENANT_CONFIGURATION") @PutResponses - @PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs", - consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = SYSTEM_V1 + "/configs", + consumes = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }, produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.NO_CONTENT) void updateTenantConfiguration(@RequestBody Map configurationValueMap); @@ -108,12 +106,11 @@ public interface MgmtTenantManagementRestApi { * * @param keyName the Name of the configuration key */ - @Operation(summary = "Delete a tenant specific configuration value", description = "The DELETE request removes a " + - "tenant specific configuration value for the tenant. Afterwards the global default value is used. " + - "Required Permission: TENANT_CONFIGURATION") + @Operation(summary = "Delete a tenant specific configuration value", + description = "The DELETE request removes a tenant specific configuration value for the tenant. " + + "Afterwards the global default value is used. Required Permission: TENANT_CONFIGURATION") @DeleteResponses - @DeleteMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", - produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = SYSTEM_V1 + "/configs/{keyName}", produces = { HAL_JSON_VALUE, APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.NO_CONTENT) void deleteTenantConfigurationValue(@PathVariable("keyName") String keyName); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java index 263c1ade8..e7f5ab755 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetMapper.java @@ -109,7 +109,7 @@ public class MgmtDistributionSetMapper { response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getAssignedSoftwareModules(response.getId(), MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null)) - .withRel(MgmtRestConstants.DISTRIBUTIONSET_V1_MODULE).expand()); + .withRel("modules").expand()); response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class) .getDistributionSetType(distributionSet.getType().getId())).withRel("type").expand()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java index 23abcbebe..88a506580 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtDistributionSetTypeMapper.java @@ -24,7 +24,6 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -76,10 +75,10 @@ public final class MgmtDistributionSetTypeMapper { public static void addLinks(final MgmtDistributionSetType result) { result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getId())) - .withRel(MgmtRestConstants.MANDATORYMODULES).expand()); + .withRel("mandatorymodules").expand()); result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getOptionalModules(result.getId())) - .withRel(MgmtRestConstants.OPTIONALMODULES).expand()); + .withRel("optionalmodules").expand()); } private DistributionSetTypeManagement.Create fromRequest(final MgmtDistributionSetTypeRequestBodyPost smsRest) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java index 39caa9947..1ca3207b2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtSoftwareModuleMapper.java @@ -28,7 +28,6 @@ import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifactHash; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleMetadata; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; -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; @@ -118,9 +117,9 @@ public final class MgmtSoftwareModuleMapper { 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()); + .withRel("artifacts").expand()); response.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(softwareModule.getType().getId())) - .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE).expand()); + .withRel("type").expand()); response.add(WebMvcLinkBuilder.linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getId())) .withRel("metadata").expand()); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java index 522bb2ca8..972950fd6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java @@ -81,24 +81,24 @@ public final class MgmtTargetMapper { */ public static void addTargetLinks(final MgmtTarget response) { response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAssignedDistributionSet(response.getControllerId())) - .withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET).expand()); + .withRel("assignedDS").expand()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).getInstalledDistributionSet(response.getControllerId())) - .withRel(MgmtRestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET).expand()); + .withRel("installedDS").expand()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAttributes(response.getControllerId())) - .withRel(MgmtRestConstants.TARGET_V1_ATTRIBUTES).expand()); + .withRel("attributes").expand()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), null, 0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, ActionFields.ID.getName() + ":" + SortDirection.DESC)) - .withRel(MgmtRestConstants.TARGET_V1_ACTIONS).expand()); + .withRel(MgmtTarget.TARGET_V1_ACTIONS).expand()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).getMetadata(response.getControllerId())) .withRel("metadata").expand()); if (response.getTargetType() != null) { response.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(response.getTargetType())) - .withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_TARGET_TYPE).expand()); + .withRel(MgmtTarget.TARGET_TYPE).expand()); } if (response.getAutoConfirmActive() != null) { response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAutoConfirmStatus(response.getControllerId())) - .withRel(MgmtRestConstants.TARGET_V1_AUTO_CONFIRM).expand()); + .withRel(MgmtTarget.AUTO_CONFIRM).expand()); } } @@ -110,11 +110,11 @@ public final class MgmtTargetMapper { response.setInitiator(status.getInitiator()); response.setRemark(status.getRemark()); response.add(linkTo(methodOn(MgmtTargetRestApi.class).deactivateAutoConfirm(target.getControllerId())) - .withRel(MgmtRestConstants.TARGET_V1_DEACTIVATE_AUTO_CONFIRM).expand()); + .withRel(MgmtTargetAutoConfirm.DEACTIVATE).expand()); } else { response = MgmtTargetAutoConfirm.disabled(); response.add(linkTo(methodOn(MgmtTargetRestApi.class).activateAutoConfirm(target.getControllerId(), null)) - .withRel(MgmtRestConstants.TARGET_V1_ACTIVATE_AUTO_CONFIRM).expand()); + .withRel(MgmtTargetAutoConfirm.ACTIVATE).expand()); } return response; } @@ -263,7 +263,7 @@ public final class MgmtTargetMapper { if (action.isCancelingOrCanceled()) { result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, action.getId())) - .withRel(MgmtRestConstants.TARGET_V1_CANCELED_ACTION).expand()); + .withRel("canceledaction").expand()); } result.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(controllerId)).withRel("target") @@ -277,12 +277,12 @@ public final class MgmtTargetMapper { result.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionStatusList(controllerId, action.getId(), 0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, ActionStatusFields.ID.getName() + ":" + SortDirection.DESC)) - .withRel(MgmtRestConstants.TARGET_V1_ACTION_STATUS).expand()); + .withRel(MgmtTarget.TARGET_V1_ACTION_STATUS).expand()); final Rollout rollout = action.getRollout(); if (rollout != null) { result.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId())) - .withRel(MgmtRestConstants.TARGET_V1_ROLLOUT).withName(rollout.getName()).expand()); + .withRel("rollout").withName(rollout.getName()).expand()); } return result; diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java index f28e83ea3..3b5627770 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetTypeMapper.java @@ -22,7 +22,6 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeAssignment; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetType; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPost; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTypeRestApi; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.TargetTypeManagement; @@ -74,7 +73,7 @@ public final class MgmtTargetTypeMapper { public static void addLinks(final MgmtTargetType result) { result.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getCompatibleDistributionSets(result.getId())) - .withRel(MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES).expand()); + .withRel(MgmtTargetTypeRestApi.COMPATIBLEDISTRIBUTIONSETTYPES).expand()); } private TargetTypeManagement.Create fromRequest(final MgmtTargetTypeRequestBodyPost targetTypesRest) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java index a8bf0491a..1eccf8f9b 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ACTION_V1_REQUEST_MAPPING; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi.ACTIONS_V1; import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_SEARCH; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.hasSize; @@ -27,9 +27,12 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -91,7 +94,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus; // pending status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingStatus)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -99,14 +102,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("content[0].active", equalTo(true))); // finished status none result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlFinishedStatus)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); // pending or finished status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingOrFinishedStatus)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -129,7 +132,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus; // running status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingStatus)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -138,14 +141,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("content[0].status", equalTo("running"))); // finished status none result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlFinishedStatus)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); // running or finished status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingOrFinishedStatus)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -177,7 +180,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlExtRefNoMatch = "externalref==234extRef"; // pending status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlExtRef)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -185,14 +188,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("content[0].externalRef", equalTo(externalRefs.get(0)))); // finished status none result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefWildcard)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlExtRefWildcard)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(2))) .andExpect(jsonPath("size", equalTo(2))); // pending or finished status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefNoMatch)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlExtRefNoMatch)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(0))) @@ -218,7 +221,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // verify that one result is returned if the actions are filtered for status code 200 final String rsqlStatusCode = "lastStatusCode==200"; - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlStatusCode)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -227,7 +230,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // verify no result is returned if we filter for a non-existing status code final String rsqlWrongStatusCode = "lastStatusCode==999"; - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlWrongStatusCode)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(0))) @@ -247,7 +250,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlDsVersion = "distributionSet.version==" + ds.getVersion(); final String rsqlDsId = "distributionSet.id==" + ds.getId(); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsName) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -256,25 +259,25 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsVersion)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsName + "," + rsqlDsVersion)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar")) + mvc.perform(get(ACTIONS_V1 + "?q=distributionSet.name==FooBar")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId)) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -303,7 +306,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlRolloutName = "rollout.name==" + rollout.getName(); final String rsqlRolloutId = "rollout.id==" + rollout.getId(); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlRolloutName) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -313,7 +316,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath( "content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlRolloutId) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -365,7 +368,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final Action action0 = actions.get(0); final Action action1 = actions.get(1); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING) + mvc.perform(get(ACTIONS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) .andDo(MockMvcResultPrinter.print()) @@ -403,7 +406,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { */ @Test void getActionsWithEmptyResult() throws Exception { - mvc.perform(get(ACTION_V1_REQUEST_MAPPING)) + mvc.perform(get(ACTIONS_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("size", equalTo(0))) @@ -421,7 +424,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // page 1: one entry final Action action0 = actions.get(0); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING) + mvc.perform(get(ACTIONS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) @@ -442,7 +445,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // page 2: one entry final Action action1 = actions.get(1); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING) + mvc.perform(get(ACTIONS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) @@ -473,8 +476,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); // not allowed methods - mvc.perform(post(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); - mvc.perform(put(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + mvc.perform(post(ACTIONS_V1)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + mvc.perform(put(ACTIONS_V1)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); } /** @@ -487,7 +490,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + actionId)) + mvc.perform(get(ACTIONS_V1 + "/" + actionId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue()))); @@ -498,7 +501,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { */ @Test void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception { - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + 101)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + mvc.perform(get(ACTIONS_V1 + "/" + 101)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); } @Test @@ -507,18 +510,18 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { Action action1 = assignmentResults.get(0).getAssignedEntity().get(0); Action action2 = assignmentResults.get(1).getAssignedEntity().get(0); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(ACTIONS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // verify action 1 .andExpect(jsonPath("content.[0].id", equalTo(action1.getId().intValue()))) .andExpect(jsonPath("content.[1].id", equalTo(action2.getId().intValue()))); - mvc.perform(delete(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId())) + mvc.perform(delete(ACTIONS_V1 + "/" + action1.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId())) + mvc.perform(get(ACTIONS_V1 + "/" + action1.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -527,7 +530,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { void shouldSuccessfullyDeleteMultipleActions() throws Exception { final List assignmentResults = createTargetsAndPerformAssignment(4); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(ACTIONS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // verify action 1 @@ -542,28 +545,28 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId(); actionIdsToDelete.add(deletedActionId2); - mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) + mvc.perform(delete(MgmtActionRestApi.ACTIONS_V1) .content(toJson(actionIdsToDelete)).contentType(APPLICATION_JSON)) .andExpect(status().isNoContent()); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1)) + mvc.perform(get(ACTIONS_V1 + "/" + deletedActionId1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId2)) + mvc.perform(get(ACTIONS_V1 + "/" + deletedActionId2)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); final Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0); final String rsql = "target.name==" + deletedAction3.getTarget().getName(); - mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) + mvc.perform(delete(MgmtActionRestApi.ACTIONS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, rsql).contentType(APPLICATION_JSON)) .andExpect(status().isNoContent()); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId())) + mvc.perform(get(ACTIONS_V1 + "/" + deletedAction3.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId())) + mvc.perform(get(ACTIONS_V1 + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -571,10 +574,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { @Test void shouldReceiveBadRequestWhenNeeded() throws Exception { // bad request on both empty parameters - mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()); + mvc.perform(delete(ACTIONS_V1).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()); // bad request when both parameters are present - mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON) + mvc.perform(delete(ACTIONS_V1).contentType(APPLICATION_JSON) .param(REQUEST_PARAMETER_SEARCH, "target.name==test") .content(toJson(List.of(1, 2, 3))) .contentType(APPLICATION_JSON)) @@ -582,16 +585,16 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { } private static String generateActionLink(final String targetId, final Long actionId) { - return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + - "/" + targetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId; + return "http://localhost" + MgmtTargetRestApi.TARGETS_V1 + + "/" + targetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId; } private static String generateTargetLink(final String targetId) { - return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId; + return "http://localhost" + MgmtTargetRestApi.TARGETS_V1 + "/" + targetId; } private static String generateDistributionSetLink(final Action action) { - return "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + action.getDistributionSet().getId(); + return "http://localhost" + MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1 + "/" + action.getDistributionSet().getId(); } private List createTargetsAndPerformAssignment(int n) { @@ -611,7 +614,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter) throws Exception { // pending status one result - mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter) + mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlTargetFilter) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -637,7 +640,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { } final ResultActions resultActions = - mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(ACTIONS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // verify action 1 @@ -683,7 +686,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { controllerManagement.updateActionExternalRef(actions.get(0).getId(), externalRef); } - final ResultActions resultActions = mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId())) + final ResultActions resultActions = mvc.perform(get(ACTIONS_V1 + "/{actionId}", actions.get(0).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java index a62124f2e..a44108bed 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java @@ -19,7 +19,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.util.Base64; -import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtBasicAuthRestApi; import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration; import org.eclipse.hawkbit.repository.test.TestConfiguration; import org.eclipse.hawkbit.repository.test.matcher.EventVerifier; @@ -84,7 +84,7 @@ class MgmtBasicAuthResourceTest { @Test @WithUser(principal = TEST_USER, authorities = { "READ", "WRITE", "DELETE" }) void validateBasicAuthWithUserDetails() throws Exception { - withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)) + withSecurityMock().perform(get(MgmtBasicAuthRestApi.USERINFO_V1)) .andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -100,7 +100,7 @@ class MgmtBasicAuthResourceTest { */ @Test void validateBasicAuthFailsWithInvalidCredentials() throws Exception { - defaultMock.perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING) + defaultMock.perform(get(MgmtBasicAuthRestApi.USERINFO_V1) .header(HttpHeaders.AUTHORIZATION, getBasicAuth("wrongUser", "wrongSecret"))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnauthorized()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 3132e24bd..13bb00b01 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.hasSize; @@ -100,7 +100,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe void getSoftwareModules() throws Exception { // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("SMTest"); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(set.getModules().size()))); @@ -114,7 +114,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); // post assignment - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM") .param("offset", "1").param("limit", "2").param("sort", "version:DESC").param("q", "name==one*") .accept(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -137,7 +137,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe smList.put(new JSONObject().put("id", smID)); } // post assignment - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(smList.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -150,7 +150,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe list.put(new JSONObject().put("id", Long.valueOf(targetId))); } assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -159,7 +159,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); // try to delete the Software Module from DistSet that has been assigned to the target - hence locked. - mvc.perform(delete(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" + smIDs.get(0)) + mvc.perform(delete(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM/" + smIDs.get(0)) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isLocked()) @@ -181,7 +181,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe smList.put(new JSONObject().put("id", smID)); } // post assignment - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(smList.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -191,7 +191,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final JSONArray list = createTargetAndJsonArray(null, null, null, null, null, knownTargetIds); // assign DisSet to target and test assignment assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -205,7 +205,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe smList2.put(new JSONObject().put("id", sm2.getId())); // fail because locked - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(smList2.toString())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isLocked()) @@ -220,7 +220,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88"); // Test if size is 0 - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(disSet.getModules().size()))); @@ -229,12 +229,12 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe testdataFactory.createSoftwareModuleApp().getId()); // post assignment - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(toJson(smIDs.stream().map(MgmtId::new).toList()))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); // Test if size is 3 - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(smIDs.size()))); @@ -248,18 +248,18 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // post assignment final String jsonIDs = toJson(moduleIDs.subList(0, maxSoftwareModules - smIDs.size()).stream().map(MgmtId::new).toList()); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(jsonIDs)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); // test if size corresponds with quota - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM?limit={limit}", maxSoftwareModules * 2)) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM?limit={limit}", maxSoftwareModules * 2)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(maxSoftwareModules))); // post one more to cause the quota to be exceeded - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM") .contentType(APPLICATION_JSON) .content(toJson(Stream.of(moduleIDs.get(moduleIDs.size() - 1)).map(MgmtId::new).toList()))) .andDo(MockMvcResultPrinter.print()) @@ -269,7 +269,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // verify quota is also enforced for bulk uploads final DistributionSet disSet2 = testdataFactory.createDistributionSetWithNoSoftwareModules("Saturn", "4.0"); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet2.getId() + "/assignedSM") .contentType(APPLICATION_JSON).content(toJson(moduleIDs.stream().map(MgmtId::new).toList()))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isTooManyRequests()) @@ -277,7 +277,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); // verify size is still 0 - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet2.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(0))); @@ -291,16 +291,16 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("Venus"); int amountOfSM = set.getModules().size(); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(amountOfSM))); // test the removal of all software modules one by one for (final SoftwareModule softwareModule : set.getModules()) { final Long smId = softwareModule.getId(); - mvc.perform(delete(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId)) + mvc.perform(delete(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM/" + smId)) .andExpect(status().isNoContent()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(--amountOfSM))); @@ -320,7 +320,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isOk()) .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) @@ -349,7 +349,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe list.put(new JSONObject().put("id", targetId).put("type", "forced")); } - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isOk()); // we just need to make sure that no error 500 is returned @@ -413,7 +413,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe } }); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + ds.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(payload.toString())) .andExpect(status().isTooManyRequests()); @@ -442,7 +442,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign our test target to another distribution set and verify that // the 'max actions per target' quota is exceeded final String json = new JSONArray().put(new JSONObject().put("id", testTarget.getControllerId())).toString(); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds3.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + ds3.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(json)) .andExpect(status().isTooManyRequests()); } @@ -466,7 +466,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), targets.get(0).getControllerId()); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets?offline=true").contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isOk()) .andExpect(jsonPath("$.assigned", equalTo(targets.size() - 1))) @@ -492,7 +492,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isBadRequest()); } @@ -510,7 +510,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isBadRequest()); } @@ -529,7 +529,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isOk()); } @@ -548,7 +548,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isBadRequest()); } @@ -576,7 +576,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // assign already one target to DS assignDistributionSet(createdDs.getId(), knownTargetIds[0]); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(list.toString())) .andExpect(status().isOk()); } @@ -594,7 +594,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe assignTargetJson.put(new JSONObject().put("id", "notexistingtarget").put("type", "forced")); - mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") + mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets") .contentType(APPLICATION_JSON).content(assignTargetJson.toString())) .andExpect(status().isOk()) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) @@ -613,7 +613,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe testdataFactory.createTarget(knownTargetId); assignDistributionSet(createdDs.getId(), knownTargetId); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); @@ -629,7 +629,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query")) .getAssignedEntity(); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedTargets") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedTargets") .param("offset", "1").param("limit", "2").param("sort", "name:DESC") .param("q", "controllerId==target*").accept(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -644,7 +644,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @Test void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { final DistributionSet createdDs = testdataFactory.createDistributionSet(); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(0))) .andExpect(jsonPath("$.total", equalTo(0))); @@ -668,7 +668,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe testdataFactory.sendUpdateActionStatusToTargets(Collections.singletonList(createTarget), Status.FINISHED, Collections.singletonList("some message")); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/installedTargets")) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); @@ -686,7 +686,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .map(Action::getTarget).toList(); testdataFactory.sendUpdateActionStatusToTargets(targets, Status.FINISHED, "some message"); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/installedTargets") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/installedTargets") .param("offset", "1").param("limit", "2").param("sort", "name:DESC") .param("q", "controllerId==target*").accept(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -710,7 +710,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe targetFilterQueryManagement.create(Create.builder().name("b").query("name==y").build()); targetFilterQueryManagement.create(Create.builder().name("c").query("name==y").build()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters")) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters")) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].name", equalTo(knownFilterName))); @@ -724,7 +724,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); targetFilterQueryManagement.create(Create.builder().name("filter1").query("name==a").autoAssignDistributionSet(set).build()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/autoAssignTargetFilters") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/autoAssignTargetFilters") .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==*1") .accept(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -741,7 +741,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final DistributionSet createdDs = testdataFactory.createDistributionSet(); final String invalidQuery = "unknownField=le=42"; - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters") .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, invalidQuery)) .andExpect(status().isBadRequest()); } @@ -757,7 +757,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe prepareTestFilters(filterNamePrefix, createdDs); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters") .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query)) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(2))) @@ -776,7 +776,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe prepareTestFilters(filterNamePrefix, createdDs); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters") + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters") .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query)) .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(0))); @@ -789,7 +789,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception { final int sets = 5; createDistributionSetsAlphabetical(sets); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING)) + mvc.perform(get(DISTRIBUTIONSETS_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) @@ -805,7 +805,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final int sets = 5; final int limitSize = 1; createDistributionSetsAlphabetical(sets); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(DISTRIBUTIONSETS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) @@ -822,7 +822,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final int offsetParam = 2; final int expectedSize = sets - offsetParam; createDistributionSetsAlphabetical(sets); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING) + mvc.perform(get(DISTRIBUTIONSETS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(sets))) .andDo(MockMvcResultPrinter.print()) @@ -1296,7 +1296,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe distributionSetManagement.createMetadata(testDS.getId(), Map.of(knownKeyPrefix + index, knownValuePrefix + index)); } - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", testDS.getId())) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata", testDS.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON)); @@ -1377,7 +1377,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe final String rsqlFindTargetId1 = "controllerId==1"; - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets?q=" + rsqlFindTargetId1) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets?q=" + rsqlFindTargetId1) .contentType(APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -1553,7 +1553,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe rolloutManagement.start(rollout.getId()); rolloutHandler.handleAll(); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/rollouts", ds1.getId()).contentType( + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/rollouts", ds1.getId()).contentType( APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1563,7 +1563,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("actions").doesNotExist()) .andExpect(jsonPath("totalAutoAssignments").doesNotExist()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/rollouts", ds2.getId()) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/rollouts", ds2.getId()) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1587,7 +1587,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe rolloutManagement.start(rollout.getId()); rolloutHandler.handleAll(); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/actions", ds1.getId()) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/actions", ds1.getId()) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1596,7 +1596,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("rollouts").doesNotExist()) .andExpect(jsonPath("totalAutoAssignments").doesNotExist()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/actions", ds2.getId()) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/actions", ds2.getId()) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1620,7 +1620,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe targetFilterQueryManagement.create( Create.builder().name("test filter 2").autoAssignDistributionSet(ds1).query("name==targets*").build()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/autoassignments", ds1.getId()).contentType( + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/autoassignments", ds1.getId()).contentType( APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1628,7 +1628,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("rollouts").doesNotExist()) .andExpect(jsonPath("actions").doesNotExist()); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/autoassignments", ds2.getId()).contentType( + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/autoassignments", ds2.getId()).contentType( APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1654,7 +1654,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe rolloutManagement.start(rollout.getId()); rolloutHandler.handleAll(); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics", ds1.getId()) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics", ds1.getId()) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1664,7 +1664,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("rollouts.RUNNING", equalTo(1))) .andExpect(jsonPath("rollouts.total", equalTo(1))); - mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/autoassignments", ds2.getId()) + mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/autoassignments", ds2.getId()) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java index c59cffb4d..264939407 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility; import org.eclipse.hawkbit.repository.DistributionSetTagManagement; @@ -52,7 +53,7 @@ import org.springframework.test.web.servlet.ResultActions; */ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegrationTest { - private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/"; + private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/"; /** * Verifies that a paged result list of DS tags reflects the content on the repository side. @@ -64,7 +65,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final DistributionSetTag assigned = tags.get(0); final DistributionSetTag unassigned = tags.get(1); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) @@ -83,7 +84,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio @Test void getDistributionSetTagsWithParameters() throws Exception { testdataFactory.createDistributionSetTags(2); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag")) + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -102,7 +103,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio distributionSetManagement.assignTag(List.of(distributionSet1.getId(), distributionSet2.getId()), tag1.getId()); distributionSetManagement.assignTag(List.of(distributionSet1.getId()), tag2.getId()); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1) .queryParam(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "distributionset.id==" + distributionSet1.getId()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -116,7 +117,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(2))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(2))); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1) .queryParam(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "distributionset.id==" + distributionSet2.getId()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -145,7 +146,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio // pass here q directly as a pure string because .queryParam method delimiters the parameters in q with , // which is logical OR, we want AND here - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "?" + MgmtRestConstants.REQUEST_PARAMETER_SEARCH + "=distributionset.id==" + distributionSet1.getId() + ";description==" + tag1.getDescription()) .accept(MediaType.APPLICATION_JSON)) @@ -168,7 +169,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final List tags = testdataFactory.createDistributionSetTags(2); final DistributionSetTag assigned = tags.get(0); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId()) + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + assigned.getId()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -193,7 +194,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio .build(); final ResultActions result = mvc - .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) + .perform(post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1) .content(toJson(List.of(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -228,7 +229,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio .build(); final ResultActions result = mvc - .perform(put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()) + .perform(put(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + original.getId()) .content(toJson(update)).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -255,7 +256,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final List tags = testdataFactory.createDistributionSetTags(1); final DistributionSetTag original = tags.get(0); - mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId())) + mvc.perform(delete(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + original.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -276,7 +277,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final List sets = testdataFactory.createDistributionSetsWithoutModules(setsAssigned); distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId()); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")) + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(setsAssigned))) @@ -299,7 +300,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final List sets = testdataFactory.createDistributionSetsWithoutModules(setsAssigned); distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId()); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -325,7 +326,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final List sets = testdataFactory.createDistributionSetsWithoutModules(setsAssigned); distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId()); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(setsAssigned))) .andDo(MockMvcResultPrinter.print()) @@ -347,7 +348,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final DistributionSetTag tag = testdataFactory.createDistributionSetTags(1).get(0); final DistributionSet set = testdataFactory.createDistributionSetsWithoutModules(1).get(0); - mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + + mvc.perform(post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned/" + set.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -368,7 +369,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio final DistributionSetTag tag = testdataFactory.createDistributionSetTags(1).get(0); final List sets = testdataFactory.createDistributionSetsWithoutModules(2); - mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(sets.stream().map(DistributionSet::getId).toList())) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -396,7 +397,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId()); - mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + + mvc.perform(delete(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned/" + unassigned.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -423,7 +424,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio distributionSetManagement.assignTag(sets.stream().map(DistributionSet::getId).toList(), tag.getId()); - mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(delete(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(List.of(unassigned0.getId(), unassigned1.getId()))) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -459,7 +460,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio withMissing.addAll(missing); mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index 6996ef6d4..ebef6b9ce 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -33,6 +33,7 @@ import com.jayway.jsonpath.JsonPath; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; @@ -420,7 +421,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati */ @Test void getDistributionSetTypesWithParameter() throws Exception { - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==a")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -528,7 +529,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati .put("colour", "rgb(106,178,83)").toString(); mvc - .perform(put(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", + .perform(put(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}", testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -560,7 +561,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati // 4 types overall (3 hawkbit tenant default, 1 test default final int types = 4; - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)) + mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) @@ -576,7 +577,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati final int types = DEFAULT_DS_TYPES; final int limitSize = 1; - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -593,7 +594,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati final int types = DEFAULT_DS_TYPES; final int offsetParam = 2; final int expectedSize = types - offsetParam; - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) .andDo(MockMvcResultPrinter.print()) 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 098fc2d1b..a6f125363 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 @@ -38,6 +38,7 @@ import org.awaitility.core.ConditionFactory; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi; import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement; @@ -125,7 +126,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED, "Approved remark."); - mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", rollout.getId()) + mvc.perform(get(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}", rollout.getId()) .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -146,7 +147,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final RolloutGroup firstRolloutGroup = rolloutGroupManagement .findByRollout(rollout.getId(), PageRequest.of(0, 1)).getContent().get(0); - mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets", + mvc.perform(get(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}/deploygroups/{deployGroupId}/targets", rollout.getId(), firstRolloutGroup.getId()).param("offset", "0").param("limit", "2") .param("sort", "name:ASC").param("q", "controllerId==exampleTarget0") .accept(MediaTypes.HAL_JSON_VALUE)) @@ -165,7 +166,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTargets(4, "rollout", "description"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); final Rollout rollout = createRollout("rollout1", 3, dsA, "controllerId==rollout*", false); - mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", rollout.getId()) + mvc.perform(post(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}/approve", rollout.getId()) .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -184,7 +185,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTargets(4, "rollout", "description"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); final Rollout rollout = createRollout("rollout1", 3, dsA, "controllerId==rollout*", false); - mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", rollout.getId()) + mvc.perform(post(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}/deny", rollout.getId()) .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index cf3f473e2..284ce18d2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -47,6 +47,7 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi; import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility; import org.eclipse.hawkbit.repository.Constants; import org.eclipse.hawkbit.repository.SoftwareModuleManagement; @@ -145,7 +146,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), null, 0, null, sm.getId(), "file1", false)); - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId()) + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts", sm.getId()) .param("representation", MgmtRepresentationMode.FULL.toString()) .param("useartifacturlhandler", Boolean.TRUE.toString())) .andDo(MockMvcResultPrinter.print()) @@ -167,7 +168,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes softwareModuleManagement.createMetadata(module.getId(), knownKeyPrefix + index, new MetadataValueCreate(knownValuePrefix + index)); } - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata", module.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -188,7 +189,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes softwareModuleManagement.createMetadata(module.getId(), knownKeyPrefix + index, new MetadataValueCreate(knownValuePrefix + index)); } - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata", module.getId()).param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", "key==known*")) .andDo(MockMvcResultPrinter.print()) @@ -208,7 +209,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final SoftwareModule module = findFirstModuleByType(testdataFactory.createDistributionSet("one"), osType).orElseThrow(); softwareModuleManagement.createMetadata(module.getId(), knownKey, new MetadataValueCreate(knownValue)); - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata/{metadataKey}", module.getId(), knownKey)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -1056,7 +1057,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes void getSoftwareModulesWithoutAdditionalRequestParameters() throws Exception { final int modules = 5; createSoftwareModulesAlphabetical(modules); - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)) + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) @@ -1072,7 +1073,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final int modules = 5; final int limitSize = 1; createSoftwareModulesAlphabetical(modules); - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING).param( + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1).param( MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1090,7 +1091,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final int offsetParam = 2; final int expectedSize = modules - offsetParam; createSoftwareModulesAlphabetical(modules); - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING).param( + mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1).param( MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules))) .andDo(MockMvcResultPrinter.print()) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index 00be12422..2ecd568e3 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -28,6 +28,7 @@ import java.util.List; import com.jayway.jsonpath.JsonPath; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; import org.eclipse.hawkbit.repository.SoftwareModuleManagement; import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement; import org.eclipse.hawkbit.repository.model.NamedEntity; @@ -104,7 +105,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt .update(SoftwareModuleTypeManagement.Update.builder().id(testType.getId()).description("Desc1234").colour("rgb(106,178,83)") .build()); - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a") + mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==a") .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -359,7 +360,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt @Test void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception { final int types = 3; - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)) + mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) @@ -374,7 +375,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt void getSoftwareModuleTypesWithPagingLimitRequestParameter() throws Exception { final int types = 3; final int limitSize = 1; - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -391,7 +392,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final int types = 3; final int offsetParam = 2; final int expectedSize = types - offsetParam; - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) .andDo(MockMvcResultPrinter.print()) 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 bf1eb2522..4fceef6a5 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 @@ -28,7 +28,9 @@ import java.util.stream.Stream; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetFilterQueryRestApi; import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper; import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility; import org.eclipse.hawkbit.repository.DistributionSetManagement; @@ -101,7 +103,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte void getTargetFilterQueries() throws Exception { final String filterName = "filter_01"; createSingleTargetFilterQuery(filterName, "name==test_01"); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1)) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); } @@ -111,7 +113,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte */ @Test void getTargetFilterQueriesWithParameters() throws Exception { - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==*1")) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==*1")) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); } @@ -127,7 +129,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte .put("name", name) .put("query", filterQuery).toString(); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1) .contentType(MediaType.APPLICATION_JSON).content(body)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()); @@ -141,7 +143,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String filterName = "filter_01"; final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); - mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId())) + mvc.perform(delete(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId())) .andExpect(status().isNoContent()); assertThat(targetFilterQueryManagement.find(filterQuery.getId())).isNotPresent(); @@ -154,7 +156,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte void deleteTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String notExistingId = "4395"; - mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId)) + mvc.perform(delete(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + notExistingId)) .andExpect(status().isNotFound()); } @@ -164,7 +166,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte @Test void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String notExistingId = "4395"; - mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId).content("{}") + mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + notExistingId).content("{}") .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isNotFound()); @@ -183,7 +185,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte // prepare final TargetFilterQuery tfq = createSingleTargetFilterQuery(filterName, filterQuery); - mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body) + mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId()).content(body) .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()) @@ -210,7 +212,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte // prepare final TargetFilterQuery tfq = targetFilterQueryManagement.create(Create.builder().name(filterName).query(filterQuery).build()); - mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body) + mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId()).content(body) .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()) @@ -239,7 +241,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte createSingleTargetFilterQuery(idB, testQuery); createSingleTargetFilterQuery(idC, testQuery); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1)) .andExpect(status().isOk()) .andDo(print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) @@ -272,7 +274,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte createSingleTargetFilterQuery(idB, testQuery); createSingleTargetFilterQuery(idC, testQuery); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andExpect(status().isOk()) .andDo(print()) @@ -290,25 +292,25 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final DistributionSet set = testdataFactory.createDistributionSet(); final TargetFilterQuery filterQuery = createSingleTargetFilterQuery("a", testQuery); - final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + final String hrefPrefix = "http://localhost" + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId(); - final String distributionsetHrefPrefix = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING; + final String distributionsetHrefPrefix = "http://localhost" + MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1; final String dsQuery = "?q=name==" + set.getName() + ";" + "version==" + set.getVersion() + "&offset=0&limit=50"; mvc.perform( - post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") + post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()); final String result = mvc.perform( - get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId())) + get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId())) .andExpect(jsonPath("$._links.autoAssignDS.href", equalTo(hrefPrefix + "/autoAssignDS"))) .andExpect(jsonPath("$._links.DS.href", startsWith(distributionsetHrefPrefix))) .andReturn().getResponse().getContentAsString(); final String multipleResult = mvc.perform( - get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?representation=full")) + get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "?representation=full")) .andExpect(jsonPath("$.content", hasSize(1))) .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("$.content[0]._links.DS.href", startsWith(distributionsetHrefPrefix))) @@ -345,7 +347,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte createSingleTargetFilterQuery(idD, testQuery); createSingleTargetFilterQuery(idE, testQuery); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount))) .andExpect(status().isOk()) @@ -373,10 +375,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String knownQuery = "name==test01"; final String knownName = "someName"; final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery); - final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + final String hrefPrefix = "http://localhost" + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId(); // test - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId())) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId())) .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName))) @@ -395,7 +397,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte // test final MvcResult mvcResult = mvc - .perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + targetIdNotExists)) + .perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + targetIdNotExists)) .andExpect(status().isNotFound()) .andReturn(); @@ -413,7 +415,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String notJson = "abc"; final MvcResult mvcResult = mvc - .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING).content(notJson) + .perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1).content(notJson) .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isBadRequest()) @@ -436,7 +438,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String invalidQuery = "name=abc"; final String body = new JSONObject().put("query", invalidQuery).put("name", "invalidFilter").toString(); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING).content(body) + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1).content(body) .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isBadRequest()) @@ -461,7 +463,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final TargetFilterQuery filterQuery = createSingleTargetFilterQuery("1", "controllerId==target*"); mvc.perform( - post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") + post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isTooManyRequests()) @@ -487,7 +489,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte // assign the auto-assign distribution set, this should work mvc.perform( - post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") + post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()); @@ -499,7 +501,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assertThat(updatedFilterQuery.getAutoAssignActionType()).isEqualTo(ActionType.FORCED); // update the query of the filter query to trigger a quota hit - mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()) + mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId()) .content("{\"query\":\"controllerId==target*\"}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isTooManyRequests()) @@ -547,7 +549,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final DistributionSet ds = testdataFactory.createDistributionSet("ds"); targetFilterQueryManagement.updateAutoAssignDS(new AutoAssignDistributionSetUpdate(filterQuery.getId()).ds(ds.getId())); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS", filterQuery.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -568,7 +570,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte .put("type", MgmtActionType.SOFT.getName()).put("weight", 200).toString(); mvc - .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + .perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS", filterQuery.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -583,7 +585,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); mvc .perform(delete( - MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS", filterQuery.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -608,11 +610,11 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assertThat(updatedFilterQuery.getAutoAssignDistributionSet()).isEqualTo(set); assertThat(updatedFilterQuery.getAutoAssignActionType()).isEqualTo(ActionType.FORCED); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")) .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(dsName))); - mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")) + mvc.perform(delete(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")) .andExpect(status().isNoContent()); final TargetFilterQuery filterQueryWithDeletedDs = targetFilterQueryManagement.find(tfq.getId()).get(); @@ -620,7 +622,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assertThat(filterQueryWithDeletedDs.getAutoAssignDistributionSet()).isNull(); assertThat(filterQueryWithDeletedDs.getAutoAssignActionType()).isNull(); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")) .andExpect(status().isNoContent()); } @@ -637,17 +639,17 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte .toString(); final String valideWeightRequest = new JSONObject().put("id", dsId).put("weight", 45).toString(); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS", filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()); enableMultiAssignments(); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS", filterId).content(invalideWeightRequest).contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS", filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()); @@ -702,7 +704,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte private void verifyAutoAssignmentByActionType(final TargetFilterQuery tfq, final DistributionSet set, final MgmtActionType actionType, final Boolean confirmationRequired) throws Exception { - final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + final String hrefPrefix = "http://localhost" + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId(); final JSONObject jsonObject = new JSONObject(); @@ -714,7 +716,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte jsonObject.put("confirmationRequired", confirmationRequired); } - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS") .content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()); @@ -727,7 +729,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assertThat(updatedFilterQuery.getAutoAssignActionType()) .isEqualTo(MgmtRestModelMapper.convertActionType(expectedActionType)); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId())) + mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId())) .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(tfq.getName()))) @@ -744,7 +746,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte private void verifyAutoAssignmentWithTimeForcedActionType(final TargetFilterQuery tfq, final DistributionSet set) throws Exception { - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + ", \"type\":\"" + MgmtActionType.TIMEFORCED.getName() + "\"}") .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) @@ -762,7 +764,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte private void verifyAutoAssignmentWithUnknownActionType(final TargetFilterQuery tfq, final DistributionSet set) throws Exception { - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + ", \"type\":\"unknown\"}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isBadRequest()) @@ -777,7 +779,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte .name("incomplete").version("1") .build()); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + incompleteDistributionSet.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isBadRequest()) @@ -791,7 +793,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assignDistributionSet(softDeletedDs, testdataFactory.createTarget("forSoftDeletedDs")); distributionSetManagement.delete(softDeletedDs.getId()); - mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") + mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + softDeletedDs.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isNotFound()) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetGroupResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetGroupResourceTest.java index a29ffdd0b..f53ef26e6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetGroupResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetGroupResourceTest.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.List; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetGroupRestApi; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; @@ -35,7 +36,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").group("Asia").build()); targetManagement.create(builder().controllerId("target3").group("Europe").build()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING) + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.[0]", Matchers.in(expectedGroups))) @@ -48,14 +49,14 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").group("Europe/East").build()); targetManagement.create(builder().controllerId("target3").group("Europe").build()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param("group", "Europe/East") .param("subgroups", "false")) .andExpect(status().isOk()) .andExpect(jsonPath("content", Matchers.hasSize(1))) .andExpect(jsonPath("content.[0].controllerId", Matchers.equalTo("target2"))); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param("group", "Europe") .param("subgroups", "true") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) @@ -72,7 +73,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").group("US").build()); targetManagement.create(builder().controllerId("target3").group("Europe").build()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/Europe/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/Europe/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andExpect(status().isOk()) .andExpect(jsonPath("content", Matchers.hasSize(2))) @@ -86,12 +87,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").build()); targetManagement.create(builder().controllerId("target3").group("Europe").build()); - mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/newGroup/assigned") + mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/newGroup/assigned") .contentType(MediaType.APPLICATION_JSON) .content(toJson(Arrays.asList("target1", "target2", "target3")))) .andExpect(status().isNoContent()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/newGroup/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/newGroup/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) @@ -103,7 +104,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio @Test void shouldReturnBadRequestWhenProvidingAnEmptyListOfControllerIds() throws Exception { - mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/someGroup/assigned") + mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/someGroup/assigned") .contentType(MediaType.APPLICATION_JSON) .content(toJson(Collections.emptyList()))) .andExpect(status().isBadRequest()); @@ -115,13 +116,13 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").build()); targetManagement.create(builder().controllerId("target3").group("US").build()); - mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .contentType(MediaType.APPLICATION_JSON) .content(toJson(Arrays.asList("target1", "target2", "target3"))) .param("group", "Europe/East")) .andExpect(status().isNoContent()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .param("group", "Europe/East") .contentType(MediaType.APPLICATION_JSON)) @@ -132,7 +133,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio .andExpect(jsonPath("content.[2].controllerId", Matchers.equalTo("target3"))); // expect bad request if empty controllerIds - mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .contentType(MediaType.APPLICATION_JSON) .content(toJson(Collections.emptyList())) .param("group", "doesNotMatter")) @@ -145,12 +146,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").build()); targetManagement.create(builder().controllerId("shouldNotAssign").group("B").build()); - mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/C") + mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/C") .contentType(MediaType.APPLICATION_JSON) .param("q", "controllerId==target*")) .andExpect(status().isNoContent()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .param("group", "C") .contentType(MediaType.APPLICATION_JSON)) @@ -165,12 +166,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target1").group("Europe").build()); targetManagement.create(builder().controllerId("target2").group("Europe").build()); - mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(delete(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .contentType(MediaType.APPLICATION_JSON) .content(toJson(Arrays.asList("target1", "target2")))) .andExpect(status().isNoContent()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .param("group", "Europe") .contentType(MediaType.APPLICATION_JSON)) @@ -178,7 +179,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio .andExpect(jsonPath("content", Matchers.hasSize(0))); // expect bad request if empty - mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(delete(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .contentType(MediaType.APPLICATION_JSON) .content(toJson(Collections.emptyList()))) .andExpect(status().isBadRequest()); @@ -190,12 +191,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("target2").group("Europe").build()); targetManagement.create(builder().controllerId("nonMatchingTarget").group("Europe").build()); - mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING) + mvc.perform(delete(MgmtTargetGroupRestApi.TARGETGROUPS_V1) .contentType(MediaType.APPLICATION_JSON) .param("q", "controllerId==target*")) .andExpect(status().isNoContent()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .param("group", "Europe") .contentType(MediaType.APPLICATION_JSON)) @@ -212,13 +213,13 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio targetManagement.create(builder().controllerId("shouldNotBeUpdated1").group("Europe").build()); targetManagement.create(builder().controllerId("shouldNotBeUpdated2").group("Europe").build()); - mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING) + mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1) .contentType(MediaType.APPLICATION_JSON) .param("group", "Europe/East") .param("q", "controllerId==target*")) .andExpect(status().isNoContent()); - mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned") + mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned") .param("group", "Europe/East") .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .contentType(MediaType.APPLICATION_JSON)) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index e4acac0cd..28528706f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -10,10 +10,10 @@ package org.eclipse.hawkbit.mgmt.rest.resource; import static org.assertj.core.api.Assertions.assertThat; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_ACTIVATE_AUTO_CONFIRM; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_AUTO_CONFIRM; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_DEACTIVATE_AUTO_CONFIRM; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.TARGET_V1_REQUEST_MAPPING; +import static org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget.AUTO_CONFIRM; +import static org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirm.ACTIVATE; +import static org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirm.DEACTIVATE; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi.TARGETS_V1; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; @@ -51,8 +51,11 @@ import org.eclipse.hawkbit.auth.SpPermission; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionConfirmationRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; +import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAutoConfirmUpdate; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility; import org.eclipse.hawkbit.repository.Identifiable; import org.eclipse.hawkbit.repository.TargetManagement.Create; @@ -164,7 +167,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { targetManagement.create(Create.builder().controllerId(knownControllerId).name(knownNameNotModify) .address(knownNewAddress).targetType(targetType).build()); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).contentType(APPLICATION_JSON)) + mvc.perform(get(TARGETS_V1 + "/" + knownControllerId).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) @@ -172,7 +175,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))) .andExpect(jsonPath("$.targetType").exists()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) @@ -204,7 +207,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { targetManagement.create(Create.builder().controllerId(knownControllerId).name(knownNameNotModify) .address(knownNewAddress).targetType(targetType).build()); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).contentType(APPLICATION_JSON)) + mvc.perform(get(TARGETS_V1 + "/" + knownControllerId).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) @@ -213,7 +216,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.targetType").exists()); //check if controller name is updated AND target type is missing (not assigned) - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) @@ -228,7 +231,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Test void getTargets() throws Exception { enableConfirmationFlow(); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + mvc.perform(get(TARGETS_V1)).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); } /** @@ -236,7 +239,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { */ @Test void getTargetsWithParameters() throws Exception { - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")) + mvc.perform(get(TARGETS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==a")) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); } @@ -249,7 +252,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target testTarget = testdataFactory.createTarget("targetId"); final MgmtTargetAutoConfirmUpdate body = new MgmtTargetAutoConfirmUpdate("custom_initiator_value", "custom_remark_value"); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" + TARGET_V1_ACTIVATE_AUTO_CONFIRM, + mvc.perform(post(TARGETS_V1 + "/{targetId}/" + AUTO_CONFIRM + "/" + ACTIVATE, testTarget.getControllerId()) .content(objectMapper.writeValueAsString(body)).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -264,7 +267,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target testTarget = testdataFactory.createTarget("targetId"); confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), null, null); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" + TARGET_V1_DEACTIVATE_AUTO_CONFIRM, + mvc.perform(post(TARGETS_V1 + "/{targetId}/" + AUTO_CONFIRM + "/" + DEACTIVATE, testTarget.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -337,7 +340,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { void testActionConfirmation(final String controllerId, final long actionId, final MgmtActionConfirmationRequestBodyPut.Confirmation payloadConfirmation, final int payloadCode, final String[] payloadMessages, final HttpStatus expectedHttpResponseStatus, final Status expectedGeneratedStatus) throws Exception { - String url = TARGET_V1_REQUEST_MAPPING + "/" + controllerId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/confirmation"; + String url = TARGETS_V1 + "/" + controllerId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId + "/confirmation"; mvc.perform(put(url).content(String.format("{\"confirmation\":\"%s\",\"details\":[\"%s\",\"%s\"],\"code\":%d}", payloadConfirmation.getName(), payloadMessages[0], @@ -390,7 +393,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final ActionStatus status = deploymentManagement.findActionStatusByAction(action.getId(), PAGE).getContent() .stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())).toList().get(0); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actions.get(0).getId() + "/status") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:DESC")) @@ -415,7 +418,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownControllerId = "knownControllerId"; testdataFactory.createTarget(knownControllerId); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}", knownControllerId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("securityToken").doesNotExist()); @@ -431,7 +434,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownControllerId = "knownControllerId"; final Target createTarget = testdataFactory.createTarget(knownControllerId); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}", knownControllerId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken()))); @@ -450,7 +453,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { createTarget(knownControllerId2); // test - mvc.perform(get(TARGET_V1_REQUEST_MAPPING)) + mvc.perform(get(TARGETS_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(2))) @@ -478,7 +481,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlFinishedStatus = "active==false"; final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus; // pending status one result - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingStatus, createTarget.getControllerId())) + mvc.perform(get(TARGETS_V1 + "/{targetId}/actions?q=" + rsqlPendingStatus, createTarget.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))) @@ -486,7 +489,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("content[0].active", equalTo(true))); // finished status none result - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlFinishedStatus, + mvc.perform(get(TARGETS_V1 + "/{targetId}/actions?q=" + rsqlFinishedStatus, createTarget.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -495,7 +498,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // pending or finished status one result mvc.perform(get( - TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingOrFinishedStatus, + TARGETS_V1 + "/{targetId}/actions?q=" + rsqlPendingOrFinishedStatus, createTarget.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -513,7 +516,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target tA = createTargetAndStartAction(); // test - cancel the active action - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions/{actionId}", tA.getControllerId(), deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE) .getContent().get(0).getId())) .andDo(MockMvcResultPrinter.print()) @@ -546,7 +549,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(cancelActions).hasSize(1); // test - cancel an cancel action returns forbidden - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions/{actionId}", tA.getControllerId(), cancelActions.get(0).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); @@ -569,7 +572,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(cancelActions.get(0).isCancelingOrCanceled()).isTrue(); // test - force quit: Canceled actions should return 204 - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions/{actionId}?force=true", tA.getControllerId(), cancelActions.get(0).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -583,7 +586,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target tA = createTargetAndStartAction(); // test - cancel an cancel action returns forbidden - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions/{actionId}?force=true", tA.getControllerId(), deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE) .getContent().get(0).getId())) .andDo(MockMvcResultPrinter.print()) @@ -598,7 +601,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownControllerId = "knownControllerIdDelete"; testdataFactory.createTarget(knownControllerId); - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)).andExpect(status().isNoContent()); + mvc.perform(delete(TARGETS_V1 + "/" + knownControllerId)).andExpect(status().isNoContent()); assertThat(targetManagement.findByControllerId(knownControllerId)).isNotPresent(); } @@ -609,7 +612,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Test void deleteTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { final String knownControllerId = "knownControllerIdDelete"; - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)).andExpect(status().isNotFound()); + mvc.perform(delete(TARGETS_V1 + "/" + knownControllerId)).andExpect(status().isNotFound()); } /** @@ -618,7 +621,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Test void updateTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { final String knownControllerId = "knownControllerIdUpdate"; - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content("{}").contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content("{}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -637,7 +640,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { targetManagement.create( Create.builder().controllerId(knownControllerId).name(knownNameNotModify).description("old description").build()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) @@ -664,7 +667,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { targetManagement.create( Create.builder().controllerId(knownControllerId).name(knownNameNotModify).description("old description").build()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); @@ -684,7 +687,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // prepare targetManagement.create(Create.builder().controllerId(knownControllerId).name(knownNameNotModify).build()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content(body) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -711,7 +714,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // prepare targetManagement.create(Create.builder().controllerId(knownControllerId).name(knownNameNotModify).address(knownNewAddress).build()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownControllerId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) @@ -735,7 +738,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String idC = "c"; final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; createTargetsAlphabetical(knownTargetAmount); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING)) + mvc.perform(get(TARGETS_V1)) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) @@ -780,7 +783,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String idA = "a"; final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; - mvc.perform(get(TARGET_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(TARGETS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) @@ -809,7 +812,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; createTargetsAlphabetical(knownTargetAmount); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING) + mvc.perform(get(TARGETS_V1) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount))) .andExpect(status().isOk()) @@ -851,7 +854,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target target = createSingleTarget(knownControllerId, knownName); final String hrefPrefix = "http://localhost/rest/v1/targets/" + knownControllerId + "/"; // test - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) + mvc.perform(get(TARGETS_V1 + "/" + knownControllerId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName))) @@ -874,7 +877,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String targetIdNotExists = "bubu"; // test - final MvcResult mvcResult = mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + targetIdNotExists)) + final MvcResult mvcResult = mvc.perform(get(TARGETS_V1 + "/" + targetIdNotExists)) .andExpect(status().isNotFound()) .andReturn(); @@ -894,7 +897,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { createSingleTarget(knownControllerId, knownName); // test - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) + mvc.perform(get(TARGETS_V1 + "/" + knownControllerId + "/assignedDS")) .andExpect(status().isNoContent()) .andExpect(content().string("")); @@ -916,7 +919,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final SoftwareModule os = findFirstModuleByType(ds, osType).orElseThrow(); final SoftwareModule jvm = findFirstModuleByType(ds, runtimeType).orElseThrow(); final SoftwareModule bApp = findFirstModuleByType(ds, appType).orElseThrow(); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) + mvc.perform(get(TARGETS_V1 + "/" + knownControllerId + "/assignedDS")) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(ds.getId().intValue()))) @@ -955,7 +958,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownName = "someName"; createSingleTarget(knownControllerId, knownName); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS")) + mvc.perform(get(TARGETS_V1 + "/" + knownControllerId + "/installedDS")) .andExpect(status().isNoContent()) .andExpect(content().string("")); } @@ -970,7 +973,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String targetList = JsonBuilder.targets(List.of(target), false); final String expectedTargetName = randomString.substring(0, Math.min(JpaTarget.CONTROLLER_ID_MAX_SIZE, NamedEntity.NAME_MAX_SIZE)); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING).content(targetList).contentType(APPLICATION_JSON)) + mvc.perform(post(TARGETS_V1).content(targetList).contentType(APPLICATION_JSON)) .andExpect(status().isCreated()) .andExpect(jsonPath("[0].controllerId", equalTo(randomString))) .andExpect(jsonPath("[0].name", equalTo(expectedTargetName))); @@ -984,7 +987,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Test void createTargetWithoutPayloadBadRequest() throws Exception { final MvcResult mvcResult = mvc - .perform(post(TARGET_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)) + .perform(post(TARGETS_V1).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andReturn(); @@ -1005,7 +1008,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String notJson = "abc"; final MvcResult mvcResult = mvc - .perform(post(TARGET_V1_REQUEST_MAPPING).content(notJson).contentType(APPLICATION_JSON)) + .perform(post(TARGETS_V1).content(notJson).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andReturn(); @@ -1024,7 +1027,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Test void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception { final MvcResult mvcResult = mvc - .perform(post(TARGET_V1_REQUEST_MAPPING).content("[{\"name\":\"id1\"}]").contentType(APPLICATION_JSON)) + .perform(post(TARGETS_V1).content("[{\"name\":\"id1\"}]").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andReturn(); @@ -1045,7 +1048,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Create test1 = Create.builder().controllerId("id1").name(randomString(NamedEntity.NAME_MAX_SIZE + 1)).build(); final MvcResult mvcResult = mvc - .perform(post(TARGET_V1_REQUEST_MAPPING).content(JsonBuilder.targets(List.of(test1), true)).contentType(APPLICATION_JSON)) + .perform(post(TARGETS_V1).content(JsonBuilder.targets(List.of(test1), true)).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andReturn(); @@ -1124,7 +1127,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownDescription = "someDescription"; final String createTargetsJson = getCreateTargetsListJsonString(knownControllerId, knownName, knownDescription); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING).content(createTargetsJson).contentType(APPLICATION_JSON)) + mvc.perform(post(TARGETS_V1).content(createTargetsJson).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); @@ -1148,11 +1151,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // create a taret first to provoke a already exists error - mvc.perform(post(TARGET_V1_REQUEST_MAPPING).content(createTargetsJson).contentType(APPLICATION_JSON)) + mvc.perform(post(TARGETS_V1).content(createTargetsJson).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); // create another one to retrieve the entity already exists exception - final MvcResult mvcResult = mvc.perform(post(TARGET_V1_REQUEST_MAPPING).content(createTargetsJson).contentType(APPLICATION_JSON)) + final MvcResult mvcResult = mvc.perform(post(TARGETS_V1).content(createTargetsJson).contentType(APPLICATION_JSON)) .andExpect(status().is(HttpStatus.CONFLICT.value())) .andReturn(); @@ -1174,7 +1177,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; testdataFactory.createTarget(knownTargetId); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS)) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("size", equalTo(0))) @@ -1190,8 +1193,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) + mvc.perform(get(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) @@ -1216,8 +1219,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final List actions = generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow( knownTargetId, schedule, duration, timezone); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) + mvc.perform(get(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) @@ -1242,8 +1245,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) + mvc.perform(get(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) @@ -1268,8 +1271,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final List actions = generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow( knownTargetId, schedule, duration, timezone); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) + mvc.perform(get(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) @@ -1314,7 +1317,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final List actions = generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow(knownTargetId, schedule, duration, timezone); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1354,9 +1357,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .toList(); // sort is default descending order, latest status first - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS)) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtTarget.TARGET_V1_ACTION_STATUS)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(0).getId().intValue()))) @@ -1383,9 +1386,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .toList(); // descending order - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtTarget.TARGET_V1_ACTION_STATUS) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "CREATEDAT:DESC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1401,9 +1404,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(2))); // ascending order - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtTarget.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "CREATEDAT:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1433,9 +1436,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .toList(); // Page 1 - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtTarget.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1448,9 +1451,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); // Page 2 - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + + MgmtTarget.TARGET_V1_ACTION_STATUS) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))) .andDo(MockMvcResultPrinter.print()) @@ -1472,8 +1475,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); // page 1: one entry - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) @@ -1487,8 +1490,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); // page 2: one entry - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) @@ -1515,8 +1518,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.SOFT); final String body = new JSONObject().put("forceType", "forced").toString(); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId).content(body) + mvc.perform(put(TARGETS_V1 + "/" + target.getControllerId() + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId).content(body) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1540,7 +1543,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { Target target = testdataFactory.createTarget(); final DistributionSet set = testdataFactory.createDistributionSet("one"); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1553,7 +1556,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { target = targetManagement.getByControllerId(target.getControllerId()); // repeating DS assignment leads again to OK - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1585,7 +1588,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { jsonPayload.put("confirmationRequired", confirmationRequired); } - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content(jsonPayload.toString()).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -1616,7 +1619,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target target = testdataFactory.createTarget(); final DistributionSet set = testdataFactory.createDistributionSet("one"); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content("{\"id\":" + set.getId() + ",\"type\": \"downloadonly\"}") .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -1641,7 +1644,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { Target target = testdataFactory.createTarget(); final DistributionSet set = testdataFactory.createDistributionSet("one"); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS?offline=true") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS?offline=true") .content("{\"id\":" + set.getId() + "}") .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -1657,7 +1660,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(target.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC); // repeating DS assignment leads again to OK - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS?offline=true") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS?offline=true") .content("{\"id\":" + set.getId() + "}") .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -1681,7 +1684,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("type", "timeforced").put("forcetime", forceTime) .toString(); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS").content(body).contentType(APPLICATION_JSON)) + mvc.perform(post(TARGETS_V1 + "/fsdfsd/assignedDS").content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); implicitLock(set); @@ -1708,7 +1711,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("maintenanceWindow", new JSONObject().put("schedule", getTestSchedule(0))) .toString(); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); @@ -1727,7 +1730,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("maintenanceWindow", new JSONObject().put("duration", getTestDuration(10))) .toString(); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content(body).contentType(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); @@ -1751,7 +1754,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("timezone", getTestTimeZone())) .toString(); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -1774,13 +1777,13 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("nextStartAt", String.valueOf(nextExecutionStart))) .toString(); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS)) + mvc.perform(get(TARGETS_V1 + "/" + target.getControllerId() + "/" + + MgmtTarget.TARGET_V1_ACTIONS)) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath("content.[0].maintenanceWindow.nextStartAt", not(nextExecutionStart))); @@ -1803,7 +1806,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("timezone", getTestTimeZone())) .toString(); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") + mvc.perform(post(TARGETS_V1 + "/" + target.getControllerId() + "/assignedDS") .content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); @@ -1813,29 +1816,29 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { void invalidRequestsOnAssignDistributionSetToTarget() throws Exception { final DistributionSet set = testdataFactory.createDistributionSet("one"); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(post(TARGETS_V1 + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); testdataFactory.createTarget("fsdfsd"); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(post(TARGETS_V1 + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(post(TARGETS_V1 + "/fsdfsd/assignedDS") .content("{\"id\":12345678}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(delete(TARGETS_V1 + "/fsdfsd/assignedDS") .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") + mvc.perform(put(TARGETS_V1 + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); @@ -1846,26 +1849,26 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; // target does not exist - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS)) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); // should work now - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // action does not exist - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/12321")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)) + mvc.perform(post(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); // Invalid content - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)) + mvc.perform(put(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); } @@ -1875,34 +1878,34 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; // target does not exist - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/1/status")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/1/status")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); // should work now - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + mvc.perform(get(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId + "/status")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // action does not exist - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321/status")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/12321/status")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + mvc.perform(delete(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId + "/status")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + mvc.perform(put(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId + "/status")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + - "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + mvc.perform(post(TARGETS_V1 + + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId + "/status")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -1918,7 +1921,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { controllerManagement.updateControllerAttributes(knownTargetId, knownControllerAttrs, null); // test query target over rest resource - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/attributes")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()) .andExpect(jsonPath("$.a", equalTo("1"))) @@ -1932,7 +1935,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTarget(knownTargetId); // test query target over rest resource - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/attributes")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().is(HttpStatus.NO_CONTENT.value())); } @@ -1963,7 +1966,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlFindAOrB = "controllerId==a,controllerId==b"; - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "?q=" + rsqlFindAOrB)) + mvc.perform(get(TARGETS_V1 + "?q=" + rsqlFindAOrB)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("size", equalTo(2))) @@ -1979,7 +1982,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Target target = testdataFactory.createTarget(knownTargetId); // test query target over rest resource with no tags - expect OK with empty list - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/tags")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/tags")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$", Matchers.hasSize(0))); @@ -1992,7 +1995,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { } // test query target over rest resource with 2 tags - expect OK with 2 tags the target is tagged with - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/tags")) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/tags")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$", Matchers.hasSize(2))) @@ -2394,7 +2397,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("[2].targetType", equalTo(type2.getId().intValue()))) .andReturn(); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + test2.getControllerId())) + mvc.perform(get(TARGETS_V1 + "/" + test2.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo("targetOfType1"))) @@ -2430,7 +2433,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String targetList = JsonBuilder.targets(List.of(target), false); // test query target over rest resource - mvc.perform(post(TARGET_V1_REQUEST_MAPPING).content(targetList).contentType(APPLICATION_JSON)) + mvc.perform(post(TARGETS_V1).content(targetList).contentType(APPLICATION_JSON)) .andExpect(status().isCreated()) .andExpect(jsonPath("[0].controllerId", equalTo("targetcontroller"))) .andExpect(jsonPath("[0].targetType", equalTo(targetTypes.get(0).getId().intValue()))); @@ -2456,7 +2459,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // update target over rest resource final String body = new JSONObject().put("targetType", targetTypes.get(1).getId().intValue()).toString(); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + controllerId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + controllerId).content(body).contentType(APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("controllerId", equalTo(controllerId))) .andExpect(jsonPath("targetType", equalTo(targetTypes.get(1).getId().intValue()))); @@ -2479,7 +2482,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String targetList = JsonBuilder.targets(List.of(target), false, unknownTargetTypeId); // post target over rest resource - mvc.perform(post(TARGET_V1_REQUEST_MAPPING).content(targetList).contentType(APPLICATION_JSON)) + mvc.perform(post(TARGETS_V1).content(targetList).contentType(APPLICATION_JSON)) .andExpect(status().isNotFound()) .andExpect(jsonPath("message", Matchers.containsString(errorMsg))); } @@ -2499,7 +2502,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(target).isNotNull(); // assign target type over rest resource - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") + mvc.perform(post(TARGETS_V1 + "/" + targetControllerId + "/targettype") .content("{\"id\":" + targetType.getId() + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -2521,7 +2524,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(target).isNotNull(); // assign invalid target type over rest resource - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") + mvc.perform(post(TARGETS_V1 + "/" + targetControllerId + "/targettype") .content("{\"id\":" + invalidTargetTypeId + "}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); @@ -2529,7 +2532,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // verify response json exception message if body does not include id // field final MvcResult mvcResult = mvc - .perform(post(TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") + .perform(post(TARGETS_V1 + "/" + targetControllerId + "/targettype") .content("{\"unknownfield\":" + invalidTargetTypeId + "}") .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -2558,7 +2561,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { assertThat(target.getTargetType().getId()).isEqualTo(targetTypes.get(0).getId()); // unassign target type over rest resource - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype").contentType(APPLICATION_JSON)) + mvc.perform(delete(TARGETS_V1 + "/" + targetControllerId + "/targettype").contentType(APPLICATION_JSON)) .andExpect(status().isNoContent()); assertThat(targetManagement.getByControllerId(targetControllerId).getTargetType()).isNull(); @@ -2571,32 +2574,32 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTargetType("targettype", Set.of()); // GET is not allowed - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE, knownTargetId)) + mvc.perform(get(TARGETS_V1 + MgmtTargetRestApi.TARGET_ID_TARGETTYPE, knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); // PUT is not allowed - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE, knownTargetId)) + mvc.perform(put(TARGETS_V1 + MgmtTargetRestApi.TARGET_ID_TARGETTYPE, knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); // POST does not exist with path parameter targettype - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE + "/123", knownTargetId)) + mvc.perform(post(TARGETS_V1 + MgmtTargetRestApi.TARGET_ID_TARGETTYPE + "/123", knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // DELETE does not exist with path parameter targettype - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE + "/123", knownTargetId)) + mvc.perform(delete(TARGETS_V1 + MgmtTargetRestApi.TARGET_ID_TARGETTYPE + "/123", knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // Invalid content - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE, knownTargetId)) + mvc.perform(post(TARGETS_V1 + MgmtTargetRestApi.TARGET_ID_TARGETTYPE, knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); // Bad request if id field is missing - mvc.perform(post(TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_ID_TARGETTYPE, knownTargetId) + mvc.perform(post(TARGETS_V1 + MgmtTargetRestApi.TARGET_ID_TARGETTYPE, knownTargetId) .content("{\"unknownfield\":123}").contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); @@ -2610,7 +2613,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { confirmationManagement.activateAutoConfirmation(knownTargetId, initiator, remark); // GET with all possible responses - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, knownTargetId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}/" + AUTO_CONFIRM, knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("active", equalTo(true))) @@ -2626,7 +2629,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTarget(knownTargetId); // GET if active - mvc.perform(get(TARGET_V1_REQUEST_MAPPING)) + mvc.perform(get(TARGETS_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].autoConfirmActive").doesNotExist()); @@ -2634,7 +2637,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { enableConfirmationFlow(); // GET if not active - mvc.perform(get(TARGET_V1_REQUEST_MAPPING)) + mvc.perform(get(TARGETS_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].autoConfirmActive", equalTo(false))); @@ -2642,7 +2645,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { confirmationManagement.activateAutoConfirmation(knownTargetId, "test", "remark"); // GET if active - mvc.perform(get(TARGET_V1_REQUEST_MAPPING)) + mvc.perform(get(TARGETS_V1)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].autoConfirmActive", equalTo(true))); @@ -2653,14 +2656,14 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; // GET for not existing target - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, knownTargetId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}/" + AUTO_CONFIRM, knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); testdataFactory.createTarget(knownTargetId); // GET for auto-confirm not active - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, knownTargetId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}/" + AUTO_CONFIRM, knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("active", equalTo(false))) @@ -2675,7 +2678,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTarget(knownTargetId); // GET with confirmation flow not active should not expose - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownTargetId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}", knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("autoConfirmActive").doesNotExist()) @@ -2684,7 +2687,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { enableConfirmationFlow(); // GET with confirmation flow active should expose - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownTargetId)) + mvc.perform(get(TARGETS_V1 + "/{targetId}", knownTargetId)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("autoConfirmActive").exists()) @@ -2702,14 +2705,14 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final Action action = getFirstAssignedAction(assignDistributionSet(dsA, Collections.singletonList(target))); // no status update yet -> no status code - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) + mvc.perform(get(TARGETS_V1 + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("lastStatusCode").doesNotExist()); // update action status with status code updateActionStatus(action, Status.RUNNING, 100); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) + mvc.perform(get(TARGETS_V1 + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("lastStatusCode", equalTo(100))) @@ -2717,7 +2720,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // update action status without a status code updateActionStatus(action, Status.RUNNING, null); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) + mvc.perform(get(TARGETS_V1 + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("lastStatusCode").doesNotExist()) @@ -2725,7 +2728,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // update action status with status code updateActionStatus(action, Status.ERROR, 432); - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) + mvc.perform(get(TARGETS_V1 + "/{targetId}/actions/{actionId}", target.getControllerId(), action.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("lastStatusCode", equalTo(432))) @@ -2745,7 +2748,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { Assertions.assertEquals(10, actionsPerTarget); List oldActions = deploymentManagement.findActionsByTarget(testTarget.getControllerId(), PAGE).getContent(); - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", testTarget.getControllerId()).param("keepLast", "5")) + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions", testTarget.getControllerId()).param("keepLast", "5")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -2762,12 +2765,12 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { void testThatDeletionOfLastNTargetActionsReturnsBadRequestWhenNeeded() throws Exception { final Target testTarget = testdataFactory.createTarget(); // either numberOfActions or actionIds list should be present - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", testTarget.getControllerId())) + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions", testTarget.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // both parameters present should also lead to bad request - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", testTarget.getControllerId()) + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions", testTarget.getControllerId()) .param("keepLast", "5") .content(toJson(List.of(1, 2, 3))) .contentType(APPLICATION_JSON)) @@ -2789,7 +2792,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .filter(action -> action.getId() % 2 == 0) .map(Identifiable::getId).toList(); - mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", testTarget.getControllerId()) + mvc.perform(delete(TARGETS_V1 + "/{targetId}/actions", testTarget.getControllerId()) .content(toJson(evenActionIds)) .contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -2836,7 +2839,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { } final ResultActions resultActions = - mvc.perform(get(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS) + mvc.perform(get(TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -2862,20 +2865,20 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { } private String generateActionSelfLink(final String knownTargetId, final Long actionId) { - return "http://localhost" + TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId; + return "http://localhost" + TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId; } private String generateActionDsLink(final Long dsId) { - return "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + dsId; + return "http://localhost" + MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1 + "/" + dsId; } private String generateCanceledactionreferenceLink(final String knownTargetId, final Action action) { - return "http://localhost" + TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); + return "http://localhost" + TARGETS_V1 + "/" + knownTargetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + action.getId(); } private String generateStatusreferenceLink(final String knownTargetId, final Long actionId) { - return "http://localhost" + TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/" + MgmtRestConstants.TARGET_V1_ACTION_STATUS + return "http://localhost" + TARGETS_V1 + "/" + knownTargetId + "/" + + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId + "/" + MgmtTarget.TARGET_V1_ACTION_STATUS + "?offset=0&limit=50&sort=id%3ADESC"; } @@ -2919,7 +2922,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { private void verifyAttributeUpdateCanBeRequested(final String knownTargetId) throws Exception { final String body = new JSONObject().put("requestAttributes", true).toString(); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownTargetId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); @@ -2929,7 +2932,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { private void verifyRequestAttributesAttributeIsOptional(final String knownTargetId) throws Exception { final String body = new JSONObject().put("description", "verify attribute can be missing").toString(); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownTargetId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -2937,7 +2940,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { private void verifyResettingRequestAttributesIsNotAllowed(final String knownTargetId) throws Exception { final String body = new JSONObject().put("requestAttributes", false).toString(); - mvc.perform(put(TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId).content(body).contentType(APPLICATION_JSON)) + mvc.perform(put(TARGETS_V1 + "/" + knownTargetId).content(body).contentType(APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java index 9417f7707..474f467c0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java @@ -55,7 +55,7 @@ import org.springframework.test.web.servlet.ResultActions; */ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationTest { - private static final String TARGETTAGS_ROOT = "http://localhost" + MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/"; + private static final String TARGETTAGS_ROOT = "http://localhost" + MgmtTargetTagRestApi.TARGETTAGS_V1 + "/"; /** * Verifies that a paged result list of target tags reflects the content on the repository side. @@ -67,7 +67,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final TargetTag assigned = tags.get(0); final TargetTag unassigned = tags.get(1); - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) @@ -87,7 +87,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT @Test void getTargetTagsWithParameters() throws Exception { testdataFactory.createTargetTags(2, ""); - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag")) + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag")) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); } @@ -111,7 +111,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT // pass here q directly as a pure string because .queryParam method delimiters the parameters in q with , // which is logical OR, we want AND here - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "?" + MgmtRestConstants.REQUEST_PARAMETER_SEARCH + "=colour==" + tag2.getColour()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -133,7 +133,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List tags = testdataFactory.createTargetTags(2, ""); final TargetTag assigned = tags.get(0); - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId()) + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + assigned.getId()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -159,7 +159,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .build(); final ResultActions result = mvc - .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING) + .perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1) .content(toJson(List.of(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -194,7 +194,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .build(); final ResultActions result = mvc - .perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()) + .perform(put(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + original.getId()) .content(toJson(update)).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -221,7 +221,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List tags = testdataFactory.createTargetTags(1, ""); final TargetTag original = tags.get(0); - mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId())) + mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + original.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -242,7 +242,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List targets = testdataFactory.createTargets(targetsAssigned); targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId()); - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")) + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(targetsAssigned))) @@ -265,7 +265,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List targets = testdataFactory.createTargets(targetsAssigned); targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId()); - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -291,7 +291,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List targets = testdataFactory.createTargets(targetsAssigned); targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId()); - mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(targetsAssigned))) .andDo(MockMvcResultPrinter.print()) @@ -313,7 +313,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0); final Target assigned = testdataFactory.createTargets(1).get(0); - mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + + mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned/" + assigned.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -336,7 +336,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final Target assigned0 = targets.get(0); final Target assigned1 = targets.get(1); - mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(List.of(assigned0.getControllerId(), assigned1.getControllerId()))) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -371,7 +371,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List withMissing = new ArrayList<>(targets); withMissing.addAll(missing); - mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -413,7 +413,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List withMissing = new ArrayList<>(targets); withMissing.addAll(missing); - mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_FAIL.name()) .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) @@ -457,7 +457,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List withMissing = new ArrayList<>(targets); withMissing.addAll(missing); - mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_SUCCESS.name()) .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) @@ -483,7 +483,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId()); - mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + + mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned/" + unassigned.getControllerId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -510,7 +510,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId()); - mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(Arrays.asList(unassigned0.getControllerId(), unassigned1.getControllerId()))) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -548,7 +548,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT targetManagement.assignTag(targets, tag.getId()); - mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -593,7 +593,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT targetManagement.assignTag(targets, tag.getId()); - mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_FAIL.name()) .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) @@ -638,7 +638,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT targetManagement.assignTag(targets, tag.getId()); - mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") + mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned") .param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_SUCCESS.name()) .content(toJson(withMissing)) .contentType(MediaType.APPLICATION_JSON)) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java index 5a04a2b17..93e480bad 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java @@ -33,7 +33,9 @@ import com.jayway.jsonpath.JsonPath; import org.eclipse.hawkbit.auth.SpPermission; import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.mgmt.json.model.MgmtId; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTypeRestApi; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetTypeManagement.Create; import org.eclipse.hawkbit.repository.TargetTypeManagement.Update; @@ -57,9 +59,9 @@ import org.springframework.test.web.servlet.ResultActions; */ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { - private static final String TARGETTYPES_ENDPOINT = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING; - private static final String TARGETTYPE_SINGLE_ENDPOINT = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{typeid}"; - private static final String TARGETTYPE_DSTYPES_ENDPOINT = TARGETTYPE_SINGLE_ENDPOINT + "/" + MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES; + private static final String TARGETTYPES_ENDPOINT = MgmtTargetTypeRestApi.TARGETTYPES_V1; + private static final String TARGETTYPE_SINGLE_ENDPOINT = MgmtTargetTypeRestApi.TARGETTYPES_V1 + "/{typeid}"; + private static final String TARGETTYPE_DSTYPES_ENDPOINT = TARGETTYPE_SINGLE_ENDPOINT + "/" + MgmtTargetTypeRestApi.COMPATIBLEDISTRIBUTIONSETTYPES; private static final String TARGETTYPE_DSTYPE_SINGLE_ENDPOINT = TARGETTYPE_DSTYPES_ENDPOINT + "/{dstypeid}"; private static final String TEST_USER = "targetTypeTester"; @@ -423,7 +425,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { assertThat(testType.getDistributionSetTypes()).hasSize(1); assertThat(distributionSetTypeManagement.findByKey(standardDsType.getKey())).isNotEmpty(); - mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/" + standardDsType.getId())) + mvc.perform(delete(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1 + "/" + standardDsType.getId())) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java index a5f19a599..f91d40ed9 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java @@ -9,7 +9,7 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING; +import static org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi.SYSTEM_V1; import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.callAs; import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.getAs; import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.withUser; @@ -52,7 +52,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg */ @Test void getTenantConfigurations() throws Exception { - mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs")) + mvc.perform(get(SYSTEM_V1 + "/configs")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // check for TenantMetadata additional properties @@ -66,7 +66,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg @Test void getTenantConfiguration() throws Exception { // test TenantConfiguration property - mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY)) + mvc.perform(get(SYSTEM_V1 + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -77,7 +77,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg @Test void getTenantMetadata() throws Exception { // test TenantMetadata property - mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)) + mvc.perform(get(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.value", equalTo(getActualDefaultDsType().intValue()))); @@ -93,7 +93,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg final ObjectMapper mapper = new ObjectMapper(); final String json = mapper.writeValueAsString(bodyPut); - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY) .contentType(MediaType.APPLICATION_JSON) .content(json)) .andDo(MockMvcResultPrinter.print()) @@ -113,7 +113,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg final ObjectMapper mapper = new ObjectMapper(); final String json = mapper.writeValueAsString(bodyPut); - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY) .contentType(MediaType.APPLICATION_JSON) .content(json)) .andDo(MockMvcResultPrinter.print()) @@ -149,13 +149,13 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg final String bodyActivate = new JSONObject().put("value", true).toString(); final String bodyDeactivate = new JSONObject().put("value", false).toString(); - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED) .content(bodyActivate) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED) .content(bodyDeactivate) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -232,7 +232,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg final String body = configuration.toString(); - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs").content(body).contentType(MediaType.APPLICATION_JSON)) + mvc.perform(put(SYSTEM_V1 + "/configs").content(body).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); @@ -258,21 +258,21 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg final String bodyDeactivate = new JSONObject().put("value", false).toString(); // enable Multi-Assignments - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED) .content(bodyActivate) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); // try to enable Auto-Close - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED) .content(bodyActivate) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()); // try to disable Auto-Close - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED) .content(bodyDeactivate) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -284,7 +284,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg */ @Test void deleteTenantConfiguration() throws Exception { - mvc.perform(delete(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY)) + mvc.perform(delete(SYSTEM_V1 + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); } @@ -294,7 +294,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg */ @Test void deleteTenantMetadataFail() throws Exception { - mvc.perform(delete(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)) + mvc.perform(delete(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -312,7 +312,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg // TODO - should be able to read with TENANT_CONFIGURATION but somehow here the role hierarchy doesn't play // checked in mgmt / update server runtime PreAuthorizeEnabledTest callAs(withUser("tenant_admin", SpPermission.READ_TENANT_CONFIGURATION, SpPermission.READ_GATEWAY_SECURITY_TOKEN), () -> { - mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs")) + mvc.perform(get(SYSTEM_V1 + "/configs")) .andDo(MockMvcResultPrinter.print()) .andDo(m -> System.out.println("-> 1: " + m.getResponse().getContentAsString())) .andExpect(status().isOk()) @@ -322,7 +322,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg }); callAs(withUser("tenant_read", SpPermission.READ_TENANT_CONFIGURATION), () -> { - mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs")) + mvc.perform(get(SYSTEM_V1 + "/configs")) .andDo(MockMvcResultPrinter.print()) .andDo(m -> System.out.println("-> 2: " + m.getResponse().getContentAsString())) .andExpect(status().isOk()) @@ -342,7 +342,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg private void assertDefaultDsTypeUpdateBadRequestFails( final String newDefaultDsType, final long oldDefaultDsType, final ResultMatcher resultMatchers) throws Exception { - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY) + mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY) .content(newDefaultDsType) .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -369,7 +369,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg configuration.put(DEFAULT_DISTRIBUTION_SET_TYPE_KEY, newDistributionSetTypeId); String body = configuration.toString(); - mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs").content(body).contentType(MediaType.APPLICATION_JSON)) + mvc.perform(put(SYSTEM_V1 + "/configs").content(body).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(resultMatchers); //Check if TenantMetadata and TenantConfiguration is not changed as Batch config failed diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java index f4008fac4..57fa10dc2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java @@ -60,14 +60,14 @@ class CorsTest extends AbstractSecurityTest { assertThat(invalidOriginResponseBody).isEqualTo(INVALID_CORS_REQUEST); final String invalidCorsUrlResponseBody = performOptionsRequestToUrlWithOrigin( - MgmtRestConstants.BASE_SYSTEM_MAPPING, ALLOWED_ORIGIN_FIRST).andExpect(status().isForbidden()) + "/some_uri", ALLOWED_ORIGIN_FIRST).andExpect(status().isForbidden()) .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN)).andReturn() .getResponse().getContentAsString(); assertThat(invalidCorsUrlResponseBody).isEqualTo(INVALID_CORS_REQUEST); } private ResultActions performOptionsRequestToRestWithOrigin(final String origin) throws Exception { - return performOptionsRequestToUrlWithOrigin(MgmtRestConstants.BASE_V1_REQUEST_MAPPING, origin); + return performOptionsRequestToUrlWithOrigin(MgmtRestConstants.REST_V1, origin); } private ResultActions performOptionsRequestToUrlWithOrigin(final String url, final String origin) throws Exception { diff --git a/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java b/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java index f3c17e92d..fd4bcb016 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java +++ b/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java @@ -85,8 +85,8 @@ public class MgmtSecurityConfiguration { final FilterRegistrationBean filterRegBean = SecurityManagedConfiguration.dosFilter(null, securityProperties.getDos().getFilter(), securityProperties.getClients()); filterRegBean.setUrlPatterns(List.of( - MgmtRestConstants.BASE_REST_MAPPING + "/*", - MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/*")); + MgmtRestConstants.REST + "/*", + "/system/admin/*")); filterRegBean.setOrder(SecurityManagedConfiguration.DOS_FILTER_ORDER); filterRegBean.setName("dosMgmtFilter"); @@ -111,9 +111,9 @@ public class MgmtSecurityConfiguration { @Autowired(required = false) @Qualifier("hawkbitHttpSecurityCustomizer") final Customizer httpSecurityCustomizer, final SystemManagement systemManagement) throws Exception { http - .securityMatcher(MgmtRestConstants.BASE_REST_MAPPING + "/**", MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**") + .securityMatcher(MgmtRestConstants.REST + "/**", "/system/admin/**") .authorizeHttpRequests(amrmRegistry -> amrmRegistry - .requestMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**") + .requestMatchers("/system/admin/**") .hasAnyAuthority(SpPermission.SYSTEM_ADMIN) .anyRequest() .authenticated()) diff --git a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java index 4259aec3e..24f1c93c4 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java +++ b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java @@ -60,14 +60,14 @@ class CorsTest extends AbstractSecurityTest { assertThat(invalidOriginResponseBody).isEqualTo(INVALID_CORS_REQUEST); final String invalidCorsUrlResponseBody = performOptionsRequestToUrlWithOrigin( - MgmtRestConstants.BASE_SYSTEM_MAPPING, ALLOWED_ORIGIN_FIRST).andExpect(status().isForbidden()) + "/some_uri", ALLOWED_ORIGIN_FIRST).andExpect(status().isForbidden()) .andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN)).andReturn() .getResponse().getContentAsString(); assertThat(invalidCorsUrlResponseBody).isEqualTo(INVALID_CORS_REQUEST); } private ResultActions performOptionsRequestToRestWithOrigin(final String origin) throws Exception { - return performOptionsRequestToUrlWithOrigin(MgmtRestConstants.BASE_V1_REQUEST_MAPPING, origin); + return performOptionsRequestToUrlWithOrigin(MgmtRestConstants.REST_V1, origin); } private ResultActions performOptionsRequestToUrlWithOrigin(final String url, final String origin) throws Exception {