Repository API query signatures Entity free (#403)

* Migrated target management queries to IDs inetsead of full entities

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

* Added missing comment.

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

* refactored target,DS,cont,deploy,rg mangement.

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

* Adde versioning documentation.

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

* Rollout, Dist and Software mgmt refactored

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

* Readded line that was remove by incident. 

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

* Fixed broken tests.

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

* Query management refactored

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

* Fix bug of auto assign DS delete

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

* Switch to collection

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

* Fixed compile error

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

* Small glitches

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

* Fixed test after merge

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-01-11 14:32:55 +01:00
committed by GitHub
parent 824ef2982f
commit 889d1492fb
97 changed files with 1126 additions and 1289 deletions

View File

@@ -104,13 +104,13 @@ public interface ArtifactManagement {
* Garbage collects local artifact binary file if only referenced by given
* {@link Artifact} metadata object.
*
* @param onlyByThisReferenced
* @param artifactId
* the related local artifact
*
* @return <code>true</code> if an binary was actually garbage collected
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
boolean clearArtifactBinary(@NotNull Artifact onlyByThisReferenced);
boolean clearArtifactBinary(@NotNull Long artifactId);
/**
* Deletes {@link Artifact} based on given id.
@@ -186,15 +186,18 @@ public interface ArtifactManagement {
/**
* Loads {@link DbArtifact} from store for given {@link Artifact}.
*
* @param artifact
* @param artifactId
* to search for
* @return loaded {@link DbArtifact}
*
* @throws GridFSDBFileNotFoundException
* if file could not be found in store
*
* @throws EntityNotFoundException
* is artifact with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DOWNLOAD_ARTIFACT + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_CONTROLLER_DOWNLOAD)
DbArtifact loadArtifactBinary(@NotNull Artifact artifact);
DbArtifact loadArtifactBinary(@NotNull Long artifactId);
}

View File

@@ -24,10 +24,8 @@ import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.hibernate.validator.constraints.NotEmpty;
@@ -116,12 +114,15 @@ public interface ControllerManagement {
* Retrieves oldest {@link Action} that is active and assigned to a
* {@link Target}.
*
* @param target
* the target to retrieve the actions from
* @param controllerId
* identifies the target to retrieve the actions from
* @return a list of actions assigned to given target which are active
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Optional<Action> findOldestActiveActionByTarget(@NotNull Target target);
Optional<Action> findOldestActiveActionByTarget(@NotNull String controllerId);
/**
* Get the {@link Action} entity for given actionId with all lazy
@@ -177,7 +178,7 @@ public interface ControllerManagement {
*
* @param controllerId
* the ID of the target to check
* @param localArtifact
* @param artifactId
* the artifact to verify if the given target had even been
* assigned to
* @return {@code true} if the given target has currently or had ever a
@@ -185,7 +186,7 @@ public interface ControllerManagement {
* otherwise {@code false}
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull Artifact localArtifact);
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull Long artifactId);
/**
* Checks if a given target has currently or has even been assigned to the
@@ -196,7 +197,7 @@ public interface ControllerManagement {
*
* @param targetId
* the ID of the target to check
* @param localArtifact
* @param artifactId
* the artifact to verify if the given target had even been
* assigned to
* @return {@code true} if the given target has currently or had ever a
@@ -204,21 +205,24 @@ public interface ControllerManagement {
* otherwise {@code false}
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotNull Artifact localArtifact);
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotNull Long artifactId);
/**
* Registers retrieved status for given {@link Target} and {@link Action} if
* it does not exist yet.
*
* @param action
* @param actionId
* to the handle status for
* @param message
* for the status
* @return the update action in case the status has been changed to
* {@link Status#RETRIEVED}
*
* @throws EntityNotFoundException
* if action with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Action registerRetrieved(@NotNull Action action, String message);
Action registerRetrieved(@NotNull Long actionId, String message);
/**
* Updates attributes of the controller.
@@ -255,40 +259,6 @@ public interface ControllerManagement {
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Target updateLastTargetQuery(@NotEmpty String controllerId, URI address);
/**
* Refreshes the time of the last time the controller has been connected to
* the server.
*
* @param target
* to update
* @param address
* the client address of the target, might be {@code null}
* @return the updated target
*
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
TargetInfo updateLastTargetQuery(@NotNull TargetInfo target, @NotNull URI address);
/**
* Update selective the target status of a given {@code target}.
*
* @param targetInfo
* the target to update the target status
* @param status
* the status to be set of the target. Might be {@code null} if
* the target status should not be updated
* @param lastTargetQuery
* the last target query to be set of the target. Might be
* {@code null} if the target lastTargetQuery should not be
* updated
* @param address
* the client address of the target, might be {@code null}
* @return the updated TargetInfo
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
TargetInfo updateTargetStatus(@NotNull TargetInfo targetInfo, TargetUpdateStatus status, Long lastTargetQuery,
URI address);
/**
* Finds {@link Target} based on given controller ID returns found Target
* without details, i.e. NO {@link Target#getTags()} and
@@ -301,7 +271,7 @@ public interface ControllerManagement {
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE)
Target findByControllerId(@NotEmpty final String controllerId);
Target findByControllerId(@NotEmpty String controllerId);
/**
* Finds {@link Target} based on given ID returns found Target without
@@ -315,6 +285,6 @@ public interface ControllerManagement {
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE)
Target findByTargetId(final long targetId);
Target findByTargetId(@NotNull Long targetId);
}

View File

@@ -114,57 +114,33 @@ public interface DeploymentManagement {
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
@NotEmpty Collection<TargetWithActionType> targets, String actionMessage);
/**
* method assigns the {@link DistributionSet} to all {@link Target}s by
* their IDs with a specific {@link ActionType} and {@code forcetime}.
*
* @param dsID
* the ID of the distribution set to assign
* @param targets
* a list of all targets and their action type
* @param rollout
* the rollout for this assignment
* @param rolloutGroup
* the rollout group for this assignment
* @return the assignment result
*
* @throw IncompleteDistributionSetException if mandatory
* {@link SoftwareModuleType} are not assigned as define by the
* {@link DistributionSetType}.
*
* @throw {@link EntityNotFoundException} if either provided
* {@link DistributionSet} or {@link Target}s do not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
@NotEmpty Collection<TargetWithActionType> targets, Rollout rollout, RolloutGroup rolloutGroup);
/**
* Cancels given {@link Action} for given {@link Target}. The method will
* immediately add a {@link Status#CANCELED} status to the action. However,
* it might be possible that the controller will continue to work on the
* cancellation.
*
* @param action
* @param actionId
* to be canceled
* @param target
* for which the action needs cancellation
*
* @return generated {@link Action} or <code>null</code> if not active on
* given {@link Target}.
* @throws CancelActionNotAllowedException
* in case the given action is not active or is already a cancel
* action
*
* @throws EntityNotFoundException
* if action with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Action cancelAction(@NotNull Action action, @NotNull Target target);
Action cancelAction(@NotNull Long actionId);
/**
* counts all actions associated to a specific target.
*
* @param rsqlParam
* rsql query string
* @param target
* @param controllerId
* the target associated to the actions to count
* @return the count value of found actions associated to the target
*
@@ -175,7 +151,7 @@ public interface DeploymentManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countActionsByTarget(@NotNull String rsqlParam, @NotNull Target target);
Long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
/**
* @return the total amount of stored action status
@@ -192,35 +168,12 @@ public interface DeploymentManagement {
/**
* counts all actions associated to a specific target.
*
* @param target
* @param controllerId
* the target associated to the actions to count
* @return the count value of found actions associated to the target
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countActionsByTarget(@NotNull Target target);
/**
* Creates an action entry into the action repository. In case of existing
* scheduled actions the scheduled actions gets canceled. A scheduled action
* is created in-active.
*
* @param targets
* the targets to create scheduled actions for
* @param distributionSet
* the distribution set for the actions
* @param actionType
* the action type for the action
* @param forcedTime
* the forcedTime of the action
* @param rollout
* the roll out for this action
* @param rolloutGroup
* the roll out group for this action
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
void createScheduledAction(@NotEmpty Collection<Target> targets, @NotNull DistributionSet distributionSet,
@NotNull ActionType actionType, Long forcedTime, @NotNull Rollout rollout,
@NotNull RolloutGroup rolloutGroup);
Long countActionsByTarget(@NotEmpty String controllerId);
/**
* Get the {@link Action} entity for given actionId.
@@ -232,30 +185,6 @@ public interface DeploymentManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Action findAction(@NotNull Long actionId);
/**
* Retrieves all actions for a specific rollout and in a specific status.
*
* @param rollout
* the rollout the actions beglong to
* @param actionStatus
* the status of the actions
* @return the actions referring a specific rollout an in a specific status
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Action> findActionsByRolloutAndStatus(@NotNull Rollout rollout, @NotNull Action.Status actionStatus);
/**
* Retrieves all {@link Action}s of a specific target.
*
* @param pageable
* pagination parameter
* @param target
* of which the actions have to be searched
* @return a paged list of actions associated with the given target
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByTarget(@NotNull Pageable pageable, @NotNull Target target);
/**
* Retrieves all {@link Action}s from repository.
*
@@ -272,14 +201,14 @@ public interface DeploymentManagement {
*
* @param pageable
* the page request parameter for paging and sorting the result
* @param distributionSet
* @param distributionSetId
* the distribution set which should be assigned to the actions
* in the result
* @return a list of {@link Action} which are assigned to a specific
* {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull DistributionSet distributionSet);
Slice<Action> findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull Long distributionSetId);
/**
* Retrieves all {@link Action}s assigned to a specific {@link Target} and a
@@ -287,7 +216,7 @@ public interface DeploymentManagement {
*
* @param rsqlParam
* rsql query string
* @param target
* @param controllerId
* the target which must be assigned to the actions
* @param pageable
* the page request
@@ -301,31 +230,21 @@ public interface DeploymentManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotNull Target target, @NotNull Pageable pageable);
/**
* Retrieves all {@link Action}s of a specific target ordered by action ID.
*
* @param target
* the target associated with the actions
* @return a list of actions associated with the given target ordered by
* action ID
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Action> findActionsByTarget(@NotNull Target target);
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId,
@NotNull Pageable pageable);
/**
* Retrieves all {@link Action}s which are referring the given
* {@link Target}.
*
* @param foundTarget
* @param controllerId
* the target to find actions for
* @param pageable
* the pageable request to limit, sort the actions
* @return a slice of actions found for a specific target
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByTarget(@NotNull Target foundTarget, @NotNull Pageable pageable);
Slice<Action> findActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable);
/**
* Retrieves all the {@link ActionStatus} entries of the given
@@ -333,12 +252,12 @@ public interface DeploymentManagement {
*
* @param pageReq
* pagination parameter
* @param action
* @param actionId
* to be filtered on
* @return the corresponding {@link Page} of {@link ActionStatus}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action);
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Long actionId);
/**
* Retrieves all {@link ActionStatus} inclusive their messages by a specific
@@ -346,23 +265,23 @@ public interface DeploymentManagement {
*
* @param pageable
* the page request parameter for paging and sorting the result
* @param action
* @param actionId
* the {@link Action} to retrieve the {@link ActionStatus} from
* @return a page of {@link ActionStatus} by a speciifc {@link Action}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<ActionStatus> findActionStatusByActionWithMessages(@NotNull Pageable pageable, @NotNull Action action);
Page<ActionStatus> findActionStatusByActionWithMessages(@NotNull Pageable pageable, @NotNull Long actionId);
/**
* Retrieves all {@link Action}s of a specific target ordered by action ID.
*
* @param target
* @param controllerId
* the target associated with the actions
* @return a list of actions associated with the given target ordered by
* action ID
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(@NotNull Target target);
List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(@NotNull String controllerId);
/**
* Get the {@link Action} entity for given actionId with all lazy attributes
@@ -379,23 +298,23 @@ public interface DeploymentManagement {
* Retrieves all active {@link Action}s of a specific target ordered by
* action ID.
*
* @param target
* @param controllerId
* the target associated with the actions
* @return a list of actions associated with the given target
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Action> findActiveActionsByTarget(@NotNull Target target);
List<Action> findActiveActionsByTarget(@NotEmpty String controllerId);
/**
* Retrieves all inactive {@link Action}s of a specific target ordered by
* action ID.
*
* @param target
* @param controllerId
* the target associated with the actions
* @return a list of actions associated with the given target
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<Action> findInActiveActionsByTarget(@NotNull Target target);
List<Action> findInActiveActionsByTarget(@NotEmpty String controllerId);
/**
* Force cancels given {@link Action} for given {@link Target}. Force
@@ -403,16 +322,19 @@ public interface DeploymentManagement {
* and a cancel request is sent to the target. But however it's not tracked,
* if the targets handles the cancel request or not.
*
* @param action
* @param actionId
* to be canceled
*
* @return generated {@link Action} or <code>null</code> if not active on
* {@link Target}.
* @throws CancelActionNotAllowedException
* in case the given action is not active
*
* @throws EntityNotFoundException
* if action with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Action forceQuitAction(@NotNull Action action);
Action forceQuitAction(@NotNull Long actionId);
/**
* Updates a {@link Action} and forces the {@link Action} if it's not
@@ -425,17 +347,6 @@ public interface DeploymentManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Action forceTargetAction(@NotNull Long actionId);
/**
* Starting an action which is scheduled, e.g. in case of roll out a
* scheduled action must be started now.
*
* @param actionId
* the the ID of the action to start now.
* @return the action which has been started
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Action startScheduledAction(@NotNull Long actionId);
/**
* Starts all scheduled actions of an RolloutGroup parent.
*

View File

@@ -81,12 +81,15 @@ public interface DistributionSetManagement {
*
* @param dsIds
* to assign for
* @param tag
* @param tagId
* to assign
* @return list of assigned ds
*
* @throws EntityNotFoundException
* if tag with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull DistributionSetTag tag);
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull Long tagId);
/**
* Count all {@link DistributionSet}s in the repository that are not marked
@@ -101,13 +104,13 @@ public interface DistributionSetManagement {
* Count all {@link DistributionSet}s in the repository that are not marked
* as deleted.
*
* @param type
* @param typeId
* to look for
*
* @return number of {@link DistributionSet}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countDistributionSetsByType(@NotNull DistributionSetType type);
Long countDistributionSetsByType(@NotNull Long typeId);
/**
* @return number of {@link DistributionSetType}s in the repository.
@@ -212,22 +215,22 @@ public interface DistributionSetManagement {
* e.g. findByDeletedFalse())
* </p>
*
* @param set
* @param setId
* to delete
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteDistributionSet(@NotNull DistributionSet set);
void deleteDistributionSet(@NotNull Long setId);
/**
* Deleted {@link DistributionSet}s by their IDs. That is either a soft
* delete of the entities have been linked to an {@link Action} before or a
* hard delete if not.
*
* @param distributionSetIDs
* @param dsIds
* to be deleted
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteDistributionSet(@NotEmpty Long... distributionSetIDs);
void deleteDistributionSet(@NotEmpty Collection<Long> dsIds);
/**
* deletes a distribution set meta data entry.
@@ -246,21 +249,24 @@ public interface DistributionSetManagement {
/**
* Deletes or mark as delete in case the type is in use.
*
* @param type
* @param typeId
* to delete
*
* @throws EntityNotFoundException
* if given set does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteDistributionSetType(@NotNull DistributionSetType type);
void deleteDistributionSetType(@NotNull Long typeId);
/**
* retrieves the distribution set for a given action.
*
* @param action
* @param actionId
* the action associated with the distribution set
* @return the distribution set which is associated with the action
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
DistributionSet findDistributionSetByAction(@NotNull Action action);
DistributionSet findDistributionSetByAction(@NotNull Long actionId);
/**
* Find {@link DistributionSet} based on given ID without details, e.g.
@@ -510,28 +516,13 @@ public interface DistributionSetManagement {
* Checks if a {@link DistributionSet} is currently in use by a target in
* the repository.
*
* @param distributionSet
* @param setId
* to check
*
* @return <code>true</code> if in use
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
boolean isDistributionSetInUse(@NotNull DistributionSet distributionSet);
/**
* entity based method call for
* {@link #toggleTagAssignment(Collection, String)}.
*
* @param sets
* to toggle for
* @param tag
* to toggle
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
* the assignment outcome.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<DistributionSet> sets,
@NotNull DistributionSetTag tag);
boolean isDistributionSetInUse(@NotNull Long setId);
/**
* Toggles {@link DistributionSetTag} assignment to given
@@ -553,12 +544,15 @@ public interface DistributionSetManagement {
* Unassign all {@link DistributionSet} from a given
* {@link DistributionSetTag} .
*
* @param tag
* @param tagId
* to unassign all ds
* @return list of unassigned ds
*
* @throws EntityNotFoundException
* if tag with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
List<DistributionSet> unAssignAllDistributionSetsByTag(@NotNull DistributionSetTag tag);
List<DistributionSet> unAssignAllDistributionSetsByTag(@NotNull Long tagId);
/**
* Unassigns a {@link SoftwareModule} form an existing
@@ -571,7 +565,7 @@ public interface DistributionSetManagement {
* @return the updated {@link DistributionSet}.
*
* @throws EntityNotFoundException
* if given module does not exist
* if given module or DS does not exist
*
* @throws EntityReadOnlyException
* if use tries to change the {@link DistributionSet} s while
@@ -586,12 +580,15 @@ public interface DistributionSetManagement {
*
* @param dsId
* to unassign for
* @param distributionSetTag
* @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
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull DistributionSetTag distributionSetTag);
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull Long tagId);
/**
* Updates existing {@link DistributionSet}.

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.Rollout;
@@ -51,13 +52,13 @@ public interface RolloutGroupManagement {
*
* @param pageRequest
* the page request to sort and limit the result
* @param rolloutGroup
* @param rolloutGroupId
* rollout group
* @return {@link TargetWithActionStatus} target with action status
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull PageRequest pageRequest,
@NotNull RolloutGroup rolloutGroup);
@NotNull Long rolloutGroupId);
/**
* Retrieves a single {@link RolloutGroup} by its ID.
@@ -109,20 +110,23 @@ public interface RolloutGroupManagement {
/**
* Get targets of specified rollout group.
*
* @param rolloutGroup
* @param rolloutGroupId
* rollout group
* @param page
* the page request to sort and limit the result
*
* @return Page<Target> list of targets of a rollout group
*
* @throws EntityNotFoundException
* if group with ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull Pageable page);
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull Pageable page);
/**
* Get targets of specified rollout group.
*
* @param rolloutGroup
* @param rolloutGroupId
* rollout group
* @param rsqlParam
* the specification for filtering the targets of a rollout group
@@ -138,7 +142,7 @@ public interface RolloutGroupManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull String rsqlParam,
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull String rsqlParam,
@NotNull Pageable pageable);
/**

View File

@@ -290,12 +290,12 @@ public interface RolloutManagement {
*
* @param rolloutId
* the ID of the {@link Rollout}
* @param rolloutGroup
* @param rolloutGroupId
* the ID of the {@link RolloutGroup}
* @return percentage finished
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull RolloutGroup rolloutGroup);
float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull Long rolloutGroupId);
/**
* Pauses a rollout which is currently running. The Rollout switches
@@ -313,10 +313,11 @@ public interface RolloutManagement {
* the rollout to be paused.
*
* @throws EntityNotFoundException
* if rollout with given ID does not exist
* if rollout or group with given ID does not exist
* @throws RolloutIllegalStateException
* if given rollout is not in {@link RolloutStatus#RUNNING}.
* Only running rollouts can be paused.
*
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
void pauseRollout(@NotNull Long rollout);

View File

@@ -175,22 +175,25 @@ public interface SoftwareManagement {
/**
* Deletes or marks as delete in case the type is in use.
*
* @param type
* @param typeId
* to delete
*
* @throws EntityNotFoundException
* not found is type with giben ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModuleType(@NotNull SoftwareModuleType type);
void deleteSoftwareModuleType(@NotNull Long typeId);
/**
* @param pageable
* the page request to page the result set
* @param set
* @param setId
* to search for
* @return all {@link SoftwareModule}s that are assigned to given
* {@link DistributionSet}.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull DistributionSet set);
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId);
/**
* Filter {@link SoftwareModule}s with given
@@ -238,13 +241,13 @@ public interface SoftwareManagement {
* of the {@link SoftwareModule}
* @param version
* of the {@link SoftwareModule}
* @param type
* @param typeId
* of the {@link SoftwareModule}
* @return the found {@link SoftwareModule} or <code>null</code>
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version,
@NotNull SoftwareModuleType type);
@NotNull Long typeId);
/**
* finds a single software module meta data by its id.
@@ -433,12 +436,8 @@ public interface SoftwareManagement {
* {@link SoftwareModule#getDescription()}
* {@link SoftwareModule#getVendor()}.
*
* @param moduleId
* to update
* @param description
* to update or <code>null</code>
* @param vendor
* to update or <code>null</code>
* @param update
* contains properties to update
*
* @throws EntityNotFoundException
* if given module does not exist

View File

@@ -16,7 +16,6 @@ import org.eclipse.hawkbit.repository.builder.TargetFilterQueryUpdate;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -62,7 +61,7 @@ public interface TargetFilterQueryManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
boolean verifyTargetFilterQuerySyntax(String query);
boolean verifyTargetFilterQuerySyntax(@NotNull String query);
/**
*
@@ -94,7 +93,7 @@ public interface TargetFilterQueryManagement {
* @return the page with the found {@link TargetFilterQuery}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, String name);
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, @NotNull String name);
/**
* Retrieves all target filter query which {@link TargetFilterQuery}.
@@ -107,7 +106,7 @@ public interface TargetFilterQueryManagement {
* @return the page with the found {@link TargetFilterQuery}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, String rsqlFilter);
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, @NotNull String rsqlFilter);
/**
* Retrieves all target filter query which {@link TargetFilterQuery}.
@@ -115,29 +114,18 @@ public interface TargetFilterQueryManagement {
*
* @param pageable
* pagination parameter
* @param distributionSet
* the auto assign distribution set
* @return the page with the found {@link TargetFilterQuery}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable,
DistributionSet distributionSet);
/**
* Retrieves all target filter query which {@link TargetFilterQuery}.
*
*
* @param pageable
* pagination parameter
* @param distributionSet
* @param setId
* the auto assign distribution set
* @param rsqlParam
* RSQL filter
* @return the page with the found {@link TargetFilterQuery}
*
* @throws EntityNotFoundException
* if DS with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable,
DistributionSet distributionSet, String rsqlParam);
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable, @NotNull Long setId,
String rsqlParam);
/**
* Retrieves all target filter query with auto assign DS which
@@ -185,7 +173,7 @@ public interface TargetFilterQueryManagement {
* provided but not found
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetFilterQuery updateTargetFilterQuery(TargetFilterQueryUpdate update);
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQueryUpdate update);
/**
* updates the {@link TargetFilterQuery#getAutoAssignDistributionSet()}.
@@ -193,7 +181,7 @@ public interface TargetFilterQueryManagement {
* @param queryId
* to be updated
* @param dsId
* to be updated or <code>null</code>
* to be updated or <code>null</code> in order to remove it
* @return the updated {@link TargetFilterQuery}
*
* @throws EntityNotFoundException
@@ -201,6 +189,6 @@ public interface TargetFilterQueryManagement {
* provided but not found
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetFilterQuery updateTargetFilterQueryAutoAssignDS(Long queryId, Long dsId);
TargetFilterQuery updateTargetFilterQueryAutoAssignDS(@NotNull Long queryId, Long dsId);
}

View File

@@ -45,14 +45,17 @@ public interface TargetManagement {
/**
* Assign a {@link TargetTag} assignment to given {@link Target}s.
*
* @param targetIds
* @param controllerIds
* to assign for
* @param tag
* @param tagId
* to assign
* @return list of assigned targets
*
* @throws EntityNotFoundException
* if given tagId does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
List<Target> assignTag(@NotEmpty Collection<String> targetIds, @NotNull TargetTag tag);
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
List<Target> assignTag(@NotEmpty Collection<String> controllerIds, @NotNull Long tagId);
/**
* Counts number of targets with given
@@ -112,22 +115,25 @@ public interface TargetManagement {
/**
* Count {@link TargetFilterQuery}s for given target filter query.
*
* @param targetFilterQuery
* {link TargetFilterQuery}
* @return the found number {@link TargetFilterQuery}s
* @param rsqlParam
* filter definition in RSQL syntax
* @return the found number {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countTargetByTargetFilterQuery(@NotEmpty String targetFilterQuery);
Long countTargetByTargetFilterQuery(@NotEmpty String rsqlParam);
/**
* Count {@link TargetFilterQuery}s for given filter parameter.
* Count {@link TargetFilterQuery}s for given target filter query.
*
* @param targetFilterQuery
* {link TargetFilterQuery}
* @return the found number {@link TargetFilterQuery}s
* @param targetFilterQueryId
* {@link TargetFilterQuery#getId()}
* @return the found number {@link Target}s
*
* @throws EntityNotFoundException
* if {@link TargetFilterQuery} with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countTargetByTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery);
Long countTargetByTargetFilterQuery(@NotNull Long targetFilterQueryId);
/**
* Counts all {@link Target}s in the repository.
@@ -169,28 +175,22 @@ public interface TargetManagement {
* Deletes all targets with the given IDs.
*
* @param targetIDs
* the technical IDs of the targets to be deleted
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTargets(@NotEmpty Long... targetIDs);
/**
* Deletes all targets with the given IDs.
*
* @param targetIDs
* the technical IDs of the targets to be deleted
* the IDs of the targets to be deleted
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
/**
* finds all {@link Target#getControllerId()} which are currently in the
* database.
* Deletes target with the given IDs.
*
* @return all IDs of all {@link Target} in the system
* @param controllerID
* the ID of the targets to be deleted
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<TargetIdName> findAllTargetIds();
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
void deleteTarget(@NotEmpty String controllerID);
/**
* Finds all targets for all the given parameters but returns not the full
@@ -231,13 +231,12 @@ public interface TargetManagement {
*
* @param pageRequest
* the pageRequest to enhance the query for paging and sorting
* @param targetFilterQuery
* {@link TargetFilterQuery}
* @param rsqlParam
* filter definition in RSQL syntax
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest,
@NotNull TargetFilterQuery targetFilterQuery);
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest, @NotNull String rsqlParam);
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
@@ -248,13 +247,13 @@ public interface TargetManagement {
* the pageRequest to enhance the query for paging and sorting
* @param distributionSetId
* id of the {@link DistributionSet}
* @param targetFilterQuery
* {@link TargetFilterQuery}
* @param rsqlParam
* filter definition in RSQL syntax
* @return a page of the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, Long distributionSetId,
@NotNull TargetFilterQuery targetFilterQuery);
@NotNull String rsqlParam);
/**
* Counts all targets for all the given parameter {@link TargetFilterQuery}
@@ -263,12 +262,12 @@ public interface TargetManagement {
*
* @param distributionSetId
* id of the {@link DistributionSet}
* @param targetFilterQuery
* {@link TargetFilterQuery}
* @param rsqlParam
* filter definition in RSQL syntax
* @return the count of found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countTargetsByTargetFilterQueryAndNonDS(Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery);
Long countTargetsByTargetFilterQueryAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam);
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
@@ -278,13 +277,13 @@ public interface TargetManagement {
* the pageRequest to enhance the query for paging and sorting
* @param groups
* the list of {@link RolloutGroup}s
* @param targetFilterQuery
* RSQL filter
* @param rsqlParam
* filter definition in RSQL syntax
* @return a page of the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotNull Pageable pageRequest,
List<RolloutGroup> groups, @NotNull String targetFilterQuery);
@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
/**
* Counts all targets for all the given parameter {@link TargetFilterQuery}
@@ -292,13 +291,13 @@ public interface TargetManagement {
*
* @param groups
* the list of {@link RolloutGroup}s
* @param targetFilterQuery
* RSQL filter
* @param rsqlParam
* filter definition in RSQL syntax
* @return count of the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(List<RolloutGroup> groups,
@NotNull String targetFilterQuery);
Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotEmpty Collection<Long> groups,
@NotNull String rsqlParam);
/**
* Finds all targets of the provided {@link RolloutGroup} that have no
@@ -311,7 +310,7 @@ public interface TargetManagement {
* @return the found {@link Target}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull RolloutGroup group);
Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group);
/**
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
@@ -490,13 +489,15 @@ public interface TargetManagement {
* and {@link Target#getActions()} possible based on
* {@link TargetFilterQuery#getQuery()}
*
* @param targetFilterQuery
* in string notation
* @param rsqlParam
* in RSQL notation
*
* @param pageable
* pagination parameter
*
* @return the found {@link Target}s, never {@code null}
*
*
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
@@ -504,20 +505,22 @@ public interface TargetManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findTargetsAll(@NotNull String targetFilterQuery, @NotNull Pageable pageable);
Page<Target> findTargetsAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
* and {@link Target#getActions()} possible based on
* {@link TargetFilterQuery#getQuery()}
*
* @param targetFilterQuery
* the specification for the query
* @param targetFilterQueryId
* {@link TargetFilterQuery#getId()}
* @param pageable
* pagination parameter
*
* @return the found {@link Target}s, never {@code null}
*
* @throws EntityNotFoundException
* if {@link TargetFilterQuery} with given ID does not exist.
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
@@ -525,7 +528,7 @@ public interface TargetManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Target> findTargetsAll(@NotNull TargetFilterQuery targetFilterQuery, @NotNull Pageable pageable);
Slice<Target> findTargetsByTargetFilterQuery(@NotNull Long targetFilterQueryId, @NotNull Pageable pageable);
/**
* method retrieves all {@link Target}s from the repo in the following
@@ -594,40 +597,33 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> targetIds, @NotEmpty String tagName);
/**
* {@link Target} based method call for
* {@link #toggleTagAssignment(Collection, String)}.
*
* @param targets
* to toggle for
* @param tag
* to toggle
* @return TagAssigmentResult with all meta data of the assignment outcome.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Target> targets, @NotNull TargetTag tag);
/**
* Un-assign all {@link Target} from a given {@link TargetTag} .
*
* @param tag
* @param targetTagId
* to un-assign all targets
* @return list of unassigned targets
*
* @throws EntityNotFoundException
* if TAG with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
List<Target> unAssignAllTargetsByTag(@NotNull TargetTag tag);
List<Target> unAssignAllTargetsByTag(@NotNull Long targetTagId);
/**
* Un-assign a {@link TargetTag} assignment to given {@link Target}.
*
* @param controllerID
* to un-assign for
* @param targetTag
* @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
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Target unAssignTag(@NotEmpty String controllerID, @NotNull TargetTag targetTag);
Target unAssignTag(@NotEmpty String controllerID, @NotNull Long targetTagId);
/**
* updates the {@link Target}.
@@ -642,5 +638,5 @@ public interface TargetManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
Target updateTarget(TargetUpdate update);
Target updateTarget(@NotNull TargetUpdate update);
}