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

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