Complete field constraint documentation in repository API (#565)

* Document constraints in builders.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Completed constraint documentation in repository API

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix typo.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-08-02 13:10:28 +02:00
committed by GitHub
parent e2ca4cf840
commit 4dc0093d8b
38 changed files with 339 additions and 97 deletions

View File

@@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -55,6 +56,9 @@ public interface ControllerManagement {
* per entry are inserted * per entry are inserted
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if given action does not exist * if given action does not exist
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link ActionStatusCreate} for field constraints.
* *
*/ */
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
@@ -74,6 +78,9 @@ public interface ControllerManagement {
* per entry are inserted * per entry are inserted
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if given action does not exist * if given action does not exist
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link ActionStatusCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
ActionStatus addInformationalActionStatus(@NotNull ActionStatusCreate create); ActionStatus addInformationalActionStatus(@NotNull ActionStatusCreate create);
@@ -91,9 +98,11 @@ public interface ControllerManagement {
* @throws QuotaExceededException * @throws QuotaExceededException
* if more than the allowed number of status entries or messages * if more than the allowed number of status entries or messages
* per entry are inserted * per entry are inserted
*
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if action status not exist * if action status not exist
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link ActionStatusCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Action addUpdateActionStatus(@NotNull ActionStatusCreate create); Action addUpdateActionStatus(@NotNull ActionStatusCreate create);

View File

@@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -111,6 +112,9 @@ public interface DistributionSetManagement {
* @throws DistributionSetCreationFailedMissingMandatoryModuleException * @throws DistributionSetCreationFailedMissingMandatoryModuleException
* is {@link DistributionSet} does not contain mandatory * is {@link DistributionSet} does not contain mandatory
* {@link SoftwareModule}s. * {@link SoftwareModule}s.
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link DistributionSetCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
DistributionSet createDistributionSet(@NotNull DistributionSetCreate create); DistributionSet createDistributionSet(@NotNull DistributionSetCreate create);
@@ -148,6 +152,9 @@ public interface DistributionSetManagement {
* @throws DistributionSetCreationFailedMissingMandatoryModuleException * @throws DistributionSetCreationFailedMissingMandatoryModuleException
* is {@link DistributionSet} does not contain mandatory * is {@link DistributionSet} does not contain mandatory
* {@link SoftwareModule}s. * {@link SoftwareModule}s.
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link DistributionSetCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<DistributionSet> createDistributionSets(@NotNull Collection<DistributionSetCreate> creates); List<DistributionSet> createDistributionSets(@NotNull Collection<DistributionSetCreate> creates);
@@ -529,6 +536,9 @@ public interface DistributionSetManagement {
* @throws EntityReadOnlyException * @throws EntityReadOnlyException
* if user tries to change requiredMigrationStep or type on a DS * if user tries to change requiredMigrationStep or type on a DS
* that is already assigned to targets * that is already assigned to targets
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link DistributionSetUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSet updateDistributionSet(@NotNull DistributionSetUpdate update); DistributionSet updateDistributionSet(@NotNull DistributionSetUpdate update);

View File

@@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -46,6 +47,9 @@ public interface DistributionSetTypeManagement {
* if a provided linked entity does not exists ( * if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or * {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()} * {@link DistributionSetType#getOptionalModuleTypes()}
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link DistributionSetTypeCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
DistributionSetType createDistributionSetType(@NotNull DistributionSetTypeCreate create); DistributionSetType createDistributionSetType(@NotNull DistributionSetTypeCreate create);
@@ -61,6 +65,9 @@ public interface DistributionSetTypeManagement {
* if a provided linked entity does not exists ( * if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or * {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()} * {@link DistributionSetType#getOptionalModuleTypes()}
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link DistributionSetTypeCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetTypeCreate> creates); List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetTypeCreate> creates);
@@ -161,6 +168,9 @@ public interface DistributionSetTypeManagement {
* if the {@link DistributionSetType} is already in use by a * if the {@link DistributionSetType} is already in use by a
* {@link DistributionSet} and user tries to change list of * {@link DistributionSet} and user tries to change list of
* {@link SoftwareModuleType}s * {@link SoftwareModuleType}s
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link DistributionSetTypeUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType updateDistributionSetType(@NotNull DistributionSetTypeUpdate update); DistributionSetType updateDistributionSetType(@NotNull DistributionSetTypeUpdate update);

View File

@@ -121,7 +121,7 @@ public interface RolloutManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if given {@link DistributionSet} does not exist * if given {@link DistributionSet} does not exist
* @throws ConstraintViolationException * @throws ConstraintViolationException
* if rollout or group parameters are invalid * if rollout or group parameters are invalid.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
Rollout createRollout(@NotNull RolloutCreate create, int amountGroup, @NotNull RolloutGroupConditions conditions); Rollout createRollout(@NotNull RolloutCreate create, int amountGroup, @NotNull RolloutGroupConditions conditions);
@@ -174,6 +174,9 @@ public interface RolloutManagement {
* @return the validation information * @return the validation information
* @throws RolloutIllegalStateException * @throws RolloutIllegalStateException
* thrown when no targets are targeted by the rollout * thrown when no targets are targeted by the rollout
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link RolloutGroupCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
ListenableFuture<RolloutGroupsValidation> validateTargetsInGroups(List<RolloutGroupCreate> groups, ListenableFuture<RolloutGroupsValidation> validateTargetsInGroups(List<RolloutGroupCreate> groups,

View File

@@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -71,11 +72,14 @@ public interface SoftwareModuleManagement {
* @param creates * @param creates
* {@link SoftwareModule}s to create * {@link SoftwareModule}s to create
* @return SoftwareModule * @return SoftwareModule
*
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if a given entity already exists * if a given entity already exists
*
* @throws EntityNotFoundException * @throws EntityNotFoundException
* of given software module type does not exist * of given software module type does not exist
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link SoftwareModuleCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModuleCreate> creates); List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModuleCreate> creates);
@@ -85,11 +89,14 @@ public interface SoftwareModuleManagement {
* @param create * @param create
* SoftwareModule to create * SoftwareModule to create
* @return SoftwareModule * @return SoftwareModule
*
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if a given entity already exists * if a given entity already exists
*
* @throws EntityNotFoundException * @throws EntityNotFoundException
* of given software module type does not exist * of given software module type does not exist
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link SoftwareModuleCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModule createSoftwareModule(@NotNull SoftwareModuleCreate create); SoftwareModule createSoftwareModule(@NotNull SoftwareModuleCreate create);
@@ -407,7 +414,10 @@ public interface SoftwareModuleManagement {
* @return the saved Entity. * @return the saved Entity.
* *
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if fiven {@link SoftwareModule} does not exist * if given {@link SoftwareModule} does not exist
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link SoftwareModuleUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModule updateSoftwareModule(@NotNull SoftwareModuleUpdate update); SoftwareModule updateSoftwareModule(@NotNull SoftwareModuleUpdate update);

View File

@@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -44,6 +45,10 @@ public interface SoftwareModuleTypeManagement {
* @param creates * @param creates
* to create * to create
* @return created Entity * @return created Entity
*
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link SoftwareModuleTypeCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleTypeCreate> creates); List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleTypeCreate> creates);
@@ -54,6 +59,10 @@ public interface SoftwareModuleTypeManagement {
* @param create * @param create
* to create * to create
* @return created Entity * @return created Entity
*
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link SoftwareModuleTypeCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleTypeCreate create); SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleTypeCreate create);
@@ -137,6 +146,9 @@ public interface SoftwareModuleTypeManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* in case the {@link SoftwareModuleType} does not exists and * in case the {@link SoftwareModuleType} does not exists and
* cannot be updated * cannot be updated
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link SoftwareModuleTypeUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleTypeUpdate update); SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleTypeUpdate update);

View File

@@ -12,6 +12,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -51,8 +52,12 @@ public interface TagManagement {
* @param create * @param create
* to be created. * to be created.
* @return the new {@link DistributionSet} * @return the new {@link DistributionSet}
*
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if distributionSetTag already exists * if distributionSetTag already exists
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TagCreate} for field constraints.
* *
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
@@ -64,8 +69,12 @@ public interface TagManagement {
* @param creates * @param creates
* to be created * to be created
* @return the new {@link DistributionSetTag} * @return the new {@link DistributionSetTag}
*
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if a given entity already exists * if a given entity already exists
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TagCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<DistributionSetTag> createDistributionSetTags(@NotNull Collection<TagCreate> creates); List<DistributionSetTag> createDistributionSetTags(@NotNull Collection<TagCreate> creates);
@@ -80,6 +89,9 @@ public interface TagManagement {
* *
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if given object already exists * if given object already exists
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TagCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
TargetTag createTargetTag(@NotNull TagCreate create); TargetTag createTargetTag(@NotNull TagCreate create);
@@ -93,6 +105,9 @@ public interface TagManagement {
* *
* @throws EntityAlreadyExistsException * @throws EntityAlreadyExistsException
* if given object has already an ID. * if given object has already an ID.
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TagCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
List<TargetTag> createTargetTags(@NotNull Collection<TagCreate> creates); List<TargetTag> createTargetTags(@NotNull Collection<TagCreate> creates);
@@ -261,6 +276,9 @@ public interface TagManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* in case the {@link DistributionSetTag} does not exists and * in case the {@link DistributionSetTag} does not exists and
* cannot be updated * cannot be updated
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TagUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetTag updateDistributionSetTag(@NotNull TagUpdate update); DistributionSetTag updateDistributionSetTag(@NotNull TagUpdate update);
@@ -275,6 +293,9 @@ public interface TagManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* in case the {@link TargetTag} does not exists and cannot be * in case the {@link TargetTag} does not exists and cannot be
* updated * updated
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TagUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetTag updateTargetTag(@NotNull TagUpdate update); TargetTag updateTargetTag(@NotNull TagUpdate update);

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository;
import java.util.Optional; import java.util.Optional;
import javax.validation.ConstraintViolationException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -35,6 +36,9 @@ public interface TargetFilterQueryManagement {
* @param create * @param create
* to create * to create
* @return the created {@link TargetFilterQuery} * @return the created {@link TargetFilterQuery}
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TargetFilterQueryCreate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
TargetFilterQuery createTargetFilterQuery(@NotNull TargetFilterQueryCreate create); TargetFilterQuery createTargetFilterQuery(@NotNull TargetFilterQueryCreate create);
@@ -188,6 +192,9 @@ public interface TargetFilterQueryManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if either {@link TargetFilterQuery} and/or autoAssignDs are * if either {@link TargetFilterQuery} and/or autoAssignDs are
* provided but not found * provided but not found
* @throws ConstraintViolationException
* if fields are not filled as specified. Check
* {@link TargetFilterQueryUpdate} for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQueryUpdate update); TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQueryUpdate update);

View File

@@ -11,10 +11,14 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.hibernate.validator.constraints.NotEmpty; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
/** /**
* Builder to create a new {@link DistributionSet} entry. Defines all fields * Builder to create a new {@link DistributionSet} entry. Defines all fields
@@ -29,28 +33,28 @@ public interface DistributionSetCreate {
* for {@link DistributionSet#getName()} * for {@link DistributionSet#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetCreate name(@NotEmpty String name); DistributionSetCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param version * @param version
* for {@link DistributionSet#getVersion()} * for {@link DistributionSet#getVersion()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetCreate version(@NotEmpty String version); DistributionSetCreate version(@Size(min = 1, max = NamedVersionedEntity.VERSION_MAX_SIZE) @NotNull String version);
/** /**
* @param description * @param description
* for {@link DistributionSet#getDescription()} * for {@link DistributionSet#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetCreate description(String description); DistributionSetCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param typeKey * @param typeKey
* for {@link DistributionSet#getType()} * for {@link DistributionSet#getType()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetCreate type(@NotEmpty String typeKey); DistributionSetCreate type(@Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE) @NotNull String typeKey);
/** /**
* @param type * @param type

View File

@@ -12,10 +12,13 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to create a new {@link DistributionSetType} entry. Defines all fields * Builder to create a new {@link DistributionSetType} entry. Defines all fields
@@ -30,28 +33,28 @@ public interface DistributionSetTypeCreate {
* for {@link DistributionSetType#getKey()} * for {@link DistributionSetType#getKey()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetTypeCreate key(@NotEmpty String key); DistributionSetTypeCreate key(@Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE) @NotNull String key);
/** /**
* @param name * @param name
* for {@link DistributionSetType#getName()} * for {@link DistributionSetType#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetTypeCreate name(@NotEmpty String name); DistributionSetTypeCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link DistributionSetType#getDescription()} * for {@link DistributionSetType#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetTypeCreate description(String description); DistributionSetTypeCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param colour * @param colour
* for {@link DistributionSetType#getColour()} * for {@link DistributionSetType#getColour()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetTypeCreate colour(String colour); DistributionSetTypeCreate colour(@Size(max = DistributionSetType.COLOUR_MAX_SIZE) String colour);
/** /**
* @param mandatory * @param mandatory

View File

@@ -10,7 +10,10 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Collection; import java.util.Collection;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.NamedEntity;
/** /**
* Builder to update an existing {@link DistributionSetType} entry. Defines all * Builder to update an existing {@link DistributionSetType} entry. Defines all
@@ -24,14 +27,14 @@ public interface DistributionSetTypeUpdate {
* for {@link DistributionSetType#getDescription()} * for {@link DistributionSetType#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetTypeUpdate description(String description); DistributionSetTypeUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param colour * @param colour
* for {@link DistributionSetType#getColour()} * for {@link DistributionSetType#getColour()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetTypeUpdate colour(String colour); DistributionSetTypeUpdate colour(@Size(max = DistributionSetType.COLOUR_MAX_SIZE) String colour);
/** /**
* @param mandatory * @param mandatory

View File

@@ -10,9 +10,13 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.hibernate.validator.constraints.NotEmpty; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
/** /**
* Builder to update an existing {@link DistributionSet} entry. Defines all * Builder to update an existing {@link DistributionSet} entry. Defines all
@@ -25,28 +29,28 @@ public interface DistributionSetUpdate {
* for {@link DistributionSet#getName()} * for {@link DistributionSet#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetUpdate name(@NotEmpty String name); DistributionSetUpdate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param version * @param version
* for {@link DistributionSet#getVersion()} * for {@link DistributionSet#getVersion()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetUpdate version(@NotEmpty String version); DistributionSetUpdate version(@Size(min = 1, max = NamedVersionedEntity.VERSION_MAX_SIZE) @NotNull String version);
/** /**
* @param description * @param description
* for {@link DistributionSet#getDescription()} * for {@link DistributionSet#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetUpdate description(String description); DistributionSetUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param typeKey * @param typeKey
* for {@link DistributionSet#getType()} * for {@link DistributionSet#getType()}
* @return updated builder instance * @return updated builder instance
*/ */
DistributionSetUpdate type(@NotEmpty String typeKey); DistributionSetUpdate type(@Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE) @NotNull String typeKey);
/** /**
* @param type * @param type

View File

@@ -11,12 +11,14 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.hibernate.validator.constraints.NotEmpty; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
/** /**
* Builder to create a new {@link Rollout} entry. Defines all fields that can be * Builder to create a new {@link Rollout} entry. Defines all fields that can be
@@ -30,14 +32,14 @@ public interface RolloutCreate {
* for {@link Rollout#getName()} * for {@link Rollout#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutCreate name(@NotEmpty String name); RolloutCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link Rollout#getDescription()} * for {@link Rollout#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutCreate description(String description); RolloutCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param set * @param set
@@ -60,7 +62,8 @@ public interface RolloutCreate {
* for {@link Rollout#getTargetFilterQuery()} * for {@link Rollout#getTargetFilterQuery()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutCreate targetFilterQuery(@NotEmpty String targetFilterQuery); RolloutCreate targetFilterQuery(
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) @NotNull String targetFilterQuery);
/** /**
* @param actionType * @param actionType

View File

@@ -8,12 +8,16 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
import org.hibernate.validator.constraints.NotEmpty; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
/** /**
* Builder to create a new {@link RolloutGroup} entry. Defines all fields that * Builder to create a new {@link RolloutGroup} entry. Defines all fields that
@@ -27,21 +31,22 @@ public interface RolloutGroupCreate {
* for {@link Rollout#getName()} * for {@link Rollout#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutGroupCreate name(@NotEmpty String name); RolloutGroupCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link Rollout#getDescription()} * for {@link Rollout#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutGroupCreate description(String description); RolloutGroupCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param targetFilterQuery * @param targetFilterQuery
* for {@link Rollout#getTargetFilterQuery()} * for {@link Rollout#getTargetFilterQuery()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutGroupCreate targetFilterQuery(@NotEmpty String targetFilterQuery); RolloutGroupCreate targetFilterQuery(
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) @NotNull String targetFilterQuery);
/** /**
* @param targetPercentage * @param targetPercentage

View File

@@ -9,10 +9,11 @@
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to update an existing {@link Rollout} entry. Defines all fields that * Builder to update an existing {@link Rollout} entry. Defines all fields that
@@ -25,14 +26,14 @@ public interface RolloutUpdate {
* for {@link Rollout#getName()} * for {@link Rollout#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutUpdate name(@NotEmpty String name); RolloutUpdate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link Rollout#getDescription()} * for {@link Rollout#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
RolloutUpdate description(String description); RolloutUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param setId * @param setId

View File

@@ -10,10 +10,14 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to create a new {@link SoftwareModule} entry. Defines all fields that * Builder to create a new {@link SoftwareModule} entry. Defines all fields that
@@ -27,35 +31,35 @@ public interface SoftwareModuleCreate {
* for {@link SoftwareModule#getName()} * for {@link SoftwareModule#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleCreate name(@NotEmpty String name); SoftwareModuleCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param version * @param version
* for {@link SoftwareModule#getVersion()} * for {@link SoftwareModule#getVersion()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleCreate version(@NotEmpty String version); SoftwareModuleCreate version(@Size(min = 1, max = NamedVersionedEntity.VERSION_MAX_SIZE) @NotNull String version);
/** /**
* @param description * @param description
* for {@link SoftwareModule#getDescription()} * for {@link SoftwareModule#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleCreate description(String description); SoftwareModuleCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param vendor * @param vendor
* for {@link SoftwareModule#getVendor()} * for {@link SoftwareModule#getVendor()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleCreate vendor(String vendor); SoftwareModuleCreate vendor(@Size(max = SoftwareModule.VENDOR_MAX_SIZE) String vendor);
/** /**
* @param typeKey * @param typeKey
* for {@link SoftwareModule#getType()} * for {@link SoftwareModule#getType()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleCreate type(@NotEmpty String typeKey); SoftwareModuleCreate type(@Size(min = 1, max = SoftwareModuleType.KEY_MAX_SIZE) @NotNull String typeKey);
/** /**
* @param type * @param type

View File

@@ -8,9 +8,12 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to create a new {@link SoftwareModuleType} entry. Defines all fields * Builder to create a new {@link SoftwareModuleType} entry. Defines all fields
@@ -24,28 +27,28 @@ public interface SoftwareModuleTypeCreate {
* for {@link SoftwareModuleType#getKey()} * for {@link SoftwareModuleType#getKey()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleTypeCreate key(@NotEmpty String key); SoftwareModuleTypeCreate key(@Size(min = 1, max = SoftwareModuleType.KEY_MAX_SIZE) @NotNull String key);
/** /**
* @param name * @param name
* for {@link SoftwareModuleType#getName()} * for {@link SoftwareModuleType#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleTypeCreate name(@NotEmpty String name); SoftwareModuleTypeCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link SoftwareModuleType#getDescription()} * for {@link SoftwareModuleType#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleTypeCreate description(String description); SoftwareModuleTypeCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param colour * @param colour
* for {@link SoftwareModuleType#getColour()} * for {@link SoftwareModuleType#getColour()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleTypeCreate colour(String colour); SoftwareModuleTypeCreate colour(@Size(max = SoftwareModuleType.COLOUR_MAX_SIZE) String colour);
/** /**
* @param maxAssignments * @param maxAssignments

View File

@@ -8,6 +8,9 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
/** /**
@@ -21,12 +24,12 @@ public interface SoftwareModuleTypeUpdate {
* for {@link SoftwareModuleType#getDescription()} * for {@link SoftwareModuleType#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleTypeUpdate description(String description); SoftwareModuleTypeUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param colour * @param colour
* for {@link SoftwareModuleType#getColour()} * for {@link SoftwareModuleType#getColour()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleTypeUpdate colour(String colour); SoftwareModuleTypeUpdate colour(@Size(max = SoftwareModuleType.COLOUR_MAX_SIZE) String colour);
} }

View File

@@ -8,6 +8,9 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
/** /**
@@ -22,12 +25,12 @@ public interface SoftwareModuleUpdate {
* for {@link SoftwareModule#getDescription()} * for {@link SoftwareModule#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleUpdate description(String description); SoftwareModuleUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param vendor * @param vendor
* for {@link SoftwareModule#getVendor()} * for {@link SoftwareModule#getVendor()}
* @return updated builder instance * @return updated builder instance
*/ */
SoftwareModuleUpdate vendor(String vendor); SoftwareModuleUpdate vendor(@Size(max = SoftwareModule.VENDOR_MAX_SIZE) String vendor);
} }

View File

@@ -8,9 +8,12 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Tag;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to create a new {@link Tag} entry. Defines all fields that can be set * Builder to create a new {@link Tag} entry. Defines all fields that can be set
@@ -24,21 +27,21 @@ public interface TagCreate {
* for {@link Tag#getName()} * for {@link Tag#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
TagCreate name(@NotEmpty String name); TagCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link Tag#getDescription()} * for {@link Tag#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
TagCreate description(String description); TagCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param colour * @param colour
* for {@link Tag#getColour()} * for {@link Tag#getColour()}
* @return updated builder instance * @return updated builder instance
*/ */
TagCreate colour(String colour); TagCreate colour(@Size(max = Tag.COLOUR_MAX_SIZE) String colour);
/** /**
* @return peek on current state of {@link Tag} in the builder * @return peek on current state of {@link Tag} in the builder

View File

@@ -8,8 +8,11 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Tag;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to update an existing {@link Tag} entry. Defines all fields that can * Builder to update an existing {@link Tag} entry. Defines all fields that can
@@ -22,20 +25,20 @@ public interface TagUpdate {
* for {@link Tag#getName()} * for {@link Tag#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
TagUpdate name(@NotEmpty String name); TagUpdate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param description * @param description
* for {@link Tag#getDescription()} * for {@link Tag#getDescription()}
* @return updated builder instance * @return updated builder instance
*/ */
TagUpdate description(String description); TagUpdate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
/** /**
* @param colour * @param colour
* for {@link Tag#getColour()} * for {@link Tag#getColour()}
* @return updated builder instance * @return updated builder instance
*/ */
TagUpdate colour(String colour); TagUpdate colour(@Size(max = Tag.COLOUR_MAX_SIZE) String colour);
} }

View File

@@ -10,10 +10,13 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to create a new {@link TargetFilterQuery} entry. Defines all fields * Builder to create a new {@link TargetFilterQuery} entry. Defines all fields
@@ -27,14 +30,14 @@ public interface TargetFilterQueryCreate {
* of {@link TargetFilterQuery#getName()} * of {@link TargetFilterQuery#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
TargetFilterQueryCreate name(@NotEmpty String name); TargetFilterQueryCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
/** /**
* @param query * @param query
* of {@link TargetFilterQuery#getQuery()} * of {@link TargetFilterQuery#getQuery()}
* @return updated builder instance * @return updated builder instance
*/ */
TargetFilterQueryCreate query(@NotEmpty String query); TargetFilterQueryCreate query(@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) @NotNull String query);
/** /**
* @param set * @param set

View File

@@ -8,8 +8,10 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Builder to update an existing {@link TargetFilterQuery} entry. Defines all * Builder to update an existing {@link TargetFilterQuery} entry. Defines all
@@ -22,13 +24,13 @@ public interface TargetFilterQueryUpdate {
* of {@link TargetFilterQuery#getName()} * of {@link TargetFilterQuery#getName()}
* @return updated builder instance * @return updated builder instance
*/ */
TargetFilterQueryUpdate name(@NotEmpty String name); TargetFilterQueryUpdate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) String name);
/** /**
* @param query * @param query
* of {@link TargetFilterQuery#getQuery()} * of {@link TargetFilterQuery#getQuery()}
* @return updated builder instance * @return updated builder instance
*/ */
TargetFilterQueryUpdate query(@NotEmpty String query); TargetFilterQueryUpdate query(@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) String query);
} }

View File

@@ -19,6 +19,15 @@ import java.util.Set;
* *
*/ */
public interface DistributionSetType extends NamedEntity { public interface DistributionSetType extends NamedEntity {
/**
* Maximum length of key.
*/
int KEY_MAX_SIZE = 64;
/**
* Maximum length of colour in Management UI.
*/
int COLOUR_MAX_SIZE = 16;
/** /**
* @return <code>true</code> if the type is deleted and only kept for * @return <code>true</code> if the type is deleted and only kept for

View File

@@ -8,9 +8,6 @@
*/ */
package org.eclipse.hawkbit.repository.model; package org.eclipse.hawkbit.repository.model;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/** /**
* Entities that have a name and description. * Entities that have a name and description.
* *
@@ -19,23 +16,20 @@ public interface NamedEntity extends TenantAwareBaseEntity {
/** /**
* Maximum length of name. * Maximum length of name.
*/ */
public static final int NAME_MAX_SIZE = 64; int NAME_MAX_SIZE = 64;
/** /**
* Maximum length of description. * Maximum length of description.
*/ */
public static final int DESCRIPTION_MAX_SIZE = 512; int DESCRIPTION_MAX_SIZE = 512;
/** /**
* @return the description of the entity. * @return the description of the entity.
*/ */
@Size(max = DESCRIPTION_MAX_SIZE)
String getDescription(); String getDescription();
/** /**
* @return the name of the entity. * @return the name of the entity.
*/ */
@Size(min = 1, max = NAME_MAX_SIZE)
@NotNull
String getName(); String getName();
} }

View File

@@ -13,6 +13,11 @@ package org.eclipse.hawkbit.repository.model;
* *
*/ */
public interface NamedVersionedEntity extends NamedEntity { public interface NamedVersionedEntity extends NamedEntity {
/**
* Maximum length of version.
*/
int VERSION_MAX_SIZE = 64;
/** /**
* @return the version of entity. * @return the version of entity.
*/ */

View File

@@ -16,6 +16,10 @@ import java.util.Optional;
* *
*/ */
public interface SoftwareModule extends NamedVersionedEntity { public interface SoftwareModule extends NamedVersionedEntity {
/**
* Maximum length of software vendor.
*/
int VENDOR_MAX_SIZE = 256;
/** /**
* @param artifactId * @param artifactId

View File

@@ -15,6 +15,15 @@ package org.eclipse.hawkbit.repository.model;
* *
*/ */
public interface SoftwareModuleType extends NamedEntity { public interface SoftwareModuleType extends NamedEntity {
/**
* Maximum length of key.
*/
int KEY_MAX_SIZE = 64;
/**
* Maximum length of colour in Management UI.
*/
int COLOUR_MAX_SIZE = 16;
/** /**
* @return business key of this {@link SoftwareModuleType}. * @return business key of this {@link SoftwareModuleType}.

View File

@@ -13,6 +13,10 @@ package org.eclipse.hawkbit.repository.model;
* *
*/ */
public interface Tag extends NamedEntity { public interface Tag extends NamedEntity {
/**
* Maximum length of colour in Management UI.
*/
int COLOUR_MAX_SIZE = 16;
/** /**
* @return colour code of the tag used in Management UI. * @return colour code of the tag used in Management UI.

View File

@@ -23,17 +23,17 @@ public interface Target extends NamedEntity {
/** /**
* Maximum length of controllerId. * Maximum length of controllerId.
*/ */
public static final int CONTROLLER_ID_MAX_SIZE = 64; int CONTROLLER_ID_MAX_SIZE = 64;
/** /**
* Maximum length of securityToken. * Maximum length of securityToken.
*/ */
public static final int SECURITY_TOKEN_MAX_SIZE = 128; int SECURITY_TOKEN_MAX_SIZE = 128;
/** /**
* Maximum length of address. * Maximum length of address.
*/ */
public static final int ADDRESS_MAX_SIZE = 512; int ADDRESS_MAX_SIZE = 512;
/** /**
* @return business identifier of the {@link Target} * @return business identifier of the {@link Target}

View File

@@ -33,6 +33,10 @@ package org.eclipse.hawkbit.repository.model;
* *
*/ */
public interface TargetFilterQuery extends TenantAwareBaseEntity { public interface TargetFilterQuery extends TenantAwareBaseEntity {
/**
* Maximum length of query filter string.
*/
int QUERY_MAX_SIZE = 1024;
/** /**
* @return name of the {@link TargetFilterQuery}. * @return name of the {@link TargetFilterQuery}.

View File

@@ -10,11 +10,11 @@ package org.eclipse.hawkbit.repository.jpa.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity; import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Extension for {@link NamedEntity} that are versioned. * Extension for {@link NamedEntity} that are versioned.
@@ -27,9 +27,9 @@ import org.hibernate.validator.constraints.NotEmpty;
public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEntity implements NamedVersionedEntity { public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEntity implements NamedVersionedEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "version", nullable = false, length = 64) @Column(name = "version", nullable = false, length = NamedVersionedEntity.VERSION_MAX_SIZE)
@Size(max = 64) @Size(min = 1, max = NamedVersionedEntity.VERSION_MAX_SIZE)
@NotEmpty @NotNull
private String version; private String version;
/** /**

View File

@@ -22,6 +22,7 @@ import javax.persistence.Index;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -29,7 +30,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.persistence.annotations.CascadeOnDelete; import org.eclipse.persistence.annotations.CascadeOnDelete;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@@ -54,13 +54,13 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
CascadeType.PERSIST }, fetch = FetchType.EAGER, orphanRemoval = true) CascadeType.PERSIST }, fetch = FetchType.EAGER, orphanRemoval = true)
private Set<DistributionSetTypeElement> elements; private Set<DistributionSetTypeElement> elements;
@Column(name = "type_key", nullable = false, updatable = false, length = 64) @Column(name = "type_key", nullable = false, updatable = false, length = DistributionSetType.KEY_MAX_SIZE)
@Size(max = 64) @Size(min = 1, max = DistributionSetType.KEY_MAX_SIZE)
@NotEmpty @NotNull
private String key; private String key;
@Column(name = "colour", nullable = true, length = 16) @Column(name = "colour", nullable = true, length = DistributionSetType.COLOUR_MAX_SIZE)
@Size(max = 16) @Size(max = DistributionSetType.COLOUR_MAX_SIZE)
private String colour; private String colour;
@Column(name = "deleted") @Column(name = "deleted")

View File

@@ -77,8 +77,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Column(name = "deleted") @Column(name = "deleted")
private boolean deleted; private boolean deleted;
@Column(name = "vendor", nullable = true, length = 256) @Column(name = "vendor", nullable = true, length = SoftwareModule.VENDOR_MAX_SIZE)
@Size(max = 256) @Size(max = SoftwareModule.VENDOR_MAX_SIZE)
private String vendor; private String vendor;
@CascadeOnDelete @CascadeOnDelete

View File

@@ -14,10 +14,10 @@ import javax.persistence.Index;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
/** /**
* Type of a software modules. * Type of a software modules.
@@ -35,17 +35,17 @@ import org.hibernate.validator.constraints.NotEmpty;
public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements SoftwareModuleType { public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements SoftwareModuleType {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "type_key", nullable = false, length = 64) @Column(name = "type_key", nullable = false, length = SoftwareModuleType.KEY_MAX_SIZE)
@Size(max = 64) @Size(min = 1, max = SoftwareModuleType.KEY_MAX_SIZE)
@NotEmpty @NotNull
private String key; private String key;
@Column(name = "max_ds_assignments", nullable = false) @Column(name = "max_ds_assignments", nullable = false)
@Min(1) @Min(1)
private int maxAssignments; private int maxAssignments;
@Column(name = "colour", nullable = true, length = 16) @Column(name = "colour", nullable = true, length = SoftwareModuleType.COLOUR_MAX_SIZE)
@Size(max = 16) @Size(max = SoftwareModuleType.COLOUR_MAX_SIZE)
private String colour; private String colour;
@Column(name = "deleted") @Column(name = "deleted")

View File

@@ -26,8 +26,8 @@ import org.eclipse.hawkbit.repository.model.Tag;
public class JpaTag extends AbstractJpaNamedEntity implements Tag { public class JpaTag extends AbstractJpaNamedEntity implements Tag {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "colour", nullable = true, length = 16) @Column(name = "colour", nullable = true, length = Tag.COLOUR_MAX_SIZE)
@Size(max = 16) @Size(max = Tag.COLOUR_MAX_SIZE)
private String colour; private String colour;
protected JpaTag() { protected JpaTag() {

View File

@@ -21,6 +21,7 @@ import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
@@ -38,13 +39,13 @@ import org.hibernate.validator.constraints.NotEmpty;
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery { public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery {
private static final long serialVersionUID = 7493966984413479089L; private static final long serialVersionUID = 7493966984413479089L;
@Column(name = "name", length = 64, nullable = false) @Column(name = "name", length = NamedEntity.NAME_MAX_SIZE, nullable = false)
@Size(max = 64) @Size(max = NamedEntity.NAME_MAX_SIZE)
@NotEmpty @NotEmpty
private String name; private String name;
@Column(name = "query", length = 1024, nullable = false) @Column(name = "query", length = TargetFilterQuery.QUERY_MAX_SIZE, nullable = false)
@Size(max = 1024) @Size(max = TargetFilterQuery.QUERY_MAX_SIZE)
@NotEmpty @NotEmpty
private String query; private String query;

View File

@@ -19,11 +19,15 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.validation.ConstraintViolationException;
import org.apache.commons.lang3.RandomStringUtils;
import org.assertj.core.api.Condition; import org.assertj.core.api.Condition;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate; import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -52,6 +56,7 @@ import com.google.common.collect.Sets;
import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Step;
import ru.yandex.qatools.allure.annotations.Stories; import ru.yandex.qatools.allure.annotations.Stories;
/** /**
@@ -170,6 +175,84 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "DistributionSetMetadata"); entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "DistributionSetMetadata");
} }
@Test
@Description("Verify that a DistributionSet with invalid properties cannot be created or updated")
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 0) })
public void createAndUpdateDistributionSetWithInvalidFields() {
final DistributionSet set = testdataFactory.createDistributionSet();
createAndUpdateDistributionSetWithInvalidDescription(set);
createAndUpdateDistributionSetWithInvalidName(set);
createAndUpdateDistributionSetWithInvalidVersion(set);
}
@Step
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
.create().name("a").version("a").description(RandomStringUtils.randomAlphanumeric(513))))
.as("entity with too long description should not be created");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
.update(set.getId()).description(RandomStringUtils.randomAlphanumeric(513))))
.as("entity with too long description should not be updated");
}
@Step
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
.create().version("a").name(RandomStringUtils.randomAlphanumeric(65))))
.as("entity with too long name should not be created");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement
.createDistributionSet(entityFactory.distributionSet().create().version("a").name("")))
.as("entity with too long name should not be created");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
.update(set.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
.as("entity with too long name should not be updated");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).name("")))
.as("entity with too short name should not be updated");
}
@Step
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
.create().name("a").version(RandomStringUtils.randomAlphanumeric(65))))
.as("entity with too long name should not be created");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement
.createDistributionSet(entityFactory.distributionSet().create().name("a").version("")))
.as("entity with too long name should not be created");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
.update(set.getId()).version(RandomStringUtils.randomAlphanumeric(65))))
.as("entity with too long name should not be updated");
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> distributionSetManagement
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).version("")))
.as("entity with too short name should not be updated");
}
@Test @Test
@Description("Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS).") @Description("Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS).")
public void createDuplicateDistributionSetsFailsWithException() { public void createDuplicateDistributionSetsFailsWithException() {