Set DdiActionFeedback ID deprecated (#1091)
* Deprecate DdiActionFeedback ID Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io> * Add deprecation to FEEDBACK_ACTION_ID in docu Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io>
This commit is contained in:
committed by
GitHub
parent
f19c3e5ff6
commit
bacd72f40c
@@ -37,6 +37,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DdiActionFeedback {
|
||||
/**
|
||||
* @deprecated
|
||||
* This ID is always given by the actionId path variable.
|
||||
* Will be removed in future versions.
|
||||
*/
|
||||
@Deprecated
|
||||
private final Long id;
|
||||
private final String time;
|
||||
|
||||
|
||||
@@ -351,13 +351,6 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
if (!actionId.equals(feedback.getId())) {
|
||||
LOG.warn(
|
||||
"provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).",
|
||||
feedback.getId(), actionId);
|
||||
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());
|
||||
@@ -370,7 +363,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
return new ResponseEntity<>(HttpStatus.GONE);
|
||||
}
|
||||
|
||||
controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, controllerId, feedback.getId()));
|
||||
controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, controllerId, actionId));
|
||||
|
||||
return ResponseEntity.ok().build();
|
||||
|
||||
@@ -501,13 +494,6 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
if (!actionId.equals(feedback.getId())) {
|
||||
LOG.warn(
|
||||
"provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).",
|
||||
feedback.getId(), actionId);
|
||||
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());
|
||||
@@ -515,7 +501,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
}
|
||||
|
||||
controllerManagement
|
||||
.addCancelActionStatus(generateActionCancelStatus(feedback, target, feedback.getId(), entityFactory));
|
||||
.addCancelActionStatus(generateActionCancelStatus(feedback, target, actionId, entityFactory));
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
|
||||
@@ -523,18 +523,6 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
.content(JsonBuilder.cancelActionFeedback("sdfsdfsdfs", "closed"))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest());
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
|
||||
.content(JsonBuilder.cancelActionFeedback("1234", "closed"))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
// right action but for wrong target
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
|
||||
.content(JsonBuilder.cancelActionFeedback(cancelAction2.getId().toString(), "closed"))
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
// finally get it right :)
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
|
||||
@@ -26,7 +26,7 @@ final class DdiApiModelProperties {
|
||||
|
||||
static final String TARGET_RESULT_FINISHED = "defined status of the result";
|
||||
|
||||
static final String TARGET_RESULT_PROGRESS = "progress assumption of the device";
|
||||
static final String TARGET_RESULT_PROGRESS = "progress assumption of the device (currently not supported).";
|
||||
|
||||
static final String TARGET_PROGRESS_CNT = "current progress level";
|
||||
|
||||
@@ -34,6 +34,8 @@ final class DdiApiModelProperties {
|
||||
|
||||
static final String ACTION_ID = "id of the action";
|
||||
|
||||
static final String FEEDBACK_ACTION_ID = "(@deprecated) id of the action";
|
||||
|
||||
static final String CANCEL_ACTION = "action that needs to be canceled";
|
||||
|
||||
static final String ACTION_ID_CANCELED = "id of the action that needs to be canceled (typically identical to id field on the cancel action itself)";
|
||||
|
||||
@@ -183,7 +183,7 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
|
||||
pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT),
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID),
|
||||
parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID_CANCELED)),
|
||||
requestFields(optionalRequestFieldWithPath("id").description(DdiApiModelProperties.ACTION_ID),
|
||||
requestFields(optionalRequestFieldWithPath("id").description(DdiApiModelProperties.FEEDBACK_ACTION_ID),
|
||||
requestFieldWithPath("status").description(DdiApiModelProperties.TARGET_STATUS),
|
||||
requestFieldWithPath("status.execution")
|
||||
.description(DdiApiModelProperties.TARGET_EXEC_STATUS).type("enum")
|
||||
@@ -386,7 +386,7 @@ public class RootControllerDocumentationTest extends AbstractApiRestDocumentatio
|
||||
parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID),
|
||||
parameterWithName("actionId").description(DdiApiModelProperties.ACTION_ID)),
|
||||
|
||||
requestFields(optionalRequestFieldWithPath("id").description(DdiApiModelProperties.ACTION_ID),
|
||||
requestFields(optionalRequestFieldWithPath("id").description(DdiApiModelProperties.FEEDBACK_ACTION_ID),
|
||||
requestFieldWithPath("status").description(DdiApiModelProperties.TARGET_STATUS),
|
||||
requestFieldWithPath("status.execution")
|
||||
.description(DdiApiModelProperties.TARGET_EXEC_STATUS).type("enum")
|
||||
|
||||
Reference in New Issue
Block a user