Adapt UI for target type compatibility check (#1189)

* Added compatibility calls needed for UI

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* Adapted UI for target type compatibility checks

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* improved exception handling for incompatibility check

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* added & fixed unit tests

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed merged conflicts

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed target type incompatibly specification

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* changed UI behaviour to close assignment popup in case of IncompatibleTargetTypeException

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* added unit test to validate incompatibly specification fix

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed review findings

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed review findings

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fix potential null pointer

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* Fixed rolloutcopy by adding dsTypeId to ProxyDistributionSetInfo

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* suppressed warning

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>
This commit is contained in:
Robert Sing
2021-10-22 16:23:25 +02:00
committed by GitHub
parent f94b4430e0
commit dea6fa3ce6
28 changed files with 473 additions and 347 deletions

View File

@@ -181,8 +181,8 @@ public interface RolloutManagement {
RolloutGroupConditions conditions);
/**
* Calculates how many targets are addressed by each rollout group and
* returns the validation information.
* Calculates how many targets are addressed by each rollout group and returns
* the validation information.
*
* @param groups
* a list of rollout groups
@@ -190,6 +190,8 @@ public interface RolloutManagement {
* the rollout
* @param createdAt
* timestamp when the rollout was created
* @param dsTypeId
* ID of the type of distribution set of the rollout
* @return the validation information
* @throws RolloutIllegalStateException
* thrown when no targets are targeted by the rollout
@@ -199,7 +201,7 @@ public interface RolloutManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
ListenableFuture<RolloutGroupsValidation> validateTargetsInGroups(@Valid List<RolloutGroupCreate> groups,
String targetFilter, Long createdAt);
String targetFilter, Long createdAt, @NotNull Long dsTypeId);
/**
* Retrieves all rollouts.

View File

@@ -102,8 +102,8 @@ public interface TargetManagement {
* @param selectTargetWithNoTag
* flag to select targets with no tag assigned
*
* @return the found number {@link Target}s
*
* @return the found number of {@link Target}s
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
*/
@@ -117,7 +117,7 @@ public interface TargetManagement {
* @param distId
* to search for
* @return number of found {@link Target}s.
*
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
*/
@@ -144,19 +144,33 @@ public interface TargetManagement {
*
* @param rsqlParam
* filter definition in RSQL syntax
* @return the found number {@link Target}s
* @return the found number of {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByRsql(@NotEmpty String rsqlParam);
/**
* Count all targets for given {@link TargetFilterQuery} and that are compatible
* with the passed {@link DistributionSetType}.
*
* @param rsqlParam
* filter definition in RSQL syntax
* @param dsTypeId
* ID of the {@link DistributionSetType} the targets need to be
* compatible with
* @return the found number of{@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByRsqlAndCompatible(@NotEmpty String rsqlParam, @NotNull Long dsTypeId);
/**
* Count {@link TargetFilterQuery}s for given target filter query.
*
* @param targetFilterQueryId
* {@link TargetFilterQuery#getId()}
* @return the found number {@link Target}s
*
* @throws EntityNotFoundException
* @return the found number of {@link Target}s
*
* @throws EntityNotFoundException
* if {@link TargetFilterQuery} with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)

View File

@@ -1,52 +0,0 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.exception;
import java.util.Collection;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TargetType;
/**
* the {@link DistributionSetTypeNotInTargetTypeException} is thrown when a
* {@link DistributionSetType} is requested as part of a {@link TargetType} but
* is not returned in {@link TargetType#getCompatibleDistributionSetTypes()}.
*/
public class DistributionSetTypeNotInTargetTypeException extends EntityNotFoundException {
private static final long serialVersionUID = 1L;
/**
* Constructor
*
* @param distributionSetTypeId
* that is not compatible with given {@link TargetType}s
* @param targetTypeIds
* of the {@link TargetType}s where given {@link DistributionSetType}
* is not part of
*/
public DistributionSetTypeNotInTargetTypeException(final Long distributionSetTypeId,
final Collection<Long> targetTypeIds) {
super("DistributionSetType " + distributionSetTypeId + " is not compatible to TargetTypes " + targetTypeIds);
}
/**
* Constructor
*
* @param distributionSetTypeIds
* that are not compatible with given {@link TargetType}
* @param targetTypeId
* of the {@link TargetType} where given {@link DistributionSetType}s
* are not part of
*/
public DistributionSetTypeNotInTargetTypeException(final Collection<Long> distributionSetTypeIds,
final Long targetTypeId) {
super("DistributionSetTypes " + distributionSetTypeIds + " are not compatible to TargetTypes " + targetTypeId);
}
}

View File

@@ -0,0 +1,71 @@
/**
* Copyright (c) 2021 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.exception;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetType;
/**
* Thrown if user tries to assign a {@link DistributionSet} to a {@link Target}
* that has an incompatible {@link TargetType}
*/
public class IncompatibleTargetTypeException extends AbstractServerRtException {
private static final long serialVersionUID = 1L;
private final Collection<String> targetTypeNames;
private final Collection<String> distributionSetTypeNames;
/**
* Creates a new IncompatibleTargetTypeException with
* {@link SpServerError#SP_TARGET_TYPE_INCOMPATIBLE} error.
*
* @param targetTypeName
* Name of the target type
* @param distributionSetTypeNames
* Names of the distribution set types
*/
public IncompatibleTargetTypeException(final String targetTypeName,
final Collection<String> distributionSetTypeNames) {
super(String.format("Target of type %s is not compatible with distribution set of types %s", targetTypeName,
distributionSetTypeNames), SpServerError.SP_TARGET_TYPE_INCOMPATIBLE);
this.targetTypeNames = Collections.singleton(targetTypeName);
this.distributionSetTypeNames = distributionSetTypeNames;
}
/**
* Creates a new IncompatibleTargetTypeException with
* {@link SpServerError#SP_TARGET_TYPE_INCOMPATIBLE} error.
*
* @param targetTypeNames
* Name of the target types
* @param distributionSetTypeName
* Name of the distribution set type
*/
public IncompatibleTargetTypeException(final Collection<String> targetTypeNames,
final String distributionSetTypeName) {
super(String.format("Targets of types %s are not compatible with distribution set of type %s", targetTypeNames,
distributionSetTypeName), SpServerError.SP_TARGET_TYPE_INCOMPATIBLE);
this.targetTypeNames = targetTypeNames;
this.distributionSetTypeNames = Collections.singleton(distributionSetTypeName);
}
public Collection<String> getTargetTypeNames() {
return targetTypeNames;
}
public Collection<String> getDistributionSetTypeNames() {
return distributionSetTypeNames;
}
}