diff --git a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java index 4ff0eae9a..a2fb1135f 100644 --- a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java +++ b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java @@ -151,7 +151,7 @@ public class DdiRootController implements DdiRootControllerRestApi { if (checkModule(fileName, module)) { LOG.warn("Softare module with id {} could not be found.", softwareModuleId); - result = new ResponseEntity<>(HttpStatus.NOT_FOUND); + result = ResponseEntity.notFound().build(); } else { // Exception squid:S3655 - Optional access is checked in checkModule @@ -215,7 +215,7 @@ public class DdiRootController implements DdiRootControllerRestApi { if (checkModule(fileName, module)) { LOG.warn("Software module with id {} could not be found.", softwareModuleId); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } try { @@ -226,7 +226,7 @@ public class DdiRootController implements DdiRootControllerRestApi { return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); } - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -243,7 +243,7 @@ public class DdiRootController implements DdiRootControllerRestApi { final Action action = findActionWithExceptionIfNotFound(actionId); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET, action.getId(), target.getId()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } if (!action.isCancelingOrCanceled()) { @@ -272,7 +272,7 @@ public class DdiRootController implements DdiRootControllerRestApi { return new ResponseEntity<>(base, HttpStatus.OK); } - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } @Override @@ -288,13 +288,13 @@ public class DdiRootController implements DdiRootControllerRestApi { LOG.warn( "provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).", feedback.getId(), actionId); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } final Action action = findActionWithExceptionIfNotFound(actionId); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET, action.getId(), target.getId()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } if (!action.isActive()) { @@ -305,7 +305,7 @@ public class DdiRootController implements DdiRootControllerRestApi { controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, controllerId, feedback.getId())); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @@ -373,7 +373,7 @@ public class DdiRootController implements DdiRootControllerRestApi { @PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId) { controllerManagement.updateControllerAttributes(controllerId, configData.getData()); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -388,7 +388,7 @@ public class DdiRootController implements DdiRootControllerRestApi { final Action action = findActionWithExceptionIfNotFound(actionId); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET, action.getId(), target.getId()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } if (action.isCancelingOrCanceled()) { @@ -403,7 +403,7 @@ public class DdiRootController implements DdiRootControllerRestApi { return new ResponseEntity<>(cancel, HttpStatus.OK); } - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } @Override @@ -420,18 +420,18 @@ public class DdiRootController implements DdiRootControllerRestApi { LOG.warn( "provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).", feedback.getId(), actionId); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } final Action action = findActionWithExceptionIfNotFound(actionId); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET, action.getId(), target.getId()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } controllerManagement .addCancelActionStatus(generateActionCancelStatus(feedback, target, feedback.getId(), entityFactory)); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } private static ActionStatusCreate generateActionCancelStatus(final DdiActionFeedback feedback, final Target target, diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java index 89679ca36..8f8dd5a5a 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java @@ -8,8 +8,6 @@ */ package org.eclipse.hawkbit.rabbitmq.test; -import static java.util.concurrent.TimeUnit.SECONDS; - import java.util.concurrent.TimeUnit; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; @@ -61,7 +59,7 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes } protected ConditionFactory createConditionFactory() { - return Awaitility.await().atMost(2, SECONDS); + return Awaitility.await().atMost(5, TimeUnit.SECONDS); } protected Message createMessage(final Object payload, final MessageProperties messageProperties) { diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java index 234e282a0..98081fa33 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtAction.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.mgmt.json.model.action; import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -24,17 +25,23 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class MgmtAction extends MgmtBaseEntity { /** - * API definition for update action}. + * API definition for action in update mode. */ public static final String ACTION_UPDATE = "update"; /** - * API definition for cancel action. + * API definition for action in canceling. */ public static final String ACTION_CANCEL = "cancel"; + /** + * API definition for action completed. + */ public static final String ACTION_FINISHED = "finished"; + /** + * API definition for action still active. + */ public static final String ACTION_PENDING = "pending"; @JsonProperty("id") @@ -46,6 +53,28 @@ public class MgmtAction extends MgmtBaseEntity { @JsonProperty private String status; + @JsonProperty + private Long forceTime; + + @JsonProperty + private MgmtActionType forceType; + + public Long getForceTime() { + return forceTime; + } + + public void setForceTime(final Long forceTime) { + this.forceTime = forceTime; + } + + public MgmtActionType getForceType() { + return forceType; + } + + public void setForceType(final MgmtActionType forceType) { + this.forceType = forceType; + } + /** * @return the status */ diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionRequestBodyPut.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionRequestBodyPut.java new file mode 100644 index 000000000..0497481cf --- /dev/null +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionRequestBodyPut.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.mgmt.json.model.action; + +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A json annotated model for Action updates in RESTful API representation. + * + */ +public class MgmtActionRequestBodyPut { + + @JsonProperty + private MgmtActionType forceType; + + public MgmtActionType getForceType() { + return forceType; + } + + public void setForceType(final MgmtActionType forceType) { + this.forceType = forceType; + } + +} diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java index 1cf226af3..fddfaf545 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java @@ -57,10 +57,10 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSets( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a single DistributionSet . @@ -73,8 +73,7 @@ public interface MgmtDistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getDistributionSet( - @PathVariable("distributionSetId") final Long distributionSetId); + ResponseEntity getDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** * Handles the POST request of creating new distribution sets . The request @@ -90,8 +89,7 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.POST, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createDistributionSets( - final List sets); + ResponseEntity> createDistributionSets(List sets); /** * Handles the DELETE request for a single DistributionSet . @@ -102,7 +100,7 @@ public interface MgmtDistributionSetRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}") - ResponseEntity deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId); + ResponseEntity deleteDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** * Handles the UPDATE request for a single DistributionSet . @@ -118,9 +116,8 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) - ResponseEntity updateDistributionSet( - @PathVariable("distributionSetId") final Long distributionSetId, - final MgmtDistributionSetRequestBodyPut toUpdate); + ResponseEntity updateDistributionSet(@PathVariable("distributionSetId") Long distributionSetId, + MgmtDistributionSetRequestBodyPut toUpdate); /** * Handles the GET request of retrieving assigned targets to a specific @@ -146,12 +143,11 @@ public interface MgmtDistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedTargets", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getAssignedTargets( - @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getAssignedTargets(@PathVariable("distributionSetId") Long distributionSetId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving installed targets to a specific @@ -177,12 +173,11 @@ public interface MgmtDistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/installedTargets", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getInstalledTargets( - @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getInstalledTargets(@PathVariable("distributionSetId") Long distributionSetId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request to retrieve target filter queries that have the @@ -209,11 +204,11 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/autoAssignTargetFilters", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAutoAssignTargetFilterQueries( - @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @PathVariable("distributionSetId") Long distributionSetId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the POST request of assigning multiple targets to a single @@ -232,8 +227,7 @@ public interface MgmtDistributionSetRestApi { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity createAssignedTarget( - @PathVariable("distributionSetId") final Long distributionSetId, - final List targetIds); + @PathVariable("distributionSetId") Long distributionSetId, List targetIds); /** * Gets a paged list of meta data for a distribution set. @@ -257,11 +251,11 @@ public interface MgmtDistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getMetadata(@PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getMetadata(@PathVariable("distributionSetId") Long distributionSetId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Gets a single meta data value for a specific key of a distribution set. @@ -275,8 +269,8 @@ public interface MgmtDistributionSetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getMetadataValue(@PathVariable("distributionSetId") final Long distributionSetId, - @PathVariable("metadataKey") final String metadataKey); + ResponseEntity getMetadataValue(@PathVariable("distributionSetId") Long distributionSetId, + @PathVariable("metadataKey") String metadataKey); /** * Updates a single meta data value of a distribution set. @@ -285,13 +279,15 @@ public interface MgmtDistributionSetRestApi { * 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 * @return status OK if the update request is successful and the updated * meta data result */ @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}/metadata/{metadataKey}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateMetadata(@PathVariable("distributionSetId") final Long distributionSetId, - @PathVariable("metadataKey") final String metadataKey, final MgmtMetadata metadata); + ResponseEntity updateMetadata(@PathVariable("distributionSetId") Long distributionSetId, + @PathVariable("metadataKey") String metadataKey, MgmtMetadata metadata); /** * Deletes a single meta data entry from the distribution set. @@ -303,8 +299,8 @@ public interface MgmtDistributionSetRestApi { * @return status OK if the delete request is successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}/metadata/{metadataKey}") - ResponseEntity deleteMetadata(@PathVariable("distributionSetId") final Long distributionSetId, - @PathVariable("metadataKey") final String metadataKey); + ResponseEntity deleteMetadata(@PathVariable("distributionSetId") Long distributionSetId, + @PathVariable("metadataKey") String metadataKey); /** * Creates a list of meta data for a specific distribution set. @@ -319,8 +315,8 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/metadata", consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createMetadata(@PathVariable("distributionSetId") final Long distributionSetId, - final List metadataRest); + ResponseEntity> createMetadata(@PathVariable("distributionSetId") Long distributionSetId, + List metadataRest); /** * Assigns a list of software modules to a distribution set. @@ -335,8 +331,8 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/assignedSM", consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity assignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId, - final List softwareModuleIDs); + ResponseEntity assignSoftwareModules(@PathVariable("distributionSetId") Long distributionSetId, + List softwareModuleIDs); /** * Deletes the assignment of the software module form the distribution set. @@ -350,8 +346,8 @@ public interface MgmtDistributionSetRestApi { * @return status OK if rejection was successful. */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}/assignedSM/{softwareModuleId}") - ResponseEntity deleteAssignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId, - @PathVariable("softwareModuleId") final Long softwareModuleId); + ResponseEntity deleteAssignSoftwareModules(@PathVariable("distributionSetId") Long distributionSetId, + @PathVariable("softwareModuleId") Long softwareModuleId); /** * Handles the GET request for retrieving the assigned software modules of a @@ -374,8 +370,8 @@ public interface MgmtDistributionSetRestApi { @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedSM", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedSoftwareModules( - @PathVariable("distributionSetId") final Long distributionSetId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam); + @PathVariable("distributionSetId") Long distributionSetId, + @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); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java index df04e7f12..b6bf2b24d 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java @@ -53,10 +53,10 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTags( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a single distribution set tag. @@ -68,8 +68,7 @@ public interface MgmtDistributionSetTagRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionsetTagId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getDistributionSetTag( - @PathVariable("distributionsetTagId") final Long distributionsetTagId); + ResponseEntity getDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId); /** * Handles the POST request of creating new distribution set tag. The @@ -84,7 +83,7 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.POST, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createDistributionSetTags(final List tags); + ResponseEntity> createDistributionSetTags(List tags); /** * @@ -100,9 +99,8 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.PUT, value = "/{distributionsetTagId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateDistributionSetTag( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - final MgmtTagRequestBodyPut restDSTagRest); + ResponseEntity updateDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId, + MgmtTagRequestBodyPut restDSTagRest); /** * Handles the DELETE request for a single distribution set tag. @@ -113,8 +111,7 @@ public interface MgmtDistributionSetTagRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionsetTagId}") - ResponseEntity deleteDistributionSetTag( - @PathVariable("distributionsetTagId") final Long distributionsetTagId); + ResponseEntity deleteDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId); /** * Handles the GET request of retrieving all assigned distribution sets by @@ -140,11 +137,11 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedDistributionSets( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @PathVariable("distributionsetTagId") Long distributionsetTagId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving all assigned distribution sets by @@ -164,7 +161,7 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DEPRECATED_DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedDistributionSets( - @PathVariable("distributionsetTagId") final Long distributionsetTagId); + @PathVariable("distributionsetTagId") Long distributionsetTagId); /** * Handles the POST request to toggle the assignment of distribution sets by @@ -181,8 +178,8 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/toggleTagAssignment") ResponseEntity toggleTagAssignment( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - final List assignedDSRequestBodies); + @PathVariable("distributionsetTagId") Long distributionsetTagId, + List assignedDSRequestBodies); /** * Handles the POST request to toggle the assignment of distribution sets by @@ -203,8 +200,8 @@ public interface MgmtDistributionSetTagRestApi { @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DEPRECATED_DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/toggleTagAssignment") ResponseEntity toggleTagAssignmentUnpaged( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - final List assignedDSRequestBodies); + @PathVariable("distributionsetTagId") Long distributionsetTagId, + List assignedDSRequestBodies); /** * Handles the POST request to assign distribution sets to the given tag id. @@ -220,8 +217,8 @@ public interface MgmtDistributionSetTagRestApi { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> assignDistributionSets( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - final List assignedDSRequestBodies); + @PathVariable("distributionsetTagId") Long distributionsetTagId, + List assignedDSRequestBodies); /** * Handles the POST request to assign distribution sets to the given tag id. @@ -241,8 +238,8 @@ public interface MgmtDistributionSetTagRestApi { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> assignDistributionSetsUnpaged( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - final List assignedDSRequestBodies); + @PathVariable("distributionsetTagId") Long distributionsetTagId, + List assignedDSRequestBodies); /** * Handles the DELETE request to unassign one distribution set from the @@ -256,8 +253,8 @@ public interface MgmtDistributionSetTagRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/{distributionsetId}") - ResponseEntity unassignDistributionSet(@PathVariable("distributionsetTagId") final Long distributionsetTagId, - @PathVariable("distributionsetId") final Long distributionsetId); + ResponseEntity unassignDistributionSet(@PathVariable("distributionsetTagId") Long distributionsetTagId, + @PathVariable("distributionsetId") Long distributionsetId); /** * Handles the DELETE request to unassign one distribution set from the @@ -275,7 +272,6 @@ public interface MgmtDistributionSetTagRestApi { @Deprecated @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DEPRECATED_DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/{distributionsetId}") - ResponseEntity unassignDistributionSetUnpaged( - @PathVariable("distributionsetTagId") final Long distributionsetTagId, - @PathVariable("distributionsetId") final Long distributionsetId); + ResponseEntity unassignDistributionSetUnpaged(@PathVariable("distributionsetTagId") Long distributionsetTagId, + @PathVariable("distributionsetId") Long distributionsetId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java index b253ac027..f48250fb2 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java @@ -56,10 +56,10 @@ public interface MgmtDistributionSetTypeRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTypes( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a single DistributionSetType @@ -73,7 +73,7 @@ public interface MgmtDistributionSetTypeRestApi { @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSetType( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); + @PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** * Handles the DELETE request for a single Distribution Set Type. @@ -84,8 +84,7 @@ public interface MgmtDistributionSetTypeRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}") - ResponseEntity deleteDistributionSetType( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); + ResponseEntity deleteDistributionSetType(@PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** * Handles the PUT request of updating a Distribution Set Type. @@ -100,8 +99,8 @@ public interface MgmtDistributionSetTypeRestApi { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateDistributionSetType( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, + MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); /** * Handles the POST request of creating new DistributionSetTypes. The @@ -118,7 +117,7 @@ public interface MgmtDistributionSetTypeRestApi { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSetTypes( - final List distributionSetTypes); + List distributionSetTypes); /** * Handles the GET request of retrieving the list of mandatory software @@ -132,7 +131,7 @@ public interface MgmtDistributionSetTypeRestApi { + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getMandatoryModules( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); + @PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** * Handles the GET request of retrieving the single mandatory software @@ -148,8 +147,8 @@ public interface MgmtDistributionSetTypeRestApi { + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getMandatoryModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, + @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** * Handles the GET request of retrieving the single optional software module @@ -165,8 +164,8 @@ public interface MgmtDistributionSetTypeRestApi { + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getOptionalModule( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); + @PathVariable("distributionSetTypeId") Long distributionSetTypeId, + @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** * Handles the GET request of retrieving the list of optional software @@ -180,7 +179,7 @@ public interface MgmtDistributionSetTypeRestApi { + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getOptionalModules( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId); + @PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** * Handles DELETE request for removing a mandatory module from the @@ -195,8 +194,8 @@ public interface MgmtDistributionSetTypeRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}") - ResponseEntity removeMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); + ResponseEntity removeMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, + @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** * Handles DELETE request for removing an optional module from the @@ -211,8 +210,8 @@ public interface MgmtDistributionSetTypeRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}") - ResponseEntity removeOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); + ResponseEntity removeOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, + @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** * Handles the POST request for adding a mandatory software module type to a @@ -228,8 +227,8 @@ public interface MgmtDistributionSetTypeRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addMandatoryModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - final MgmtId smtId); + ResponseEntity addMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, + MgmtId smtId); /** * Handles the POST request for adding an optional software module type to a @@ -245,7 +244,7 @@ public interface MgmtDistributionSetTypeRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addOptionalModule(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId, - final MgmtId smtId); + ResponseEntity addOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, + MgmtId smtId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java index 9053af8c8..b33753570 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java @@ -39,7 +39,7 @@ public interface MgmtDownloadArtifactRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}/download") @ResponseBody - ResponseEntity downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, - @PathVariable("artifactId") final Long artifactId); + ResponseEntity downloadArtifact(@PathVariable("softwareModuleId") Long softwareModuleId, + @PathVariable("artifactId") Long artifactId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java index ea179b830..4a31f78e4 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadRestApi.java @@ -35,6 +35,6 @@ public interface MgmtDownloadRestApi { */ @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING) @ResponseBody - ResponseEntity downloadArtifactByDownloadId(@PathVariable("downloadId") final String downloadId); + ResponseEntity downloadArtifactByDownloadId(@PathVariable("downloadId") String downloadId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java index cfdedae80..a026078d1 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java @@ -50,10 +50,10 @@ public interface MgmtRolloutRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getRollouts( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a single rollout. @@ -64,7 +64,7 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(value = "/{rolloutId}", method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getRollout(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity getRollout(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request for creating rollout. @@ -79,7 +79,7 @@ public interface MgmtRolloutRestApi { @RequestMapping(method = RequestMethod.POST, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity create(final MgmtRolloutRestRequestBody rolloutRequestBody); + ResponseEntity create(MgmtRolloutRestRequestBody rolloutRequestBody); /** * Handles the POST request for starting a rollout. @@ -91,7 +91,7 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/start", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity start(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity start(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request for pausing a rollout. @@ -103,7 +103,7 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/pause", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity pause(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity pause(@PathVariable("rolloutId") Long rolloutId); /** * Handles the DELETE request for deleting a rollout. @@ -115,7 +115,7 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{rolloutId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity delete(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity delete(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request for resuming a rollout. @@ -127,7 +127,7 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/resume", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity resume(@PathVariable("rolloutId") final Long rolloutId); + ResponseEntity resume(@PathVariable("rolloutId") Long rolloutId); /** * Handles the GET request of retrieving all rollout groups referred to a @@ -153,12 +153,11 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getRolloutGroups( - @PathVariable("rolloutId") final Long rolloutId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getRolloutGroups(@PathVariable("rolloutId") Long rolloutId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request for retrieving a single rollout group. @@ -171,8 +170,8 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups/{groupId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getRolloutGroup(@PathVariable("rolloutId") final Long rolloutId, - @PathVariable("groupId") final Long groupId); + ResponseEntity getRolloutGroup(@PathVariable("rolloutId") Long rolloutId, + @PathVariable("groupId") Long groupId); /** * Retrieves all targets related to a specific rollout group. @@ -199,10 +198,10 @@ public interface MgmtRolloutRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{rolloutId}/deploygroups/{groupId}/targets", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getRolloutGroupTargets(@PathVariable("rolloutId") final Long rolloutId, - @PathVariable("groupId") final Long groupId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getRolloutGroupTargets(@PathVariable("rolloutId") Long rolloutId, + @PathVariable("groupId") Long groupId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java index 47afc2bc3..37c6b1eab 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java @@ -172,7 +172,7 @@ public interface MgmtSoftwareModuleRestApi { * the ID of the software module in the URL * @param restSoftwareModule * the modules to be updated. - * @return status OK if update is successful + * @return status OK if update was successful */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, @@ -186,7 +186,7 @@ public interface MgmtSoftwareModuleRestApi { * * @param softwareModuleId * the ID of the module to retrieve - * @return status OK if delete as sucessfull. + * @return status OK if delete was successful. * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}") diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java index 3d33a6589..104b21a86 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java @@ -52,10 +52,10 @@ public interface MgmtSoftwareModuleTypeRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTypes( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a single software module type . @@ -68,7 +68,7 @@ public interface MgmtSoftwareModuleTypeRestApi { @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getSoftwareModuleType( - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); + @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** * Handles the DELETE request for a single software module type . @@ -79,8 +79,7 @@ public interface MgmtSoftwareModuleTypeRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleTypeId}") - ResponseEntity deleteSoftwareModuleType( - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); + ResponseEntity deleteSoftwareModuleType(@PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** * Handles the PUT request of updating a software module type . @@ -95,8 +94,8 @@ public interface MgmtSoftwareModuleTypeRestApi { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateSoftwareModuleType( - @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId, - final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType); + @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId, + MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType); /** * Handles the POST request of creating new SoftwareModuleTypes. The request @@ -113,6 +112,6 @@ public interface MgmtSoftwareModuleTypeRestApi { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createSoftwareModuleTypes( - final List softwareModuleTypes); + List softwareModuleTypes); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java index 843974936..294d50972 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java @@ -34,7 +34,7 @@ public interface MgmtSystemManagementRestApi { * @return HttpStatus.OK */ @RequestMapping(method = RequestMethod.DELETE, value = "/tenants/{tenant}") - ResponseEntity deleteTenant(@PathVariable("tenant") final String tenant); + ResponseEntity deleteTenant(@PathVariable("tenant") String tenant); /** * Collects and returns system usage statistics. It provides a system wide diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java index 1fa94b552..23f337ceb 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemRestApi.java @@ -51,7 +51,7 @@ public interface MgmtSystemRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = "/configs/{keyName}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity deleteConfigurationValue(@PathVariable("keyName") final String keyName); + ResponseEntity deleteConfigurationValue(@PathVariable("keyName") String keyName); /** * Handles the GET request of deleting a tenant specific configuration value @@ -65,8 +65,7 @@ public interface MgmtSystemRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/configs/{keyName}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getConfigurationValue( - @PathVariable("keyName") final String keyName); + ResponseEntity getConfigurationValue(@PathVariable("keyName") String keyName); /** * Handles the GET request of deleting a tenant specific configuration value @@ -83,8 +82,7 @@ public interface MgmtSystemRestApi { @RequestMapping(method = RequestMethod.PUT, value = "/configs/{keyName}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateConfigurationValue( - @PathVariable("keyName") final String keyName, - final MgmtSystemTenantConfigurationValueRequest configurationValueRest); + ResponseEntity updateConfigurationValue(@PathVariable("keyName") String keyName, + MgmtSystemTenantConfigurationValueRequest configurationValueRest); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java index 369b2148b..7ec5b6d84 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java @@ -38,7 +38,7 @@ public interface MgmtTargetFilterQueryRestApi { @RequestMapping(method = RequestMethod.GET, value = "/{filterId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getFilter(@PathVariable("filterId") final Long filterId); + ResponseEntity getFilter(@PathVariable("filterId") Long filterId); /** * Handles the GET request of retrieving all filters. @@ -63,10 +63,10 @@ public interface MgmtTargetFilterQueryRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getFilters( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the POST request of creating new target filters. The request body @@ -82,7 +82,7 @@ public interface MgmtTargetFilterQueryRestApi { @RequestMapping(method = RequestMethod.POST, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity createFilter(@RequestBody final MgmtTargetFilterQueryRequestBody filter); + ResponseEntity createFilter(@RequestBody MgmtTargetFilterQueryRequestBody filter); /** * Handles the PUT request of updating a target filter. The ID is within the @@ -101,8 +101,8 @@ public interface MgmtTargetFilterQueryRestApi { @RequestMapping(method = RequestMethod.PUT, value = "/{filterId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateFilter(@PathVariable("filterId") final Long filterId, - @RequestBody final MgmtTargetFilterQueryRequestBody targetFilterRest); + ResponseEntity updateFilter(@PathVariable("filterId") Long filterId, + @RequestBody MgmtTargetFilterQueryRequestBody targetFilterRest); /** * Handles the DELETE request of deleting a target filter. @@ -115,7 +115,7 @@ public interface MgmtTargetFilterQueryRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{filterId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity deleteFilter(@PathVariable("filterId") final Long filterId); + ResponseEntity deleteFilter(@PathVariable("filterId") Long filterId); /** * Handles the GET request of retrieving the distribution set for auto @@ -128,7 +128,7 @@ public interface MgmtTargetFilterQueryRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{filterId}/autoAssignDS", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getAssignedDistributionSet(@PathVariable("filterId") final Long filterId); + ResponseEntity getAssignedDistributionSet(@PathVariable("filterId") Long filterId); /** * Handles the POST request for changing distribution set for auto @@ -143,8 +143,8 @@ public interface MgmtTargetFilterQueryRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{filterId}/autoAssignDS", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity postAssignedDistributionSet(@PathVariable("filterId") final Long filterId, - @RequestBody final MgmtId dsId); + ResponseEntity postAssignedDistributionSet(@PathVariable("filterId") Long filterId, + @RequestBody MgmtId dsId); /** * Handles the DELETE request for removing the distribution set for auto @@ -155,6 +155,6 @@ public interface MgmtTargetFilterQueryRestApi { * @return http status */ @RequestMapping(method = RequestMethod.DELETE, value = "/{filterId}/autoAssignDS") - ResponseEntity deleteAssignedDistributionSet(@PathVariable("filterId") final Long filterId); + ResponseEntity deleteAssignedDistributionSet(@PathVariable("filterId") Long filterId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java index cd7a00e21..10dde5c50 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java @@ -12,6 +12,7 @@ import java.util.List; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtDistributionSetAssigment; @@ -39,10 +40,9 @@ public interface MgmtTargetRestApi { * the ID of the target to retrieve * @return a single target with status OK. */ - @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getTarget(@PathVariable("controllerId") final String controllerId); + ResponseEntity getTarget(@PathVariable("controllerId") String controllerId); /** * Handles the GET request of retrieving all targets. @@ -67,10 +67,10 @@ public interface MgmtTargetRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargets( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the POST request of creating new targets. The request body must @@ -86,7 +86,7 @@ public interface MgmtTargetRestApi { @RequestMapping(method = RequestMethod.POST, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createTargets(final List targets); + ResponseEntity> createTargets(List targets); /** * Handles the PUT request of updating a target. The ID is within the URL @@ -105,8 +105,8 @@ public interface MgmtTargetRestApi { @RequestMapping(method = RequestMethod.PUT, value = "/{controllerId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateTarget(@PathVariable("controllerId") final String controllerId, - final MgmtTargetRequestBody targetRest); + ResponseEntity updateTarget(@PathVariable("controllerId") String controllerId, + MgmtTargetRequestBody targetRest); /** * Handles the DELETE request of deleting a target. @@ -118,7 +118,7 @@ public interface MgmtTargetRestApi { * the response. */ @RequestMapping(method = RequestMethod.DELETE, value = "/{controllerId}") - ResponseEntity deleteTarget(@PathVariable("controllerId") final String controllerId); + ResponseEntity deleteTarget(@PathVariable("controllerId") String controllerId); /** * Handles the GET request of retrieving the attributes of a specific @@ -130,7 +130,7 @@ public interface MgmtTargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}/attributes", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getAttributes(@PathVariable("controllerId") final String controllerId); + ResponseEntity getAttributes(@PathVariable("controllerId") String controllerId); /** * Handles the GET request of retrieving the Actions of a specific target. @@ -155,11 +155,11 @@ public interface MgmtTargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}/actions", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getActionHistory(@PathVariable("controllerId") final String controllerId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getActionHistory(@PathVariable("controllerId") String controllerId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a specific Actions of a specific @@ -173,8 +173,8 @@ public interface MgmtTargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}/actions/{actionId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getAction(@PathVariable("controllerId") final String controllerId, - @PathVariable("actionId") final Long actionId); + ResponseEntity getAction(@PathVariable("controllerId") String controllerId, + @PathVariable("actionId") Long actionId); /** * Handles the DELETE request of canceling an specific Actions of a specific @@ -189,9 +189,26 @@ public interface MgmtTargetRestApi { * @return status no content in case cancellation was successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{controllerId}/actions/{actionId}") - ResponseEntity cancelAction(@PathVariable("controllerId") final String controllerId, - @PathVariable("actionId") final Long actionId, - @RequestParam(value = "force", required = false, defaultValue = "false") final boolean force); + ResponseEntity cancelAction(@PathVariable("controllerId") String controllerId, + @PathVariable("actionId") Long actionId, + @RequestParam(value = "force", required = false, defaultValue = "false") boolean force); + + /** + * Handles the PUT update request to switch an action from soft to forced. + * + * @param controllerId + * the ID of the target in the URL path parameter + * @param actionId + * the ID of the action in the URL path parameter + * @param actionUpdate + * to update the action + * @return status no content in case cancellation was successful + */ + @RequestMapping(method = RequestMethod.PUT, value = "/{controllerId}/actions/{actionId}", consumes = { + MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, + MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateAction(@PathVariable("controllerId") String controllerId, + @PathVariable("actionId") Long actionId, MgmtActionRequestBodyPut actionUpdate); /** * Handles the GET request of retrieving the ActionStatus of a specific @@ -216,11 +233,11 @@ public interface MgmtTargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}/actions/{actionId}/status", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getActionStatusList( - @PathVariable("controllerId") final String controllerId, @PathVariable("actionId") final Long actionId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam); + ResponseEntity> getActionStatusList(@PathVariable("controllerId") String controllerId, + @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); /** * Handles the GET request of retrieving the assigned distribution set of an @@ -233,8 +250,7 @@ public interface MgmtTargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}/assignedDS", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getAssignedDistributionSet( - @PathVariable("controllerId") final String controllerId); + ResponseEntity getAssignedDistributionSet(@PathVariable("controllerId") String controllerId); /** * Changes the assigned distribution set of a target. @@ -248,8 +264,8 @@ public interface MgmtTargetRestApi { @RequestMapping(method = RequestMethod.POST, value = "/{controllerId}/assignedDS", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity postAssignedDistributionSet(@PathVariable("controllerId") final String controllerId, - final MgmtDistributionSetAssigment dsId); + ResponseEntity postAssignedDistributionSet(@PathVariable("controllerId") String controllerId, + MgmtDistributionSetAssigment dsId); /** * Handles the GET request of retrieving the installed distribution set of @@ -262,7 +278,6 @@ public interface MgmtTargetRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{controllerId}/installedDS", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getInstalledDistributionSet( - @PathVariable("controllerId") final String controllerId); + ResponseEntity getInstalledDistributionSet(@PathVariable("controllerId") String controllerId); } diff --git a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java index 641b56d86..e698bc91f 100644 --- a/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java +++ b/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java @@ -53,10 +53,10 @@ public interface MgmtTargetTagRestApi { @RequestMapping(method = RequestMethod.GET, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTags( - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the GET request of retrieving a single target tag. @@ -68,7 +68,7 @@ public interface MgmtTargetTagRestApi { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetTagId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getTargetTag(@PathVariable("targetTagId") final Long targetTagId); + ResponseEntity getTargetTag(@PathVariable("targetTagId") Long targetTagId); /** * Handles the POST request of creating new target tag. The request body @@ -83,7 +83,7 @@ public interface MgmtTargetTagRestApi { @RequestMapping(method = RequestMethod.POST, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createTargetTags(final List tags); + ResponseEntity> createTargetTags(List tags); /** * @@ -98,8 +98,8 @@ public interface MgmtTargetTagRestApi { @RequestMapping(method = RequestMethod.PUT, value = "/{targetTagId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateTargetTag(@PathVariable("targetTagId") final Long targetTagId, - final MgmtTagRequestBodyPut restTargetTagRest); + ResponseEntity updateTargetTag(@PathVariable("targetTagId") Long targetTagId, + MgmtTagRequestBodyPut restTargetTagRest); /** * Handles the DELETE request for a single target tag. @@ -110,7 +110,7 @@ public interface MgmtTargetTagRestApi { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{targetTagId}") - ResponseEntity deleteTargetTag(@PathVariable("targetTagId") final Long targetTagId); + ResponseEntity deleteTargetTag(@PathVariable("targetTagId") Long targetTagId); /** * Handles the GET request of retrieving all assigned targets by the given @@ -129,7 +129,7 @@ public interface MgmtTargetTagRestApi { @Deprecated @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.DEPRECATAED_TARGET_TAG_TARGETS_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId); + ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") Long targetTagId); /** * Handles the GET request of retrieving all assigned targets by the given @@ -154,11 +154,11 @@ public interface MgmtTargetTagRestApi { */ @RequestMapping(method = RequestMethod.GET, value = MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); + ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") Long targetTagId, + @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 = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) String rsqlParam); /** * Handles the POST request to toggle the assignment of targets by the given @@ -175,9 +175,8 @@ public interface MgmtTargetTagRestApi { + "/toggleTagAssignment", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity toggleTagAssignment( - @PathVariable("targetTagId") final Long targetTagId, - final List assignedTargetRequestBodies); + ResponseEntity toggleTagAssignment(@PathVariable("targetTagId") Long targetTagId, + List assignedTargetRequestBodies); /** * Handles the POST request to toggle the assignment of targets by the given @@ -197,8 +196,8 @@ public interface MgmtTargetTagRestApi { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity toggleTagAssignmentUnpaged( - @PathVariable("targetTagId") final Long targetTagId, - final List assignedTargetRequestBodies); + @PathVariable("targetTagId") Long targetTagId, + List assignedTargetRequestBodies); /** * Handles the POST request to assign targets to the given tag id. @@ -213,8 +212,8 @@ public interface MgmtTargetTagRestApi { @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> assignTargets(@PathVariable("targetTagId") final Long targetTagId, - final List assignedTargetRequestBodies); + ResponseEntity> assignTargets(@PathVariable("targetTagId") Long targetTagId, + List assignedTargetRequestBodies); /** * Handles the POST request to assign targets to the given tag id. @@ -232,8 +231,8 @@ public interface MgmtTargetTagRestApi { @RequestMapping(method = RequestMethod.POST, value = MgmtRestConstants.DEPRECATAED_TARGET_TAG_TARGETS_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> assignTargetsUnpaged(@PathVariable("targetTagId") final Long targetTagId, - final List assignedTargetRequestBodies); + ResponseEntity> assignTargetsUnpaged(@PathVariable("targetTagId") Long targetTagId, + List assignedTargetRequestBodies); /** * Handles the DELETE request to unassign one target from the given tag id. @@ -246,8 +245,8 @@ public interface MgmtTargetTagRestApi { */ @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/{controllerId}") - ResponseEntity unassignTarget(@PathVariable("targetTagId") final Long targetTagId, - @PathVariable("controllerId") final String controllerId); + ResponseEntity unassignTarget(@PathVariable("targetTagId") Long targetTagId, + @PathVariable("controllerId") String controllerId); /** * Handles the DELETE request to unassign one target from the given tag id. @@ -263,6 +262,6 @@ public interface MgmtTargetTagRestApi { @Deprecated @RequestMapping(method = RequestMethod.DELETE, value = MgmtRestConstants.DEPRECATAED_TARGET_TAG_TARGETS_REQUEST_MAPPING + "/{controllerId}") - ResponseEntity unassignTargetUnpaged(@PathVariable("targetTagId") final Long targetTagId, - @PathVariable("controllerId") final String controllerId); + ResponseEntity unassignTargetUnpaged(@PathVariable("targetTagId") Long targetTagId, + @PathVariable("controllerId") String controllerId); } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java index 4bd7e53a0..0cad26bef 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java @@ -106,7 +106,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { } final List rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, findDsPage.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, findDsPage.getTotalElements())); } @Override @@ -114,7 +114,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { @PathVariable("distributionSetId") final Long distributionSetId) { final DistributionSet foundDs = findDistributionSetWithExceptionIfNotFound(distributionSetId); - return new ResponseEntity<>(MgmtDistributionSetMapper.toResponse(foundDs), HttpStatus.OK); + return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(foundDs)); } @Override @@ -138,7 +138,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { @Override public ResponseEntity deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId) { distributionSetManagement.deleteDistributionSet(distributionSetId); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -146,12 +146,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { @PathVariable("distributionSetId") final Long distributionSetId, @RequestBody final MgmtDistributionSetRequestBodyPut toUpdate) { - return new ResponseEntity<>( - MgmtDistributionSetMapper.toResponse(distributionSetManagement.updateDistributionSet( - entityFactory.distributionSet().update(distributionSetId).name(toUpdate.getName()) - .description(toUpdate.getDescription()).version(toUpdate.getVersion()) - .requiredMigrationStep(toUpdate.isRequiredMigrationStep()))), - HttpStatus.OK); + return ResponseEntity.ok(MgmtDistributionSetMapper + .toResponse(distributionSetManagement.updateDistributionSet(entityFactory.distributionSet() + .update(distributionSetId).name(toUpdate.getName()).description(toUpdate.getDescription()) + .version(toUpdate.getVersion()).requiredMigrationStep(toUpdate.isRequiredMigrationStep())))); } @Override @@ -175,8 +173,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable); } - return new ResponseEntity<>(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent()), - targetsAssignedDS.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent()), + targetsAssignedDS.getTotalElements())); } @Override @@ -204,8 +202,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { pageable); } - return new ResponseEntity<>(new PagedList<>(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent()), - targetsInstalledDS.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent()), + targetsInstalledDS.getTotalElements())); } @Override @@ -223,10 +221,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { final Page targetFilterQueries = targetFilterQueryManagement .findTargetFilterQueryByAutoAssignDS(pageable, distributionSetId, rsqlParam); - return new ResponseEntity<>( - new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent()), - targetFilterQueries.getTotalElements()), - HttpStatus.OK); + return ResponseEntity + .ok(new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent()), + targetFilterQueries.getTotalElements())); } @Override @@ -241,7 +238,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { MgmtRestModelMapper.convertActionType(t.getType()), t.getForcetime())) .collect(Collectors.toList())); - return new ResponseEntity<>(MgmtDistributionSetMapper.toResponse(assignDistributionSet), HttpStatus.OK); + return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(assignDistributionSet)); } @Override @@ -267,10 +264,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { pageable); } - return new ResponseEntity<>( - new PagedList<>(MgmtDistributionSetMapper.toResponseDsMetadata(metaDataPage.getContent()), - metaDataPage.getTotalElements()), - HttpStatus.OK); + return ResponseEntity + .ok(new PagedList<>(MgmtDistributionSetMapper.toResponseDsMetadata(metaDataPage.getContent()), + metaDataPage.getTotalElements())); } @@ -324,7 +320,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { distributionSetManagement.assignSoftwareModules(distributionSetId, softwareModuleIDs.stream().map(MgmtSoftwareModuleAssigment::getId).collect(Collectors.toList())); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -348,8 +344,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Page softwaremodules = softwareModuleManagement.findSoftwareModuleByAssignedTo(pageable, distributionSetId); - return new ResponseEntity<>(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()), - softwaremodules.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()), + softwaremodules.getTotalElements())); } private DistributionSet findDistributionSetWithExceptionIfNotFound(final Long distributionSetId) { diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java index 56034437b..7a2c5be8d 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java @@ -80,14 +80,14 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes } final List rest = MgmtTagMapper.toResponseDistributionSetTag(findTargetsAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, findTargetsAll.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, findTargetsAll.getTotalElements())); } @Override public ResponseEntity getDistributionSetTag( @PathVariable("distributionsetTagId") final Long distributionsetTagId) { final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); - return new ResponseEntity<>(MgmtTagMapper.toResponse(tag), HttpStatus.OK); + return ResponseEntity.ok(MgmtTagMapper.toResponse(tag)); } @Override @@ -106,11 +106,9 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @PathVariable("distributionsetTagId") final Long distributionsetTagId, @RequestBody final MgmtTagRequestBodyPut restDSTagRest) { - return new ResponseEntity<>( - MgmtTagMapper.toResponse(tagManagement.updateDistributionSetTag( - entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName()) - .description(restDSTagRest.getDescription()).colour(restDSTagRest.getColour()))), - HttpStatus.OK); + return ResponseEntity.ok(MgmtTagMapper.toResponse(tagManagement + .updateDistributionSetTag(entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName()) + .description(restDSTagRest.getDescription()).colour(restDSTagRest.getColour())))); } @Override @@ -121,16 +119,16 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes this.tagManagement.deleteDistributionSetTag(tag.getName()); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override public ResponseEntity> getAssignedDistributionSets( @PathVariable("distributionsetTagId") final Long distributionsetTagId) { - return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(distributionSetManagement + return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDistributionSets(distributionSetManagement .findDistributionSetsByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), distributionsetTagId) - .getContent()), HttpStatus.OK); + .getContent())); } @Override @@ -156,7 +154,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes final List rest = MgmtDistributionSetMapper .toResponseFromDsList(findDistrAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, findDistrAll.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, findDistrAll.getTotalElements())); } @Override @@ -180,7 +178,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(), assigmentResult.getUnassigned()); - return new ResponseEntity<>(tagAssigmentResultRest, HttpStatus.OK); + return ResponseEntity.ok(tagAssigmentResultRest); } @Override @@ -191,7 +189,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes final List assignedDs = this.distributionSetManagement .assignTag(findDistributionSetIds(assignedDSRequestBodies), distributionsetTagId); LOG.debug("Assignd DistributionSet {}", assignedDs.size()); - return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK); + return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDistributionSets(assignedDs)); } @Override @@ -200,7 +198,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @PathVariable("distributionsetId") final Long distributionsetId) { LOG.debug("Unassign ds {} for ds tag {}", distributionsetId, distributionsetTagId); this.distributionSetManagement.unAssignTag(distributionsetId, distributionsetTagId); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } private DistributionSetTag findDistributionTagById(final Long distributionsetTagId) { diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java index 76494416e..da9935752 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadResource.java @@ -71,7 +71,7 @@ public class MgmtDownloadResource implements MgmtDownloadRestApi { final DownloadArtifactCache artifactCache = downloadIdCache.get(downloadId); if (artifactCache == null) { LOGGER.warn("Download Id {} could not be found", downloadId); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } DbArtifact artifact = null; @@ -85,7 +85,7 @@ public class MgmtDownloadResource implements MgmtDownloadRestApi { if (artifact == null) { LOGGER.warn("Artifact with cached id {} and download type {} could not be found.", artifactCache.getId(), artifactCache.getDownloadType()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } final HttpServletResponse response = requestResponseContextHolder.getHttpServletResponse(); diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java index 4fb9f0574..7a5c36f16 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java @@ -45,13 +45,6 @@ final class MgmtRestModelMapper { response.setDescription(base.getDescription()); } - /** - * Convert a action rest type to a action repository type. - * - * @param actionTypeRest - * the rest type - * @return or the action repository type - */ /** * Convert a action rest type to a action repository type. * @@ -75,4 +68,28 @@ final class MgmtRestModelMapper { throw new IllegalStateException("Action Type is not supported"); } } + + /** + * Convert a action repository type to rest type. + * + * @param actionType + * the rest type + * @return or the action repository type + */ + public static MgmtActionType convertActionType(final ActionType actionType) { + if (actionType == null) { + return null; + } + + switch (actionType) { + case SOFT: + return MgmtActionType.SOFT; + case FORCED: + return MgmtActionType.FORCED; + case TIMEFORCED: + return MgmtActionType.TIMEFORCED; + default: + throw new IllegalStateException("Action Type is not supported"); + } + } } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java index 95c8c8aa5..6ac1fcc80 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java @@ -86,7 +86,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { } final List rest = MgmtRolloutMapper.toResponseRollout(findModulesAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, findModulesAll.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, findModulesAll.getTotalElements())); } @Override @@ -94,7 +94,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { final Rollout findRolloutById = rolloutManagement.findRolloutWithDetailedStatus(rolloutId) .orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId)); - return new ResponseEntity<>(MgmtRolloutMapper.toResponseRollout(findRolloutById, true), HttpStatus.OK); + return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(findRolloutById, true)); } @Override @@ -174,7 +174,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { final List rest = MgmtRolloutMapper .toResponseRolloutGroup(findRolloutGroupsAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, findRolloutGroupsAll.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, findRolloutGroupsAll.getTotalElements())); } @Override @@ -215,7 +215,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { rolloutGroupTargets = pageTargets; } final List rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, rolloutGroupTargets.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, rolloutGroupTargets.getTotalElements())); } private DistributionSet findDistributionSetOrThrowException(final MgmtRolloutRestRequestBody rolloutRequestBody) { diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java index ba62d6d5a..9c17bc380 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java @@ -70,7 +70,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { @RequestParam(value = "sha1sum", required = false) final String sha1Sum) { if (file.isEmpty()) { - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + return ResponseEntity.badRequest().build(); } String fileName = optionalFileName; @@ -208,10 +208,11 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { final Page metaDataPage; if (rsqlParam != null) { - metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam, - pageable); + metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, + rsqlParam, pageable); } else { - metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable); + metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, + pageable); } return ResponseEntity @@ -252,8 +253,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestBody final List metadataRest) { - final List created = softwareModuleManagement.createSoftwareModuleMetadata(softwareModuleId, - MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest)); + final List created = softwareModuleManagement.createSoftwareModuleMetadata( + softwareModuleId, MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest)); return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created)); } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java index 2e04118e7..82e9cddf4 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java @@ -73,7 +73,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes final List rest = MgmtSoftwareModuleTypeMapper .toTypesResponse(findModuleTypessAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, countModulesAll), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, countModulesAll)); } @Override @@ -81,14 +81,14 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { final SoftwareModuleType foundType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); - return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toResponse(foundType), HttpStatus.OK); + return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toResponse(foundType)); } @Override public ResponseEntity deleteSoftwareModuleType( @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { softwareModuleTypeManagement.deleteSoftwareModuleType(softwareModuleTypeId); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -96,11 +96,12 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId, @RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) { - final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement.updateSoftwareModuleType(entityFactory - .softwareModuleType().update(softwareModuleTypeId).description(restSoftwareModuleType.getDescription()) - .colour(restSoftwareModuleType.getColour())); + final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement + .updateSoftwareModuleType(entityFactory.softwareModuleType().update(softwareModuleTypeId) + .description(restSoftwareModuleType.getDescription()) + .colour(restSoftwareModuleType.getColour())); - return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toResponse(updatedSoftwareModuleType), HttpStatus.OK); + return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toResponse(updatedSoftwareModuleType)); } @Override diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java index 9d5f7fda3..977139295 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java @@ -57,7 +57,7 @@ public class MgmtSystemManagementResource implements MgmtSystemManagementRestApi @Override public ResponseEntity deleteTenant(@PathVariable("tenant") final String tenant) { systemManagement.deleteTenant(tenant); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } /** diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java index f77d4582e..0a846462e 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemResource.java @@ -60,9 +60,8 @@ public class MgmtSystemResource implements MgmtSystemRestApi { */ @Override public ResponseEntity> getSystemConfiguration() { - return new ResponseEntity<>( - MgmtSystemMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties), - HttpStatus.OK); + return ResponseEntity + .ok(MgmtSystemMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties)); } /** @@ -81,7 +80,7 @@ public class MgmtSystemResource implements MgmtSystemRestApi { tenantConfigurationManagement.deleteConfiguration(keyName); LOG.debug("{} config value deleted, return status {}", keyName, HttpStatus.OK); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return ResponseEntity.ok().build(); } /** @@ -99,9 +98,8 @@ public class MgmtSystemResource implements MgmtSystemRestApi { @PathVariable("keyName") final String keyName) { LOG.debug("{} config value getted, return status {}", keyName, HttpStatus.OK); - return new ResponseEntity<>( - MgmtSystemMapper.toResponse(keyName, tenantConfigurationManagement.getConfigurationValue(keyName)), - HttpStatus.OK); + return ResponseEntity + .ok(MgmtSystemMapper.toResponse(keyName, tenantConfigurationManagement.getConfigurationValue(keyName))); } /** @@ -123,7 +121,7 @@ public class MgmtSystemResource implements MgmtSystemRestApi { final TenantConfigurationValue updatedValue = tenantConfigurationManagement .addOrUpdateConfiguration(keyName, configurationValueRest.getValue()); - return new ResponseEntity<>(MgmtSystemMapper.toResponse(keyName, updatedValue), HttpStatus.OK); + return ResponseEntity.ok(MgmtSystemMapper.toResponse(keyName, updatedValue)); } } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java index 8adae8161..f9a669ba6 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java @@ -56,7 +56,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA // to single response include poll status final MgmtTargetFilterQuery response = MgmtTargetFilterQueryMapper.toResponse(findTarget); - return new ResponseEntity<>(response, HttpStatus.OK); + return ResponseEntity.ok(response); } @Override @@ -85,7 +85,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA final List rest = MgmtTargetFilterQueryMapper .toResponse(findTargetFiltersAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, countTargetsAll), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, countTargetsAll)); } @Override @@ -106,14 +106,14 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA .updateTargetFilterQuery(entityFactory.targetFilterQuery().update(filterId) .name(targetFilterRest.getName()).query(targetFilterRest.getQuery())); - return new ResponseEntity<>(MgmtTargetFilterQueryMapper.toResponse(updateFilter), HttpStatus.OK); + return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter)); } @Override public ResponseEntity deleteFilter(@PathVariable("filterId") final Long filterId) { filterManagement.deleteTargetFilterQuery(filterId); LOG.debug("{} target filter query deleted, return status {}", filterId, HttpStatus.OK); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -123,7 +123,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA final TargetFilterQuery updateFilter = filterManagement.updateTargetFilterQueryAutoAssignDS(filterId, dsId.getId()); - return new ResponseEntity<>(MgmtTargetFilterQueryMapper.toResponse(updateFilter), HttpStatus.OK); + return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter)); } @Override @@ -140,7 +140,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA public ResponseEntity deleteAssignedDistributionSet(@PathVariable("filterId") final Long filterId) { filterManagement.updateTargetFilterQueryAutoAssignDS(filterId, null); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return ResponseEntity.noContent().build(); } private TargetFilterQuery findFilterWithExceptionIfNotFound(final Long filterId) { diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java index 63aaaa7d2..883686466 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java @@ -24,13 +24,16 @@ import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; +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.repository.ActionFields; +import org.eclipse.hawkbit.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.builder.TargetCreate; import org.eclipse.hawkbit.repository.model.Action; +import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.PollStatus; import org.eclipse.hawkbit.repository.model.Target; @@ -175,13 +178,17 @@ public final class MgmtTargetMapper { .collect(Collectors.toList()); } - static MgmtAction toResponse(final String targetId, final Action action, final boolean isActive) { + static MgmtAction toResponse(final String targetId, final Action action) { final MgmtAction result = new MgmtAction(); result.setActionId(action.getId()); result.setType(getType(action)); + if (ActionType.TIMEFORCED.equals(action.getActionType())) { + result.setForceTime(action.getForcedTime()); + } + result.setForceType(MgmtRestModelMapper.convertActionType(action.getActionType())); - if (isActive) { + if (action.isActive()) { result.setStatus(MgmtAction.ACTION_PENDING); } else { result.setStatus(MgmtAction.ACTION_FINISHED); @@ -194,13 +201,32 @@ public final class MgmtTargetMapper { return result; } + static MgmtAction toResponseWithLinks(final String controllerId, final Action action) { + final MgmtAction result = toResponse(controllerId, action); + + if (action.isCancelingOrCanceled()) { + result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, action.getId())) + .withRel(MgmtRestConstants.TARGET_V1_CANCELED_ACTION)); + } else { + result.add(linkTo( + methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(action.getDistributionSet().getId())) + .withRel("distributionset")); + } + + result.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionStatusList(controllerId, action.getId(), 0, + MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, + ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)) + .withRel(MgmtRestConstants.TARGET_V1_ACTION_STATUS)); + + return result; + } + static List toResponse(final String targetId, final Collection actions) { if (actions == null) { return Collections.emptyList(); } - return actions.stream().map(action -> toResponse(targetId, action, action.isActive())) - .collect(Collectors.toList()); + return actions.stream().map(action -> toResponse(targetId, action)).collect(Collectors.toList()); } private static String getType(final Action action) { diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java index 7168014c2..aa91ff5a1 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java @@ -8,9 +8,6 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; - import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -18,26 +15,26 @@ import java.util.Map; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction; +import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionStatus; +import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtDistributionSetAssigment; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetAttributes; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody; -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.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.EntityFactory; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.TargetManagement; +import org.eclipse.hawkbit.repository.exception.ConstraintViolationException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.rest.data.SortDirection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -76,7 +73,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { MgmtTargetMapper.addPollStatus(findTarget, response); MgmtTargetMapper.addTargetLinks(response); - return new ResponseEntity<>(response, HttpStatus.OK); + return ResponseEntity.ok(response); } @Override @@ -103,7 +100,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } final List rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, countTargetsAll), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, countTargetsAll)); } @Override @@ -123,27 +120,27 @@ public class MgmtTargetResource implements MgmtTargetRestApi { .name(targetRest.getName()).description(targetRest.getDescription()).address(targetRest.getAddress()) .securityToken(targetRest.getSecurityToken())); - return new ResponseEntity<>(MgmtTargetMapper.toResponse(updateTarget), HttpStatus.OK); + return ResponseEntity.ok(MgmtTargetMapper.toResponse(updateTarget)); } @Override public ResponseEntity deleteTarget(@PathVariable("controllerId") final String controllerId) { this.targetManagement.deleteTarget(controllerId); LOG.debug("{} target deleted, return status {}", controllerId, HttpStatus.OK); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override public ResponseEntity getAttributes(@PathVariable("controllerId") final String controllerId) { final Map controllerAttributes = targetManagement.getControllerAttributes(controllerId); if (controllerAttributes.isEmpty()) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return ResponseEntity.noContent().build(); } final MgmtTargetAttributes result = new MgmtTargetAttributes(); result.putAll(controllerAttributes); - return new ResponseEntity<>(result, HttpStatus.OK); + return ResponseEntity.ok(result); } @Override @@ -171,10 +168,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { totalActionCount = this.deploymentManagement.countActionsByTarget(controllerId); } - return new ResponseEntity<>( - new PagedList<>(MgmtTargetMapper.toResponse(controllerId, activeActions.getContent()), - totalActionCount), - HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(controllerId, activeActions.getContent()), + totalActionCount)); } @Override @@ -185,26 +180,10 @@ public class MgmtTargetResource implements MgmtTargetRestApi { .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getControllerId().equals(controllerId)) { LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), controllerId); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } - final MgmtAction result = MgmtTargetMapper.toResponse(controllerId, action, action.isActive()); - - if (!action.isCancelingOrCanceled()) { - result.add(linkTo( - methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(action.getDistributionSet().getId())) - .withRel("distributionset")); - } else if (action.isCancelingOrCanceled()) { - result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, action.getId())) - .withRel(MgmtRestConstants.TARGET_V1_CANCELED_ACTION)); - } - - result.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionStatusList(controllerId, action.getId(), 0, - MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, - ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)) - .withRel(MgmtRestConstants.TARGET_V1_ACTION_STATUS)); - - return new ResponseEntity<>(result, HttpStatus.OK); + return ResponseEntity.ok(MgmtTargetMapper.toResponseWithLinks(controllerId, action)); } @Override @@ -216,7 +195,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { if (!action.getTarget().getControllerId().equals(controllerId)) { LOG.warn("given action ({}) is not assigned to given target ({}).", actionId, controllerId); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } if (force) { @@ -227,7 +206,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { // both functions will throw an exception, when action is in wrong // state, which is mapped by MgmtResponseExceptionHandler. - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return ResponseEntity.noContent().build(); } @Override @@ -244,7 +223,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { if (!action.getTarget().getId().equals(target.getId())) { LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), target.getId()); - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + return ResponseEntity.notFound().build(); } final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); @@ -254,9 +233,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi { final Page statusList = this.deploymentManagement.findActionStatusByAction( new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action.getId()); - return new ResponseEntity<>(new PagedList<>( + return ResponseEntity.ok(new PagedList<>( MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement), - statusList.getTotalElements()), HttpStatus.OK); + statusList.getTotalElements())); } @@ -267,9 +246,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi { .map(MgmtDistributionSetMapper::toResponse).orElse(null); if (distributionSetRest == null) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return ResponseEntity.noContent().build(); } - return new ResponseEntity<>(distributionSetRest, HttpStatus.OK); + return ResponseEntity.ok(distributionSetRest); } @Override @@ -282,7 +261,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { this.deploymentManagement.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), Arrays.asList(controllerId)); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override @@ -292,9 +271,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi { .map(MgmtDistributionSetMapper::toResponse).orElse(null); if (distributionSetRest == null) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return ResponseEntity.noContent().build(); } - return new ResponseEntity<>(distributionSetRest, HttpStatus.OK); + return ResponseEntity.ok(distributionSetRest); } private Target findTargetWithExceptionIfNotFound(final String controllerId) { @@ -302,4 +281,24 @@ public class MgmtTargetResource implements MgmtTargetRestApi { .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); } + @Override + public ResponseEntity updateAction(@PathVariable("controllerId") final String controllerId, + @PathVariable("actionId") final Long actionId, @RequestBody final MgmtActionRequestBodyPut actionUpdate) { + + Action action = deploymentManagement.findAction(actionId) + .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); + if (!action.getTarget().getControllerId().equals(controllerId)) { + LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), controllerId); + return ResponseEntity.notFound().build(); + } + + if (!MgmtActionType.FORCED.equals(actionUpdate.getForceType())) { + throw new ConstraintViolationException("Resource supports only switch to FORCED."); + } + + action = deploymentManagement.forceTargetAction(actionId); + + return ResponseEntity.ok(MgmtTargetMapper.toResponseWithLinks(controllerId, action)); + } + } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java index 98f8ca2da..0334f9f46 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java @@ -79,13 +79,13 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { } final List rest = MgmtTagMapper.toResponse(findTargetsAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, findTargetsAll.getTotalElements()), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, findTargetsAll.getTotalElements())); } @Override public ResponseEntity getTargetTag(@PathVariable("targetTagId") final Long targetTagId) { final TargetTag tag = findTargetTagById(targetTagId); - return new ResponseEntity<>(MgmtTagMapper.toResponse(tag), HttpStatus.OK); + return ResponseEntity.ok(MgmtTagMapper.toResponse(tag)); } @Override @@ -107,7 +107,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { LOG.debug("target tag updated"); - return new ResponseEntity<>(MgmtTagMapper.toResponse(updateTargetTag), HttpStatus.OK); + return ResponseEntity.ok(MgmtTagMapper.toResponse(updateTargetTag)); } @Override @@ -117,15 +117,15 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { this.tagManagement.deleteTargetTag(targetTag.getName()); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } @Override public ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) { - return new ResponseEntity<>(MgmtTargetMapper.toResponse(targetManagement + return ResponseEntity.ok(MgmtTargetMapper.toResponse(targetManagement .findTargetsByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId) - .getContent()), HttpStatus.OK); + .getContent())); } @Override @@ -151,7 +151,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { final Long countTargetsAll = findTargetsAll.getTotalElements(); final List rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent()); - return new ResponseEntity<>(new PagedList<>(rest, countTargetsAll), HttpStatus.OK); + return ResponseEntity.ok(new PagedList<>(rest, countTargetsAll)); } @Override @@ -167,7 +167,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { final MgmtTargetTagAssigmentResult tagAssigmentResultRest = new MgmtTargetTagAssigmentResult(); tagAssigmentResultRest.setAssignedTargets(MgmtTargetMapper.toResponse(assigmentResult.getAssignedEntity())); tagAssigmentResultRest.setUnassignedTargets(MgmtTargetMapper.toResponse(assigmentResult.getUnassignedEntity())); - return new ResponseEntity<>(tagAssigmentResultRest, HttpStatus.OK); + return ResponseEntity.ok(tagAssigmentResultRest); } @Override @@ -176,7 +176,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); final List assignedTarget = this.targetManagement .assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId); - return new ResponseEntity<>(MgmtTargetMapper.toResponse(assignedTarget), HttpStatus.OK); + return ResponseEntity.ok(MgmtTargetMapper.toResponse(assignedTarget)); } @Override @@ -184,7 +184,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { @PathVariable("controllerId") final String controllerId) { LOG.debug("Unassign target {} for target tag {}", controllerId, targetTagId); this.targetManagement.unAssignTag(controllerId, targetTagId); - return new ResponseEntity<>(HttpStatus.OK); + return ResponseEntity.ok().build(); } private TargetTag findTargetTagById(final Long targetTagId) { diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index e308fd496..b2ad73894 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -838,12 +838,14 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) - .andExpect(jsonPath("type", equalTo("cancel"))).andExpect(jsonPath("status", equalTo("pending"))) - .andExpect(jsonPath("_links.self.href", equalTo(generateActionSelfLink(knownTargetId, actions.get(0))))) + .andExpect(jsonPath("forceType", equalTo("forced"))).andExpect(jsonPath("type", equalTo("cancel"))) + .andExpect(jsonPath("status", equalTo("pending"))) + .andExpect(jsonPath("_links.self.href", + equalTo(generateActionSelfLink(knownTargetId, actions.get(0).getId())))) .andExpect(jsonPath("_links.canceledaction.href", equalTo(generateCanceledactionreferenceLink(knownTargetId, actions.get(0))))) .andExpect(jsonPath("_links.status.href", - equalTo(generateStatusreferenceLink(knownTargetId, actions.get(0))))); + equalTo(generateStatusreferenceLink(knownTargetId, actions.get(0).getId())))); } @Test @@ -859,12 +861,12 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest .andExpect(jsonPath("content.[1].type", equalTo("update"))) .andExpect(jsonPath("content.[1].status", equalTo("pending"))) .andExpect(jsonPath("content.[1]._links.self.href", - equalTo(generateActionSelfLink(knownTargetId, actions.get(1))))) + equalTo(generateActionSelfLink(knownTargetId, actions.get(1).getId())))) .andExpect(jsonPath("content.[0].id", equalTo(actions.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("cancel"))) .andExpect(jsonPath("content.[0].status", equalTo("pending"))) .andExpect(jsonPath("content.[0]._links.self.href", - equalTo(generateActionSelfLink(knownTargetId, actions.get(0))))) + equalTo(generateActionSelfLink(knownTargetId, actions.get(0).getId())))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(2))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(2))); @@ -1000,7 +1002,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest .andExpect(jsonPath("content.[0].type", equalTo("cancel"))) .andExpect(jsonPath("content.[0].status", equalTo("pending"))) .andExpect(jsonPath("content.[0]._links.self.href", - equalTo(generateActionSelfLink(knownTargetId, actions.get(0))))) + equalTo(generateActionSelfLink(knownTargetId, actions.get(0).getId())))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(1))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); @@ -1017,15 +1019,15 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest .andExpect(jsonPath("content.[0].type", equalTo("update"))) .andExpect(jsonPath("content.[0].status", equalTo("pending"))) .andExpect(jsonPath("content.[0]._links.self.href", - equalTo(generateActionSelfLink(knownTargetId, actions.get(1))))) + equalTo(generateActionSelfLink(knownTargetId, actions.get(1).getId())))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(1))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); } - private String generateActionSelfLink(final String knownTargetId, final Action action) { + private String generateActionSelfLink(final String knownTargetId, final Long actionId) { return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId; } private String generateCanceledactionreferenceLink(final String knownTargetId, final Action action) { @@ -1033,10 +1035,10 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId(); } - private String generateStatusreferenceLink(final String knownTargetId, final Action action) { + private String generateStatusreferenceLink(final String knownTargetId, final Long actionId) { return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS + "?offset=0&limit=50&sort=id:DESC"; + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/" + MgmtRestConstants.TARGET_V1_ACTION_STATUS + + "?offset=0&limit=50&sort=id:DESC"; } private List generateTargetWithTwoUpdatesWithOneOverride(final String knownTargetId) @@ -1074,12 +1076,41 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("type", equalTo("update"))).andExpect(jsonPath("status", equalTo("pending"))) - .andExpect(jsonPath("_links.self.href", equalTo(generateActionSelfLink(knownTargetId, actions.get(1))))) + .andExpect(jsonPath("forceType", equalTo("forced"))) + .andExpect(jsonPath("_links.self.href", + equalTo(generateActionSelfLink(knownTargetId, actions.get(1).getId())))) .andExpect(jsonPath("_links.distributionset.href", equalTo("http://localhost/rest/v1/distributionsets/" + actions.get(1).getDistributionSet().getId()))) .andExpect(jsonPath("_links.status.href", - equalTo(generateStatusreferenceLink(knownTargetId, actions.get(1))))); + equalTo(generateStatusreferenceLink(knownTargetId, actions.get(1).getId())))); + } + + @Test + @Description("Verfies that an action is switched from soft to forced if requested by management API") + public void updateAction() throws Exception { + final Target target = testdataFactory.createTarget(); + final DistributionSet set = testdataFactory.createDistributionSet(); + final Long actionId = deploymentManagement + .assignDistributionSet(set.getId(), ActionType.SOFT, 0, Arrays.asList(target.getControllerId())) + .getActions().get(0); + assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.SOFT); + + final String body = new JSONObject().put("forceType", "forced").toString(); + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId).content(body) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("id", equalTo(actionId.intValue()))).andExpect(jsonPath("type", equalTo("update"))) + .andExpect(jsonPath("status", equalTo("pending"))).andExpect(jsonPath("forceType", equalTo("forced"))) + .andExpect(jsonPath("_links.self.href", + equalTo(generateActionSelfLink(target.getControllerId(), actionId)))) + .andExpect(jsonPath("_links.distributionset.href", + equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) + .andExpect(jsonPath("_links.status.href", + equalTo(generateStatusreferenceLink(target.getControllerId(), actionId)))); + + assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.FORCED); } @Test @@ -1179,12 +1210,14 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest .andExpect(status().isNotFound()); // not allowed methods - mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isMethodNotAllowed()); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); + + // Invalid content + mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isUnsupportedMediaType()); } @Test diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 1ef1a8f11..18305f3a3 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -47,6 +47,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.MetaData; +import org.eclipse.hawkbit.repository.model.RepositoryModelConstants; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetWithActionType; @@ -236,8 +237,8 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { } protected DistributionSetAssignmentResult assignDistributionSet(final Long dsID, final String controllerId) { - return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, - ActionType.FORCED, org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME))); + return deploymentManagement.assignDistributionSet(dsID, Arrays.asList( + new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME))); } protected DistributionSetAssignmentResult assignDistributionSet(final DistributionSet pset, diff --git a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java index b81e6c2b5..421359115 100644 --- a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RestResourceConversionHelper.java @@ -144,7 +144,7 @@ public final class RestResourceConversionHelper { if (ranges.isEmpty() || ranges.get(0).equals(full)) { LOG.debug("filename ({}) results into a full request: ", artifact.getFilename()); handleFullFileRequest(artifact, response, file, controllerManagement, statusId, full); - result = new ResponseEntity<>(HttpStatus.OK); + result = ResponseEntity.ok().build(); } // standard range request else if (ranges.size() == 1) {