Remove deprecated (#2800)

* ActionFields.DETAILSTATUS removed and replaces with STATUS (so status is with changed semantic - not active but real status)
* MgmtAction.detailStatus removed and replaced with status (so status is with changed semantic - not active but real status)
* MgmtTargetTagRestApi.assignTargetsPut removed - use POST method
* ActionStatusFields.REPORTEDAT deprecation removed - it is a synonym of CREATEDAT but is part of timestamp/reported aspect while createdat is part of creted at/by
* MgmtDistributionSetRequestBodyPost.os/runtime/application is removed

and

* ActionStatusFields.TIMESTAMPT added

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-11-13 13:39:03 +02:00
committed by GitHub
parent 2c8118bf52
commit 62139055b0
30 changed files with 481 additions and 756 deletions

View File

@@ -20,10 +20,8 @@ import lombok.Getter;
public enum ActionFields implements QueryField {
ID("id"),
@Deprecated(since = "0.10.0", forRemoval = true) // use ACTIVE
STATUS("active"), // true if status is "pending", false if "finished", after removal, will deprecate DETAILSTATUS too and replace with STATUS
ACTIVE("active"), // true if st
DETAILSTATUS("status"), // real status
ACTIVE("active"),
STATUS("status"),
LASTSTATUSCODE("lastActionStatusCode"),
CREATEDAT("createdAt"),
CREATEDBY("createdBy"),
@@ -48,19 +46,4 @@ public enum ActionFields implements QueryField {
this.jpaEntityFieldName = jpaEntityFieldName;
this.subEntityAttributes = List.of(subEntityAttributes);
}
/**
* @deprecated since 0.10.0 - use {@link #ACTIVE} instead of {@link #STATUS}
*/
@Deprecated(since = "0.10.0", forRemoval = true) // remove together with STATUS (with active meaning)
public static Object convertStatusValue(final String value) {
final String trimmedValue = value.trim();
if (trimmedValue.equalsIgnoreCase("pending")) {
return true;
} else if (trimmedValue.equalsIgnoreCase("finished")) {
return false;
} else {
throw new IllegalArgumentException("field 'status' must be one of the following values {pending, finished}");
}
}
}

View File

@@ -18,9 +18,11 @@ import lombok.Getter;
public enum ActionStatusFields implements QueryField {
ID("id"),
@Deprecated
REPORTEDAT("createdAt"),
CREATEDAT("createdAt"),
// search fields in sync with entity specifics (timestamp & report time)
TIMESTAMP("timestamp"),
REPORTEDAT("createdAt"), // same as CREATEDAT
// fields for db records as in other fields - created at / by
CREATEDAT("createdAt"), // same as REPORTEDAT
CREATEDBY("createdBy");
private final String jpaEntityFieldName;

View File

@@ -494,8 +494,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
private static ActionStatusCreate generateActionCancelStatus(
final DdiActionFeedback feedback, final Target target, final Long actionId) {
final ActionStatusCreateBuilder actionStatusCreate = ActionStatusCreate.builder()
.actionId(actionId).occurredAt(feedback.getTimestamp());
final ActionStatusCreateBuilder actionStatusCreate = ActionStatusCreate.builder().actionId(actionId).timestamp(feedback.getTimestamp());
final List<String> messages = new ArrayList<>();
final Status status;
switch (feedback.getStatus().getExecution()) {
@@ -601,7 +600,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
private ActionStatusCreate generateUpdateStatus(final DdiActionFeedback feedback, final String controllerId, final Long actionId) {
final ActionStatusCreateBuilder actionStatusCreate = ActionStatusCreate.builder()
.actionId(actionId).occurredAt(feedback.getTimestamp());
.actionId(actionId).timestamp(feedback.getTimestamp());
final List<String> messages = new ArrayList<>();
if (!CollectionUtils.isEmpty(feedback.getStatus().getDetails())) {

View File

@@ -37,8 +37,8 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
"lastModifiedBy" : "bumlux",
"lastModifiedAt" : 1682408571265,
"type" : "update",
"active" : false,
"status" : "finished",
"detailStatus" : "finished",
"rollout" : 1,
"rolloutName" : "rollout",
"_links" : {
@@ -74,35 +74,15 @@ public class MgmtAction extends MgmtBaseEntity {
* API definition for action in canceling.
*/
public static final String ACTION_CANCEL = "cancel";
/**
* API definition for action completed.
*
* @deprecated since 0.10.0 will be removed together with status field
*/
@Deprecated(since = "0.10.0", forRemoval = true)
public static final String ACTION_FINISHED = "finished";
/**
* API definition for action still active.
*
* @deprecated since 0.10.0 will be removed together with status field
*/
@Deprecated(since = "0.10.0", forRemoval = true)
public static final String ACTION_PENDING = "pending";
@Schema(description = "ID of the action", example = "7")
private Long id;
@Schema(description = "Type of action", example = "update")
private String type;
/**
* @deprecated since 0.10.0 - use {@link #active} instead of {@link #status}
*/
@Deprecated(since = "0.10.0")
@Schema(description = "Status of action, use active", example = "finished", deprecated = true)
private String status;
@Schema(description = "Status of action")
@Schema(description = "If acton is active")
private boolean active;
@Schema(description = "Detailed status of action", example = "finished")
private String detailStatus;
@Schema(description = "Status of action")
private String status;
@Schema(example = "1691065903238")
private Long forceTime;
private MgmtActionType forceType;
@@ -117,8 +97,7 @@ public class MgmtAction extends MgmtBaseEntity {
@Schema(description = "The name of the rollout this action was created for", example = "rollout")
private String rolloutName;
@Schema(description = "(Optional) Code provided as part of the last status update that was sent by the device.",
example = "200")
@Schema(description = "(Optional) Code provided as part of the last status update that was sent by the device.", example = "200")
private Integer lastStatusCode;
@Schema(description = "If created by external system this field contains the external reference for the action")

View File

@@ -32,17 +32,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssi
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut {
// deprecated format from the times where os, application and runtime where statically defined
@Schema(hidden = true)
private MgmtSoftwareModuleAssignment os;
@Schema(hidden = true)
private MgmtSoftwareModuleAssignment runtime;
@Schema(hidden = true)
private MgmtSoftwareModuleAssignment application;
// deprecated format - END
private List<MgmtSoftwareModuleAssignment> modules;
@Schema(description = "The type of the distribution set", example = "test_default_ds_type")

View File

@@ -331,18 +331,6 @@ public interface MgmtTargetTagRestApi {
@RequestBody List<String> controllerIds,
@RequestParam(value = "onNotFoundPolicy", required = false, defaultValue = "FAIL") OnNotFoundPolicy onNotFoundPolicy);
/**
* @deprecated since 0.9.0, use {@link #assignTargets(Long, List, OnNotFoundPolicy)} (POST) instead.
*/
@Deprecated(forRemoval = true, since = "0.9.0")
@PutMapping(
value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> assignTargetsPut(
@PathVariable("targetTagId") Long targetTagId,
@RequestBody List<String> controllerIds,
@RequestParam(value = "onNotFoundPolicy", required = false, defaultValue = "FAIL") OnNotFoundPolicy onNotFoundPolicy);
/**
* Handles the DELETE request to unassign one target from the given tag id.
*

View File

@@ -18,7 +18,6 @@ import org.eclipse.hawkbit.mgmt.json.model.action.MgmtAction;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtActionMapper;
import org.eclipse.hawkbit.mgmt.rest.resource.util.LogUtility;
import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -47,9 +46,6 @@ public class MgmtActionResource implements MgmtActionRestApi {
public ResponseEntity<PagedList<MgmtAction>> getActions(
final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam,
final String representationModeParam) {
LogUtility.logDeprecated(rsqlParam != null && rsqlParam.contains("status")
? "Usage of getActions with RSQL that is up to modification: rsql=" + rsqlParam
: "Usage of getActions:result that is up to modification.");
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionSortParam(sortParam));
final Slice<Action> actions;
@@ -68,7 +64,6 @@ public class MgmtActionResource implements MgmtActionRestApi {
@Override
public ResponseEntity<MgmtAction> getAction(final Long actionId) {
LogUtility.logDeprecated("Usage of getActions:result that is up to modification.");
final Action action = deploymentManagement.findAction(actionId)
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));

View File

@@ -118,7 +118,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
public ResponseEntity<PagedList<MgmtDistributionSet>> getDistributionSets(
final String rsqlParam, final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) {
if (rsqlParam != null && rsqlParam.toLowerCase().contains("complete")) {
LogUtility.logDeprecated("Usage of MgmtDistributionSetResource.getActions with 'complete': 'complete' distribution set search field may be removed.");
LogUtility.logDeprecated("Usage of MgmtDistributionSetResource.getActions with 'complete': 'complete' distribution set search field is limited and may be removed.");
}
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<? extends DistributionSet> findDsPage;

View File

@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTagMapper;
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtTargetMapper;
import org.eclipse.hawkbit.mgmt.rest.resource.util.LogUtility;
import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TargetTagManagement;
@@ -158,13 +157,6 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
return ResponseEntity.ok().build();
}
@Override
public ResponseEntity<Void> assignTargetsPut(
final Long targetTagId, final List<String> controllerIds, final OnNotFoundPolicy onNotFoundPolicy) {
LogUtility.logDeprecated("Deprecated usage of assignTargetsPut. Use assignTargetsPut (POST) instead.");
return assignTargets(targetTagId, controllerIds, onNotFoundPolicy);
}
@Override
@AuditLog(entity = "TargetTag", type = AuditLog.Type.UPDATE, description = "Unassign Target From Target Tag")
public ResponseEntity<Void> unassignTarget(final Long targetTagId, final String controllerId) {

View File

@@ -59,15 +59,6 @@ public class MgmtDistributionSetMapper {
final String defaultDsKey, final Map<String, DistributionSetType> dsTypeKeyToDsType) {
return sets.stream().<DistributionSetManagement.Create> map(dsRest -> {
final Set<Long> modules = new HashSet<>();
if (dsRest.getOs() != null) {
modules.add(dsRest.getOs().getId());
}
if (dsRest.getApplication() != null) {
modules.add(dsRest.getApplication().getId());
}
if (dsRest.getRuntime() != null) {
modules.add(dsRest.getRuntime().getId());
}
if (dsRest.getModules() != null) {
dsRest.getModules().forEach(module -> modules.add(module.getId()));
}

View File

@@ -239,11 +239,8 @@ public final class MgmtTargetMapper {
action.getWeight().ifPresent(result::setWeight);
result.setForceType(MgmtRestModelMapper.convertActionType(action.getActionType()));
result.setStatus(action.isActive() ? MgmtAction.ACTION_PENDING : MgmtAction.ACTION_FINISHED);
result.setActive(action.isActive());
result.setDetailStatus(action.getStatus().toString().toLowerCase());
result.setStatus(action.getStatus().toString().toLowerCase());
action.getLastActionStatusCode().ifPresent(result::setLastStatusCode);
final Rollout rollout = action.getRollout();
@@ -365,7 +362,7 @@ public final class MgmtTargetMapper {
result.setMessages(messages);
result.setReportedAt(actionStatus.getCreatedAt());
result.setTimestamp(actionStatus.getOccurredAt());
result.setTimestamp(actionStatus.getTimestamp());
result.setId(actionStatus.getId());
result.setType(MgmtActionStatus.Type.forValue(actionStatus.getStatus().name()));
actionStatus.getCode().ifPresent(result::setCode);

View File

@@ -10,8 +10,11 @@
package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ACTION_V1_REQUEST_MAPPING;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_SEARCH;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
@@ -35,7 +38,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.ResultActions;
/**
@@ -84,32 +86,32 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
final String rsqlPendingStatus = "status==pending";
final String rsqlFinishedStatus = "status==finished";
final String rsqlPendingStatus = "active==true";
final String rsqlFinishedStatus = "active==false";
final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus;
// pending status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content[0].status", equalTo("pending")));
.andExpect(jsonPath("content[0].active", equalTo(true)));
// finished status none result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
.andExpect(jsonPath("size", equalTo(0)));
// pending or finished status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content[0].status", equalTo("pending")));
.andExpect(jsonPath("content[0].active", equalTo(true)));
}
@@ -122,34 +124,34 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
final String rsqlPendingStatus = "detailStatus==running";
final String rsqlFinishedStatus = "detailStatus==finished";
final String rsqlPendingStatus = "status==running";
final String rsqlFinishedStatus = "status==finished";
final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus;
// running status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content[0].detailStatus", equalTo("running")))
.andExpect(jsonPath("content[0].status", equalTo("pending")));
.andExpect(jsonPath("content[0].active", equalTo(true)))
.andExpect(jsonPath("content[0].status", equalTo("running")));
// finished status none result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
.andExpect(jsonPath("size", equalTo(0)));
// running or finished status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content[0].detailStatus", equalTo("running")))
.andExpect(jsonPath("content[0].status", equalTo("pending")));
.andExpect(jsonPath("content[0].active", equalTo(true)))
.andExpect(jsonPath("content[0].status", equalTo("running")));
}
/**
@@ -175,7 +177,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlExtRefNoMatch = "externalref==234extRef";
// pending status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -183,14 +185,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content[0].externalRef", equalTo(externalRefs.get(0))));
// finished status none result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefWildcard))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefWildcard))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(2)))
.andExpect(jsonPath("size", equalTo(2)));
// pending or finished status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefNoMatch))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefNoMatch))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
@@ -204,8 +206,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
void filterActionsByLastStatusCode() throws Exception {
// assign a distribution set to three targets
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsA,
testdataFactory.createTargets("target1", "target2", "target3"));
final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(
dsA, testdataFactory.createTargets("target1", "target2", "target3"));
final List<Action> actions = assignmentResult.getAssignedEntity();
assertThat(actions).hasSize(3);
@@ -216,7 +218,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify that one result is returned if the actions are filtered for status code 200
final String rsqlStatusCode = "lastStatusCode==200";
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -225,7 +227,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify no result is returned if we filter for a non-existing status code
final String rsqlWrongStatusCode = "lastStatusCode==999";
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
@@ -245,7 +247,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlDsVersion = "distributionSet.version==" + ds.getVersion();
final String rsqlDsId = "distributionSet.id==" + ds.getId();
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -254,25 +256,25 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content.[0]._links.distributionset.name",
equalTo(ds.getName() + ":" + ds.getVersion())));
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)));
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)));
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar"))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
.andExpect(jsonPath("size", equalTo(0)));
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -301,7 +303,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlRolloutName = "rollout.name==" + rollout.getName();
final String rsqlRolloutId = "rollout.id==" + rollout.getId();
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -311,15 +313,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath(
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content.[0]._links.target.name", equalTo(target1.getName())))
.andExpect(jsonPath(
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
.andExpect(jsonPath("content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
}
/**
@@ -364,7 +365,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final Action action0 = actions.get(0);
final Action action1 = actions.get(1);
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
@@ -373,8 +374,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify action 1
.andExpect(jsonPath("content.[1].id", equalTo(action1.getId().intValue())))
.andExpect(jsonPath("content.[1].type", equalTo("update")))
.andExpect(jsonPath("content.[1].status", equalTo("pending")))
.andExpect(jsonPath("content.[1].detailStatus", equalTo("running")))
.andExpect(jsonPath("content.[1].active", equalTo(true)))
.andExpect(jsonPath("content.[1].status", equalTo("running")))
.andExpect(jsonPath("content.[1]._links.self.href",
equalTo(generateActionLink(knownTargetId, action1.getId()))))
.andExpect(jsonPath("content.[1]._links.target.href", equalTo(generateTargetLink(knownTargetId))))
@@ -384,13 +385,12 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify action 0
.andExpect(jsonPath("content.[0].id", equalTo(action0.getId().intValue())))
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
.andExpect(jsonPath("content.[0].detailStatus", equalTo("canceling")))
.andExpect(jsonPath("content.[0].active", equalTo(true)))
.andExpect(jsonPath("content.[0].status", equalTo("canceling")))
.andExpect(jsonPath("content.[0]._links.self.href",
equalTo(generateActionLink(knownTargetId, action0.getId()))))
.andExpect(jsonPath("content.[0]._links.target.href", equalTo(generateTargetLink(knownTargetId))))
.andExpect(jsonPath("content.[0]._links.distributionset.href",
equalTo(generateDistributionSetLink(action0))))
.andExpect(jsonPath("content.[0]._links.distributionset.href", equalTo(generateDistributionSetLink(action0))))
// verify collection properties
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2)))
@@ -403,7 +403,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
*/
@Test
void getActionsWithEmptyResult() throws Exception {
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("size", equalTo(0)))
@@ -421,7 +421,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// page 1: one entry
final Action action0 = actions.get(0);
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
@@ -430,8 +430,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify action 0
.andExpect(jsonPath("content.[0].id", equalTo(action0.getId().intValue())))
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
.andExpect(jsonPath("content.[0].detailStatus", equalTo(action0.getStatus().toString().toLowerCase())))
.andExpect(jsonPath("content.[0].active", equalTo(true)))
.andExpect(jsonPath("content.[0].status", equalTo(action0.getStatus().toString().toLowerCase())))
.andExpect(jsonPath("content.[0]._links.self.href",
equalTo(generateActionLink(knownTargetId, action0.getId()))))
@@ -442,7 +442,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// page 2: one entry
final Action action1 = actions.get(1);
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
@@ -453,10 +453,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify action 1
.andExpect(jsonPath("content.[0].id", equalTo(action1.getId().intValue())))
.andExpect(jsonPath("content.[0].type", equalTo("update")))
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
.andExpect(jsonPath("content.[0].detailStatus", equalTo(action1.getStatus().toString().toLowerCase())))
.andExpect(jsonPath("content.[0]._links.self.href",
equalTo(generateActionLink(knownTargetId, action1.getId()))))
.andExpect(jsonPath("content.[0].active", equalTo(true)))
.andExpect(jsonPath("content.[0].status", equalTo(action1.getStatus().toString().toLowerCase())))
.andExpect(jsonPath("content.[0]._links.self.href", equalTo(generateActionLink(knownTargetId, action1.getId()))))
// verify collection properties
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2)))
@@ -474,12 +473,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
// not allowed methods
mvc.perform(post(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isMethodNotAllowed());
mvc.perform(put(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isMethodNotAllowed());
mvc.perform(post(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
mvc.perform(put(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
}
/**
@@ -492,7 +487,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
final Long actionId = actions.get(0).getId();
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + actionId))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + actionId))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue())));
@@ -503,9 +498,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
*/
@Test
void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception {
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + 101)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
}
@Test
@@ -514,20 +507,18 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
Action action1 = assignmentResults.get(0).getAssignedEntity().get(0);
Action action2 = assignmentResults.get(1).getAssignedEntity().get(0);
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// verify action 1
.andExpect(jsonPath("content.[0].id", equalTo(action1.getId().intValue())))
.andExpect(jsonPath("content.[1].id", equalTo(action2.getId().intValue())));
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
}
@@ -536,11 +527,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
void shouldSuccessfullyDeleteMultipleActions() throws Exception {
final List<DistributionSetAssignmentResult> assignmentResults = createTargetsAndPerformAssignment(4);
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// verify action 1
.andExpect(jsonPath("content.[0].id", equalTo(assignmentResults.get(0).getAssignedEntity().get(0).getId().intValue())))
.andExpect(jsonPath("content.[1].id", equalTo(assignmentResults.get(1).getAssignedEntity().get(0).getId().intValue())))
@@ -548,33 +537,31 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content.[3].id", equalTo(assignmentResults.get(3).getAssignedEntity().get(0).getId().intValue())));
final List<Long> actionIdsToDelete = new ArrayList<>();
long deletedActionId1 = assignmentResults.get(2).getAssignedEntity().get(0).getId();
final long deletedActionId1 = assignmentResults.get(2).getAssignedEntity().get(0).getId();
actionIdsToDelete.add(deletedActionId1);
long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId();
final long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId();
actionIdsToDelete.add(deletedActionId2);
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.content(toJson(actionIdsToDelete)).contentType(MediaType.APPLICATION_JSON))
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).content(toJson(actionIdsToDelete)).contentType(APPLICATION_JSON))
.andExpect(status().isOk());
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId2))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId2))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0);
String rsql = "target.name==" + deletedAction3.getTarget().getName();
final Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0);
final String rsql = "target.name==" + deletedAction3.getTarget().getName();
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, rsql).contentType(MediaType.APPLICATION_JSON))
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).param(REQUEST_PARAMETER_SEARCH, rsql).contentType(APPLICATION_JSON))
.andExpect(status().isOk());
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId()))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId()))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
}
@@ -582,14 +569,13 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
@Test
void shouldReceiveBadRequestWhenNeeded() throws Exception {
// bad request on both empty parameters
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest());
// bad request when both parameters are present
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "target.name==test")
.content(toJson(List.of(1,2,3)))
.contentType(MediaType.APPLICATION_JSON))
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)
.param(REQUEST_PARAMETER_SEARCH, "target.name==test")
.content(toJson(List.of(1, 2, 3)))
.contentType(APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@@ -623,15 +609,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter)
throws Exception {
// pending status one result
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter)
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content.[0]._links.target.name", equalTo(target.getName())))
.andExpect(jsonPath(
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
.andExpect(jsonPath("content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
}
private void getActions(final boolean withExternalRef) throws Exception {
@@ -650,26 +635,22 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
}
final ResultActions resultActions =
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// verify action 1
.andExpect(jsonPath("content.[1].id", equalTo(action1.getId().intValue())))
.andExpect(jsonPath("content.[1].type", equalTo("update")))
.andExpect(jsonPath("content.[1].status", equalTo("pending")))
.andExpect(jsonPath("content.[1].detailStatus", equalTo("running")))
.andExpect(jsonPath("content.[1].active", equalTo(true)))
.andExpect(jsonPath("content.[1].status", equalTo("running")))
.andExpect(jsonPath("content.[1]._links.self.href",
equalTo(generateActionLink(knownTargetId, action1.getId()))))
// verify action 0
.andExpect(jsonPath("content.[0].id", equalTo(action0.getId().intValue())))
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
.andExpect(jsonPath("content.[0].status", equalTo("pending")))
.andExpect(jsonPath("content.[1].detailStatus", equalTo("running")))
.andExpect(jsonPath("content.[0]._links.self.href",
equalTo(generateActionLink(knownTargetId, action0.getId()))))
.andExpect(jsonPath("content.[0].active", equalTo(true)))
.andExpect(jsonPath("content.[1].status", equalTo("running")))
.andExpect(jsonPath("content.[0]._links.self.href", equalTo(generateActionLink(knownTargetId, action0.getId()))))
// verify collection properties
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(2)))
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(2)))
@@ -700,10 +681,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
controllerManagement.updateActionExternalRef(actions.get(0).getId(), externalRef);
}
final ResultActions resultActions =
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
final ResultActions resultActions = mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
if (withExternalRef) {
resultActions.andExpect(jsonPath("externalRef", equalTo(externalRef)));

View File

@@ -284,7 +284,7 @@ public interface ControllerManagement {
* allowed number of action status messages from history; messageCount equal zero, does not retrieve any message; and messageCount larger
* than zero, retrieves the specified number of messages, limited by maximum allowed number. A controller sends the feedback for an
* {@link ActionStatus} as a list of messages; while returning the messages, even though the messages from multiple {@link ActionStatus}
* are retrieved in descending order by the reported time ({@link ActionStatus#getOccurredAt()}), i.e. latest ActionStatus first, the
* are retrieved in descending order by the reported time ({@link ActionStatus#getTimestamp()}), i.e. latest ActionStatus first, the
* sub-ordering of messages from within single {@link ActionStatus} is unspecified.
*
* @param actionId to be filtered on

View File

@@ -336,6 +336,6 @@ public interface Action extends TenantAwareBaseEntity {
private Integer code;
private Collection<@ValidString String> messages;
private Long occurredAt;
private Long timestamp;
}
}

View File

@@ -23,7 +23,7 @@ public interface ActionStatus extends TenantAwareBaseEntity {
/**
* @return time in {@link TimeUnit#MILLISECONDS} when the status was reported.
*/
long getOccurredAt();
long getTimestamp();
/**
* @return {@link Action} this {@link ActionStatus} belongs to.

View File

@@ -42,7 +42,6 @@ import cz.jirutka.rsql.parser.ast.OrNode;
import cz.jirutka.rsql.parser.ast.RSQLVisitor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.QueryField;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
@@ -298,9 +297,6 @@ public class JpaQueryRsqlVisitor<A extends Enum<A> & QueryField, T> extends Abst
if (javaType != null && javaType.isEnum()) {
return transformEnumValue(node, value, javaType);
}
if (fieldName == ActionFields.STATUS) {
return ActionFields.convertStatusValue(value);
}
if (Boolean.TYPE.equals(javaType)) {
return convertBooleanValue(node, value, javaType);

View File

@@ -40,7 +40,6 @@ import cz.jirutka.rsql.parser.ast.RSQLOperators;
import cz.jirutka.rsql.parser.ast.RSQLVisitor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.QueryField;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
@@ -365,10 +364,6 @@ public class JpaQueryRsqlVisitorG2<A extends Enum<A> & QueryField, T>
return toEnumValue(node, javaType, value);
}
if (enumValue == ActionFields.STATUS) {
return ActionFields.convertStatusValue(value);
}
if (boolean.class.equals(javaType) || Boolean.class.equals(javaType)) {
if ("true".equals(value) || "false".equals(value)) {
return Boolean.valueOf(value);

View File

@@ -22,7 +22,6 @@ import org.aopalliance.intercept.MethodInvocation;
import org.eclipse.hawkbit.artifact.encryption.ArtifactEncryption;
import org.eclipse.hawkbit.artifact.encryption.ArtifactEncryptionSecretsStorage;
import org.eclipse.hawkbit.artifact.encryption.ArtifactEncryptionService;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.AutoAssignExecutor;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.PropertiesQuotaManagement;
@@ -42,7 +41,6 @@ import org.eclipse.hawkbit.repository.event.ApplicationEventFilter;
import org.eclipse.hawkbit.repository.event.remote.EventEntityManager;
import org.eclipse.hawkbit.repository.event.remote.EventEntityManagerHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.jpa.acm.AccessController;
import org.eclipse.hawkbit.repository.jpa.aspects.ExceptionMappingAspectHandler;
import org.eclipse.hawkbit.repository.jpa.autocleanup.AutoActionCleanup;
@@ -478,39 +476,6 @@ public class JpaRepositoryConfiguration {
};
}
/**
* @deprecated since 0.10.0, will be removed in future releases. Use "active" for querying active status instead of "status".
*/
@Deprecated(since = "0.10.0", forRemoval = true)
@Bean
public NodeTransformer actionStatusTransformer() {
return new NodeTransformer.Abstract() {
// just extension points for subclasses
@Override
protected <T extends Enum<T> & QueryField> Object transformValueElement(
final Object value, final Comparison comparison, final Class<T> queryFieldType) {
return queryFieldType == (Class<?>) ActionFields.class && "active".equalsIgnoreCase(comparison.getKey())
? mapActionStatus(value)
: value;
}
private static Object mapActionStatus(final Object value) {
final String strValue = String.valueOf(value);
if ("true".equalsIgnoreCase(strValue) || "false".equalsIgnoreCase(strValue)) {
return value;
} else {
// handle custom action fields status
try {
return ActionFields.convertStatusValue(strValue);
} catch (final IllegalArgumentException e) {
throw new RSQLParameterUnsupportedFieldException(e.getMessage());
}
}
}
};
}
@Bean
@ConditionalOnMissingBean
QueryParser queryParser() {

View File

@@ -119,7 +119,7 @@ public abstract class AbstractDsAssignmentStrategy {
public JpaActionStatus createActionStatus(final JpaAction action, final String actionMessage) {
final JpaActionStatus actionStatus = new JpaActionStatus();
actionStatus.setAction(action);
actionStatus.setOccurredAt(action.getCreatedAt());
actionStatus.setTimestamp(action.getCreatedAt());
if (StringUtils.hasText(actionMessage)) {
actionStatus.addMessage(actionMessage);

View File

@@ -67,7 +67,7 @@ public class JpaActionManagement {
protected static JpaActionStatus buildJpaActionStatus(final ActionStatusCreate create) {
final JpaActionStatus actionStatus = new JpaActionStatus(
create.getStatus(),
Optional.ofNullable(create.getOccurredAt()).orElseGet(System::currentTimeMillis));
Optional.ofNullable(create.getTimestamp()).orElseGet(System::currentTimeMillis));
Optional.ofNullable(create.getMessages()).ifPresent(messages -> messages.forEach(actionStatus::addMessage));
actionStatus.setCode(create.getCode());
return actionStatus;

View File

@@ -209,7 +209,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
@Override
protected void onActionStatusUpdate(final JpaActionStatus newActionStatus, final JpaAction action) {
final Action.Status updatedActionStatus = newActionStatus.getStatus();
final long occurredAt = newActionStatus.getOccurredAt();
final long timestamp = newActionStatus.getTimestamp();
switch (updatedActionStatus) {
case ERROR: {
final JpaTarget target = action.getTarget();
@@ -218,7 +218,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
break;
}
case FINISHED: {
requestControllerAttributes(handleFinishedAndStoreInTargetStatus(occurredAt, action));
requestControllerAttributes(handleFinishedAndStoreInTargetStatus(timestamp, action));
break;
}
case DOWNLOADED: {
@@ -499,7 +499,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
? RepositoryConstants.MAX_ACTION_HISTORY_MSG_COUNT
: messageCount;
final PageRequest pageable = PageRequest.of(0, limit, Sort.by(Direction.DESC, "occurredAt"));
final PageRequest pageable = PageRequest.of(0, limit, Sort.by(Direction.DESC, "timestamp"));
final Page<String> messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(
actionId, RepositoryConstants.SERVER_MESSAGE_PREFIX + "%", pageable);
@@ -846,15 +846,15 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
* @param action updated action
* @return a present controllerId in case the attributes needs to be requested.
*/
private JpaTarget handleFinishedAndStoreInTargetStatus(final long occurredAt, final JpaAction action) {
private JpaTarget handleFinishedAndStoreInTargetStatus(final long timestamp, final JpaAction action) {
final JpaTarget target = action.getTarget();
action.setActive(false);
action.setStatus(Status.FINISHED);
if (target.getInstallationDate() == null || target.getInstallationDate() < occurredAt) {
if (target.getInstallationDate() == null || target.getInstallationDate() < timestamp) {
final JpaDistributionSet ds = entityManager.merge(action.getDistributionSet());
target.setInstalledDistributionSet(ds);
target.setInstallationDate(occurredAt);
target.setInstallationDate(timestamp);
// Target reported an installation of a DOWNLOAD_ONLY assignment, the assigned DS has to be adapted
// because the currently assigned DS can be unequal to the currently installed DS (the downloadOnly DS)

View File

@@ -1048,7 +1048,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
private void setSkipActionStatus(final JpaAction action) {
final JpaActionStatus actionStatus = new JpaActionStatus();
actionStatus.setAction(action);
actionStatus.setOccurredAt(action.getCreatedAt());
actionStatus.setTimestamp(action.getCreatedAt());
actionStatus.setStatus(Status.RUNNING);
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Distribution Set is already assigned. Skipping this action.");
actionStatusRepository.save(actionStatus);

View File

@@ -142,7 +142,7 @@ public class JpaDistributionSetManagement
DistributionSetFields.class));
}
if (completedComparison.get() != null) { // really a comparison
log.warn("Usage of 'complete' in RSQL is deprecated and will be removed in future: {}", node);
log.warn("Usage of 'complete' is limited and may be removed: {}", node);
final boolean completed = completeComparison(completedComparison);
return filter(JpaManagementHelper.findAllWithCountBySpec(jpaRepository, specList, pageable), completed);
}

View File

@@ -568,7 +568,7 @@ public class JpaRolloutManagement implements RolloutManagement {
JpaActionStatus actionStatus = new JpaActionStatus();
actionStatus.setAction(action);
actionStatus.setStatus(status);
actionStatus.setOccurredAt(currentTimestamp);
actionStatus.setTimestamp(currentTimestamp);
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "A " + typeOfCancellation + " has been performed by server.");
cancellingStatuses.add(actionStatus);
});

View File

@@ -60,7 +60,7 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
@Setter
@Getter
@Column(name = "target_occurred_at", nullable = false, updatable = false)
private long occurredAt;
private long timestamp;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(
@@ -97,12 +97,12 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
*
* @param action the action for this action status
* @param status the status for this action status
* @param occurredAt the occurred timestamp
* @param timestamp the occurred timestamp
*/
public JpaActionStatus(final Action action, final Status status, final long occurredAt) {
public JpaActionStatus(final Action action, final Status status, final long timestamp) {
this.action = (JpaAction) action;
this.status = status;
this.occurredAt = occurredAt;
this.timestamp = timestamp;
}
/**
@@ -110,13 +110,13 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
*
* @param action the action for this action status
* @param status the status for this action status
* @param occurredAt the occurred timestamp
* @param timestamp the occurred timestamp
* @param message the message which should be added to this action status
*/
public JpaActionStatus(final JpaAction action, final Status status, final long occurredAt, final String message) {
public JpaActionStatus(final JpaAction action, final Status status, final long timestamp, final String message) {
this.action = action;
this.status = status;
this.occurredAt = occurredAt;
this.timestamp = timestamp;
addMessage(message);
}
@@ -124,11 +124,11 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
* Creates a new {@link ActionStatus} object.
*
* @param status the status for this action status
* @param occurredAt the occurred timestamp
* @param timestamp the occurred timestamp
*/
public JpaActionStatus(final Status status, final long occurredAt) {
public JpaActionStatus(final Status status, final long timestamp) {
this.status = status;
this.occurredAt = occurredAt;
this.timestamp = timestamp;
}
@Override

View File

@@ -203,12 +203,12 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
final Long actionId = getFirstAssignedActionId(assignDistributionSet(testDs, testTarget));
controllerManagement.addUpdateActionStatus(ActionStatusCreate.builder().actionId(actionId)
.status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis()).messages(List.of("proceeding message 1"))
.status(Action.Status.RUNNING).timestamp(System.currentTimeMillis()).messages(List.of("proceeding message 1"))
.build());
waitNextMillis();
controllerManagement.addUpdateActionStatus(ActionStatusCreate.builder().actionId(actionId)
.status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis()).messages(List.of("proceeding message 2"))
.status(Action.Status.RUNNING).timestamp(System.currentTimeMillis()).messages(List.of("proceeding message 2"))
.build());
final List<String> messages = controllerManagement.getActionHistoryMessages(actionId, 2);
@@ -242,7 +242,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(actionId1).isNotNull();
final ActionStatusCreateBuilder status = ActionStatusCreate.builder().actionId(actionId1).status(Status.WARNING);
for (int i = 0; i < maxStatusEntries; i++) {
controllerManagement.addInformationalActionStatus(status.messages(List.of("Msg " + i)).occurredAt(System.currentTimeMillis()).build());
controllerManagement.addInformationalActionStatus(status.messages(List.of("Msg " + i)).timestamp(System.currentTimeMillis()).build());
}
final ActionStatusCreate actionStatusCreate = status.build();
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
@@ -254,7 +254,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(actionId2).isNotEqualTo(actionId1);
final ActionStatusCreateBuilder statusWarning = ActionStatusCreate.builder().actionId(actionId2).status(Status.WARNING);
for (int i = 0; i < maxStatusEntries; i++) {
controllerManagement.addUpdateActionStatus(statusWarning.messages(List.of("Msg " + i)).occurredAt(System.currentTimeMillis()).build());
controllerManagement.addUpdateActionStatus(statusWarning.messages(List.of("Msg " + i)).timestamp(System.currentTimeMillis()).build());
}
final ActionStatusCreate actionStatusCreateQE = statusWarning.build();
assertThatExceptionOfType(AssignmentQuotaExceededException.class)

View File

@@ -66,6 +66,20 @@ class RsqlActionFieldsTest extends AbstractJpaIntegrationTest {
assertRSQLQuery(ActionFields.ID.name() + "=in=(" + action.getId() + ",10000000)", 1);
assertRSQLQuery(ActionFields.ID.name() + "=out=(" + action.getId() + ",10000000)", 10);
}/**
* Test action by status
*/
@Test
void testFilterByParameterActive() {
assertRSQLQuery(ActionFields.ACTIVE.name() + "==" + true, 5);
assertRSQLQuery(ActionFields.ACTIVE.name() + "!=" + true, 6);
assertRSQLQuery(ActionFields.ACTIVE.name() + "=in=(" + true + ")", 5);
assertRSQLQuery(ActionFields.ACTIVE.name() + "=out=(" + true +")", 6);
final String rsql = ActionFields.ACTIVE.name() + "==true2";
assertThatExceptionOfType(QueryException.class)
.as("RSQLParameterUnsupportedFieldException because active cannot be compared with 'true2'")
.isThrownBy(() -> assertRSQLQuery(rsql, 5));
}
/**
@@ -73,14 +87,14 @@ class RsqlActionFieldsTest extends AbstractJpaIntegrationTest {
*/
@Test
void testFilterByParameterStatus() {
assertRSQLQuery(ActionFields.STATUS.name() + "==pending", 5);
assertRSQLQuery(ActionFields.STATUS.name() + "!=pending", 6);
assertRSQLQuery(ActionFields.STATUS.name() + "=in=(pending)", 5);
assertRSQLQuery(ActionFields.STATUS.name() + "=out=(pending)", 6);
assertRSQLQuery(ActionFields.STATUS.name() + "==" + Status.RUNNING, 5);
assertRSQLQuery(ActionFields.STATUS.name() + "!=" + Status.RUNNING, 6);
assertRSQLQuery(ActionFields.STATUS.name() + "=in=(" + Status.RUNNING + ")", 5);
assertRSQLQuery(ActionFields.STATUS.name() + "=out=(" + Status.RUNNING +")", 6);
final String rsql = ActionFields.STATUS.name() + "==true2";
final String rsql = ActionFields.STATUS.name() + "==not_a_status";
assertThatExceptionOfType(QueryException.class)
.as("RSQLParameterUnsupportedFieldException because status cannot be compared with 'true'")
.as("RSQLParameterUnsupportedFieldException because status cannot be compared with 'not_a_status'")
.isThrownBy(() -> assertRSQLQuery(rsql, 5));
}
@@ -99,7 +113,7 @@ class RsqlActionFieldsTest extends AbstractJpaIntegrationTest {
newAction.setActionType(ActionType.SOFT);
newAction.setDistributionSet(dsA);
newAction.setActive(active);
newAction.setStatus(Status.RUNNING);
newAction.setStatus(active ? Status.RUNNING : Status.FINISHED);
newAction.setTarget(target);
newAction.setWeight(45);
newAction.setInitiatedBy(tenantAware.getCurrentUsername());

View File

@@ -147,10 +147,6 @@ public final class SpPermission {
allPermissions.add(APPROVE_ROLLOUT);
allPermissions.add(HANDLE_ROLLOUT);
// coarse-grained - maybe to be deprecated
for (final String access_prefix : new String[] { CREATE_PREFIX, READ_PREFIX, UPDATE_PREFIX, DELETE_PREFIX }) {
allPermissions.add(access_prefix + "REPOSITORY");
}
allPermissions.add(TENANT_CONFIGURATION);
if (!tenant) {

View File

@@ -132,7 +132,7 @@ public class TargetActionsHistory extends Grid<TargetActionsHistory.ActionStatus
icon = Utils.tooltip(VaadinIcon.ADJUST.create(), "Pending Update");
icon.setColor("orange");
}// todo getDetailStatus should return an enum from src/main/java/org/eclipse/hawkbit/repository/model/Action.java
} else if (action.getType().equals(MgmtAction.ACTION_UPDATE) && action.getDetailStatus().equals("finished")) {
} else if (action.getType().equals(MgmtAction.ACTION_UPDATE) && action.getStatus().equals("finished")) {
icon = Utils.tooltip(VaadinIcon.CHECK_CIRCLE.create(), "Updated");
icon.setColor("green");
} else {