Move deprecated repository and mgmt rest methods in separate module (#2177)

Some already deprecated management REST methods are moved in separate module (together with used only for them repository api and impl) in order to have cleanly separate deprecatd REST API.
The new module is hawkbit-mgmt-resource-deprecated. It is inculded, by default, in hawkbit-mgmt-stater.
* when we decide to remove the deprecated REST API implementation completely - will be easily remved - just module and refs
* deprecated REST API could be excluded (by removing the module from runtime) even before that for the runtimes.
* after removal, for some time (untill the usad management and repository APIs are compatible) it will be possible to refer (and include) the deprecated method implementation together with the next hawkBit versions.

The deprecated methods are:
* POST /rest/v1/distributionsettags/{distributionsetTagId}/assigned/toggleTagAssignment
* POST /rest/v1/distributionsettags/{distributionsetTagId}/assigned
* POST /rest/v1/targettags/{targetTagId}/assigned/toggleTagAssignment
* POST /rest/v1/targettags/{targetTagId}/assigned

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-09 11:04:39 +02:00
committed by GitHub
parent 3fde9604f4
commit d2799f4bbc
31 changed files with 816 additions and 671 deletions

View File

@@ -32,7 +32,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Statistic;
@@ -384,33 +383,4 @@ public interface DistributionSetManagement extends RepositoryManagement<Distribu
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countAutoAssignmentsForDistributionSet(@NotNull Long id);
/**
* Toggles {@link DistributionSetTag} assignment to given
* {@link DistributionSet}s by means that if some (or all) of the targets in
* the list have the {@link org.eclipse.hawkbit.repository.model.Tag} not yet assigned, they will be. Only if all
* of theme have the tag already assigned they will be removed instead.
*
* @param ids to toggle for
* @param tagName to toggle
* @return {@link DistributionSetTagAssignmentResult} with all meta data of the assignment outcome.
* @throws EntityNotFoundException if given tag does not exist or (at least one) module
* @deprecated since 0.6.0 in favor of assign/unassign
*/
@Deprecated(forRemoval = true)
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Long> ids, @NotNull String tagName);
/**
* Unassign a {@link DistributionSetTag} assignment to given {@link DistributionSet}.
*
* @param id to unassign for
* @param tagId to unassign
* @return the unassigned ds or <null> if no ds is unassigned
* @throws EntityNotFoundException if set or tag with given ID does not exist
* @deprecated since 0.6.0 in favor of unassignTag(List<Long>, long)
*/
@Deprecated(forRemoval = true)
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSet unassignTag(long id, long tagId);
}

View File

@@ -33,12 +33,10 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetMetadata;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.TargetTypeAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
@@ -756,33 +754,4 @@ public interface TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
TargetMetadata updateMetadata(@NotEmpty String controllerId, @NotNull MetaData metadata);
/**
* Toggles {@link TargetTag} assignment to given {@link Target}s by means that
* if some (or all) of the targets in the list have the {@link Tag} not yet
* assigned, they will be. Only if all of them have the tag already assigned
* they will be removed instead.
*
* @param controllerIds to toggle for
* @param tagName to toggle
* @return TagAssigmentResult with all metadata of the assignment outcome.
* @throws EntityNotFoundException if tag with given name does not exist
* @deprecated since 0.6.0 - not very usable with very unclear logic
*/
@Deprecated(forRemoval = true, since = "0.6.0")
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> controllerIds, @NotEmpty String tagName);
/**
* Un-assign a {@link TargetTag} assignment to given {@link Target}.
*
* @param controllerId to un-assign for
* @param targetTagId to un-assign
* @return the unassigned target or <null> if no target is unassigned
* @throws EntityNotFoundException if TAG with given ID does not exist
* @deprecated since 0.6.0 - use {@link #unassignTag(Collection, long)} (List, long)} instead
*/
@Deprecated(forRemoval = true, since = "0.6.0")
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Target unassignTag(@NotEmpty String controllerId, long targetTagId);
}

