Refactor REST Constants (#2881)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-01-22 17:06:44 +02:00
committed by GitHub
parent 5d562abd3c
commit 97762360c3
53 changed files with 1201 additions and 1536 deletions

View File

@@ -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";
}

View File

@@ -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<List<DdiArtifact>> 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<DdiControllerBase> 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<InputStream> 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<Void> 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<DdiDeploymentBase> 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<Void> 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<Void> 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<DdiCancel> 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<Void> 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<DdiDeploymentBase> 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<DdiConfirmationBase> 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<DdiConfirmationBaseAction> 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<Void> 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<Void> 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<Void> 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<Void> setAssignedOfflineVersion(
@Valid @RequestBody DdiAssignedVersion ddiAssignedVersion,

View File

@@ -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;

View File

@@ -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<DdiActionHistory> generateDdiActionHistory(final Action action, final Integer actionHistoryMessageCount) {
final List<String> 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));

View File

@@ -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.<String> 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());
}

View File

@@ -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);

View File

@@ -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));
}

View File

@@ -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());
}

View File

@@ -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));
}

View File

@@ -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());
}

View File

@@ -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;

View File

@@ -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;