View File

@@ -12,6 +12,8 @@ package org.eclipse.hawkbit.repository.model;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
/**
* Generic assignment result bean.
*
@@ -19,71 +21,35 @@ import java.util.List;
*/
public abstract class AbstractAssignmentResult<T extends BaseEntity> {
@Getter
private final int alreadyAssigned;
private final List<? extends T> assignedEntity;
private final List<? extends T> unassignedEntity;
/**
* Constructor.
*
* @param alreadyAssigned count of already assigned entities
* @param assignedEntity {@link List} of assigned entity.
* @param unassignedEntity {@link List} of unassigned entity.
*/
protected AbstractAssignmentResult(final int alreadyAssigned, final List<? extends T> assignedEntity,
final List<? extends T> unassignedEntity) {
protected AbstractAssignmentResult(
final int alreadyAssigned, final List<? extends T> assignedEntity, final List<? extends T> unassignedEntity) {
this.alreadyAssigned = alreadyAssigned;
this.assignedEntity = assignedEntity;
this.unassignedEntity = unassignedEntity;
}
/**
* @return number of newly assigned elements.
*/
public int getAssigned() {
return getAssignedEntity().size();
}
/**
* @return total number (assigned and already assigned).
*/
public int getTotal() {
return getAssigned() + alreadyAssigned;
}
/**
* @return number of already assigned/ignored elements.
*/
public int getAlreadyAssigned() {
return alreadyAssigned;
}
/**
* @return number of unsassigned elements
*/
public int getUnassigned() {
return getUnassignedEntity().size();
}
/**
* @return {@link List} of assigned entity.
*/
public List<T> getAssignedEntity() {
if (assignedEntity == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(assignedEntity);
return assignedEntity == null ? Collections.emptyList() : Collections.unmodifiableList(assignedEntity);
}
/**
* @return {@link List} of unassigned entity.
*/
public List<T> getUnassignedEntity() {
if (unassignedEntity == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(unassignedEntity);
return unassignedEntity == null ? Collections.emptyList() : Collections.unmodifiableList(unassignedEntity);
}
}

View File

@@ -1,45 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.model;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
/**
* Result object for {@link DistributionSetTag} assignments.
*
* @deprecated since 0.6.0 with toggle deprecation
*/
@Deprecated(forRemoval = true, since = "0.6.0")
@Getter
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DistributionSetTagAssignmentResult extends AbstractAssignmentResult<DistributionSet> {
private final DistributionSetTag distributionSetTag;
/**
* Constructor.
*
* @param alreadyAssigned number of already assigned/ignored elements
* @param assigned newly assigned elements
* @param unassigned unassigned elements
* @param distributionSetTag the assigned or unassigned tag
*/
public DistributionSetTagAssignmentResult(final int alreadyAssigned,
final List<DistributionSet> assigned, final List<DistributionSet> unassigned,
final DistributionSetTag distributionSetTag) {
super(alreadyAssigned, assigned, unassigned);
this.distributionSetTag = distributionSetTag;
}
}

View File

@@ -1,44 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.model;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
/**
* Result object for {@link TargetTag} assignments.
*
* @deprecated since 0.6.0 with deprecation of toggle assignments
*/
@Deprecated(forRemoval = true, since = "0.6.0")
@Getter
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TargetTagAssignmentResult extends AbstractAssignmentResult<Target> {
private final TargetTag targetTag;
/**
* Constructor.
*
* @param alreadyAssigned count of already assigned (ignored) elements
* @param assigned {@link List} of assigned {@link Target}s.
* @param unassigned {@link List} of unassigned {@link Target}s.
* @param targetTag the assigned or unassigned tag
*/
public TargetTagAssignmentResult(final int alreadyAssigned, final List<? extends Target> assigned,
final List<? extends Target> unassigned, final TargetTag targetTag) {
super(alreadyAssigned, assigned, unassigned);
this.targetTag = targetTag;
}
}