diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java index 8a3a50ad2..8c44f0496 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java @@ -19,8 +19,8 @@ import org.eclipse.hawkbit.im.authentication.PermissionService; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails; import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter; -import org.eclipse.hawkbit.security.SecurityContextTenantAware; import org.eclipse.hawkbit.security.DdiSecurityProperties; +import org.eclipse.hawkbit.security.SecurityContextTenantAware; import org.eclipse.hawkbit.security.SpringSecurityAuditorAware; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java index 0b321842f..9638377eb 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -24,11 +24,11 @@ import org.eclipse.hawkbit.ExcludePathAwareShallowETagFilter; import org.eclipse.hawkbit.cache.CacheConstants; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; -import org.eclipse.hawkbit.repository.ControllerManagement; -import org.eclipse.hawkbit.repository.TenantConfigurationManagement; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationToken; import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter; +import org.eclipse.hawkbit.repository.ControllerManagement; +import org.eclipse.hawkbit.repository.SystemManagement; +import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.rest.resource.RestConstants; import org.eclipse.hawkbit.security.ControllerTenantAwareAuthenticationDetailsSource; import org.eclipse.hawkbit.security.DdiSecurityProperties; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java index 1c562364f..d5e8db96f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java @@ -12,8 +12,8 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder; import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder; import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java index 19f3bcee2..7854640da 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java @@ -277,13 +277,11 @@ public interface ArtifactManagement { SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id); /** - * Loads {@link org.eclipse.hawkbit.artifact.server.json.model.Artifact} - * from store for given {@link LocalArtifact}. + * Loads {@link DbArtifact} from store for given {@link LocalArtifact}. * * @param artifact * to search for - * @return loaded - * {@link org.eclipse.hawkbit.artifact.server.json.model.Artifact} + * @return loaded {@link DbArtifact} * * @throws GridFSDBFileNotFoundException * if file could not be found in store diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 2b18ab7ff..4ee3b1275 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -43,16 +43,6 @@ public interface ControllerManagement { String SERVER_MESSAGE_PREFIX = "Update Server: "; - /** - * Simple addition of a new {@link ActionStatus} entry to the {@link Action} - * . No state changes. - * - * @param statusMessage - * to add to the action - */ - @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - void addInformationalActionStatus(@NotNull ActionStatus statusMessage); - /** * Adds an {@link ActionStatus} for a cancel {@link Action} including * potential state changes for the target and the {@link Action} itself. @@ -68,6 +58,16 @@ public interface ControllerManagement { @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) Action addCancelActionStatus(@NotNull ActionStatus actionStatus); + /** + * Simple addition of a new {@link ActionStatus} entry to the {@link Action} + * . No state changes. + * + * @param statusMessage + * to add to the action + */ + @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) + void addInformationalActionStatus(@NotNull ActionStatus statusMessage); + /** * Adds an {@link ActionStatus} entry for an update {@link Action} including * potential state changes for the target and the {@link Action} itself. @@ -133,14 +133,14 @@ public interface ControllerManagement { List findSoftwareModulesByDistributionSet(@NotNull DistributionSet distributionSet); /** - * Retrieves last {@link UpdateAction} for a download of an artifact of - * given module and target. + * Retrieves last {@link Action} for a download of an artifact of given + * module and target. * * @param controllerId * to look for * @param module * that should be assigned to the target - * @return last {@link UpdateAction} for given combination + * @return last {@link Action} for given combination * * @throws EntityNotFoundException * if action for given combination could not be found diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index cffc3b8ad..754d66b65 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.repository; +import java.util.Collection; import java.util.List; import javax.validation.constraints.NotNull; @@ -99,7 +100,7 @@ public interface DeploymentManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, - @NotEmpty List targets); + @NotEmpty Collection targets); // TODO document: why are rollouts in the signature ? can all the parameters // be null or the list empty? @@ -123,7 +124,7 @@ public interface DeploymentManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, - @NotEmpty List targets, Rollout rollout, RolloutGroup rolloutGroup); + @NotEmpty Collection targets, Rollout rollout, RolloutGroup rolloutGroup); /** * method assigns the {@link DistributionSet} to all {@link Target}s by @@ -210,7 +211,7 @@ public interface DeploymentManagement { * the roll out group for this action */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - void createScheduledAction(List targets, DistributionSet distributionSet, ActionType actionType, + void createScheduledAction(Collection targets, DistributionSet distributionSet, ActionType actionType, long forcedTime, Rollout rollout, RolloutGroup rolloutGroup); /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java index c79fb669d..ad947879a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository; import java.util.Collections; import java.util.List; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.Target; @@ -53,11 +52,6 @@ public class DistributionSetAssignmentResult extends AssignmentResult { this.targetManagement = targetManagement; } - @Override - public List getAssignedEntity() { - return targetManagement.findTargetByControllerID(assignedTargets); - } - /** * @return the actionIds */ @@ -65,4 +59,9 @@ public class DistributionSetAssignmentResult extends AssignmentResult { return actions; } + @Override + public List getAssignedEntity() { + return targetManagement.findTargetByControllerID(assignedTargets); + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java index 728a4d0c5..54f7eb8e5 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java @@ -16,32 +16,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; * Holds distribution set filter parameters. */ public final class DistributionSetFilter { - private final Boolean isDeleted; - private final Boolean isComplete; - private final DistributionSetType type; - private final String searchText; - private final Boolean selectDSWithNoTag; - private final Collection tagNames; - private final String assignedTargetId; - private final String installedTargetId; - - /** - * Parametric constructor. - * - * @param builder - * DistributionSetFilterBuilder - */ - public DistributionSetFilter(final DistributionSetFilterBuilder builder) { - this.isDeleted = builder.isDeleted; - this.isComplete = builder.isComplete; - this.type = builder.type; - this.searchText = builder.searchText; - this.selectDSWithNoTag = builder.selectDSWithNoTag; - this.tagNames = builder.tagNames; - this.assignedTargetId = builder.assignedTargetId; - this.installedTargetId = builder.installedTargetId; - } - /** * * Distribution set filter builder. @@ -68,8 +42,13 @@ public final class DistributionSetFilter { return new DistributionSetFilter(this); } - public DistributionSetFilterBuilder setIsDeleted(final Boolean isDeleted) { - this.isDeleted = isDeleted; + public DistributionSetFilterBuilder setAssignedTargetId(final String assignedTargetId) { + this.assignedTargetId = assignedTargetId; + return this; + } + + public DistributionSetFilterBuilder setInstalledTargetId(final String installedTargetId) { + this.installedTargetId = installedTargetId; return this; } @@ -78,8 +57,8 @@ public final class DistributionSetFilter { return this; } - public DistributionSetFilterBuilder setType(final DistributionSetType type) { - this.type = type; + public DistributionSetFilterBuilder setIsDeleted(final Boolean isDeleted) { + this.isDeleted = isDeleted; return this; } @@ -98,28 +77,53 @@ public final class DistributionSetFilter { return this; } - public DistributionSetFilterBuilder setAssignedTargetId(final String assignedTargetId) { - this.assignedTargetId = assignedTargetId; - return this; - } - - public DistributionSetFilterBuilder setInstalledTargetId(final String installedTargetId) { - this.installedTargetId = installedTargetId; + public DistributionSetFilterBuilder setType(final DistributionSetType type) { + this.type = type; return this; } } + private final Boolean isDeleted; + private final Boolean isComplete; + private final DistributionSetType type; + private final String searchText; + private final Boolean selectDSWithNoTag; + private final Collection tagNames; + private final String assignedTargetId; - public Boolean getIsDeleted() { - return isDeleted; + private final String installedTargetId; + + /** + * Parametric constructor. + * + * @param builder + * DistributionSetFilterBuilder + */ + public DistributionSetFilter(final DistributionSetFilterBuilder builder) { + this.isDeleted = builder.isDeleted; + this.isComplete = builder.isComplete; + this.type = builder.type; + this.searchText = builder.searchText; + this.selectDSWithNoTag = builder.selectDSWithNoTag; + this.tagNames = builder.tagNames; + this.assignedTargetId = builder.assignedTargetId; + this.installedTargetId = builder.installedTargetId; + } + + public String getAssignedTargetId() { + return assignedTargetId; + } + + public String getInstalledTargetId() { + return installedTargetId; } public Boolean getIsComplete() { return isComplete; } - public DistributionSetType getType() { - return type; + public Boolean getIsDeleted() { + return isDeleted; } public String getSearchText() { @@ -134,12 +138,8 @@ public final class DistributionSetFilter { return tagNames; } - public String getAssignedTargetId() { - return assignedTargetId; - } - - public String getInstalledTargetId() { - return installedTargetId; + public DistributionSetType getType() { + return type; } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index bea9f2719..db737df4a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -41,6 +41,10 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; +/** + * Management service for {@link DistributionSet}s. + * + */ public interface DistributionSetManagement { // TODO rename/document the whole with details thing (document what the diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java index 6208d395c..933f2ad9e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java @@ -32,15 +32,81 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface ReportManagement { /** - * Generates a report of all targets of their current update status count. - * For each {@link TargetUpdateStatus} an total count of targets which are - * in this status currently. + * Data base format. * - * @return a data report series which contains the target count for each - * target update status + * + * + * @param */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - DataReportSeries targetStatus(); + public interface DateType { + /** + * @param s + * @return T + */ + T format(String s); + + /** + * h2 format. + * + * @return String + */ + String h2Format(); + + /** + * mysql format. + * + * @return String + */ + String mySqlFormat(); + } + + /** + * Return DateTypes. + */ + public static final class DateTypes implements Serializable { + private static final long serialVersionUID = 1L; + private static final PerMonth PER_MONTH = new PerMonth(); + + /** + * @return PerMonth + */ + public static PerMonth perMonth() { + return PER_MONTH; + } + + private DateTypes() { + + } + } + + /** + * Gives the date format based on DB H2 or mySql. + * + * + * + */ + public static final class PerMonth implements DateType, Serializable { + private static final long serialVersionUID = 1L; + private static final String DATE_PATTERN = "yyyy-MM"; + + @Override + public LocalDate format(final String s) { + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN); + final YearMonth ym = YearMonth.parse(s, formatter); + return ym.atDay(1); + } + + @Override + public String h2Format() { + return DATE_PATTERN; + } + + @Override + public String mySqlFormat() { + return "%Y-%m"; + } + + } /** * Generates a report of the top x distribution set assigned usage as a list @@ -81,22 +147,6 @@ public interface ReportManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) List> distributionUsageInstalled(int topXEntries); - /** - * Generates report for target created over period. - * - * @param dateType - * {@link PerMonth} - * @param from - * start date - * @param to - * end date - * @return DataReportSeries ListReportSeries list of target created - * count - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - DataReportSeries targetsCreatedOverPeriod(@NotNull DateType dateType, - @NotNull LocalDateTime from, @NotNull LocalDateTime to); - /** * Generates report for feedback over period. * @@ -113,6 +163,22 @@ public interface ReportManagement { DataReportSeries feedbackReceivedOverTime(@NotNull DateType dateType, @NotNull LocalDateTime from, @NotNull LocalDateTime to); + /** + * Generates report for target created over period. + * + * @param dateType + * {@link PerMonth} + * @param from + * start date + * @param to + * end date + * @return DataReportSeries ListReportSeries list of target created + * count + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + DataReportSeries targetsCreatedOverPeriod(@NotNull DateType dateType, + @NotNull LocalDateTime from, @NotNull LocalDateTime to); + /** * Generates a report as a {@link ListReportSeries} targets polled based on * the {@link TargetStatus#getLastTargetQuery()} within an hour, day, week, @@ -130,80 +196,14 @@ public interface ReportManagement { DataReportSeries targetsLastPoll(); /** - * Return DateTypes. + * Generates a report of all targets of their current update status count. + * For each {@link TargetUpdateStatus} an total count of targets which are + * in this status currently. + * + * @return a data report series which contains the target count for each + * target update status */ - public static final class DateTypes implements Serializable { - private static final long serialVersionUID = 1L; - private static final PerMonth PER_MONTH = new PerMonth(); - - private DateTypes() { - - } - - /** - * @return PerMonth - */ - public static PerMonth perMonth() { - return PER_MONTH; - } - } - - /** - * Data base format. - * - * - * - * @param - */ - public interface DateType { - /** - * @param s - * @return T - */ - T format(String s); - - /** - * h2 format. - * - * @return String - */ - String h2Format(); - - /** - * mysql format. - * - * @return String - */ - String mySqlFormat(); - } - - /** - * Gives the date format based on DB H2 or mySql. - * - * - * - */ - public static final class PerMonth implements DateType, Serializable { - private static final long serialVersionUID = 1L; - private static final String DATE_PATTERN = "yyyy-MM"; - - @Override - public LocalDate format(final String s) { - final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN); - final YearMonth ym = YearMonth.parse(s, formatter); - return ym.atDay(1); - } - - @Override - public String h2Format() { - return DATE_PATTERN; - } - - @Override - public String mySqlFormat() { - return "%Y-%m"; - } - - } + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + DataReportSeries targetStatus(); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java index 9654b8368..baff4586c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java @@ -27,47 +27,6 @@ import org.springframework.security.access.prepost.PreAuthorize; */ public interface RolloutGroupManagement { - /** - * Retrieves a single {@link RolloutGroup} by its ID. - * - * @param rolloutGroupId - * the ID of the rollout group to find - * @return the found {@link RolloutGroup} by its ID or {@code null} if it - * does not exists - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - RolloutGroup findRolloutGroupById(@NotNull Long rolloutGroupId); - - /** - * Retrieves a page of {@link RolloutGroup}s filtered by a given - * {@link Rollout}. - * - * @param rolloutId - * the ID of the rollout to filter the {@link RolloutGroup}s - * @param page - * the page request to sort and limit the result - * @return a page of found {@link RolloutGroup}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable page); - - /** - * Retrieves a page of {@link RolloutGroup}s filtered by a given - * {@link Rollout} and the given {@link Specification}. - * - * @param rolloutId - * the ID of the rollout to filter the {@link RolloutGroup}s - * @param specification - * the specification to filter the result set based on attributes - * of the {@link RolloutGroup} - * @param page - * the page request to sort and limit the result - * @return a page of found {@link RolloutGroup}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findRolloutGroupsAll(@NotNull Rollout rollout, - @NotNull Specification specification, @NotNull Pageable page); - /** * Retrieves a page of {@link RolloutGroup}s filtered by a given * {@link Rollout} with the detailed status. @@ -81,47 +40,6 @@ public interface RolloutGroupManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) Page findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable page); - /** - * Get count of targets in different status in rollout group. - * - * @param rolloutGroupId - * rollout group id - * @return rolloutGroup with details of targets count for different statuses - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - RolloutGroup findRolloutGroupWithDetailedStatus(@NotNull Long rolloutGroupId); - - // TODO discuss: target read perm missing? - /** - * Get targets of specified rollout group. - * - * @param rolloutGroup - * rollout group - * @param specification - * the specification for filtering the targets of a rollout group - * @param page - * the page request to sort and limit the result - * - * @return Page list of targets of a rollout group - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, - @NotNull Specification specification, @NotNull Pageable page); - - // TODO discuss: target read perm missing? - /** - * Get targets of specified rollout group. - * - * @param rolloutGroup - * rollout group - * @param page - * the page request to sort and limit the result - * - * @return Page list of targets of a rollout group - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull Pageable page); - // TODO discuss: target read perm missing? /** * @@ -141,4 +59,86 @@ public interface RolloutGroupManagement { Page findAllTargetsWithActionStatus(@NotNull PageRequest pageRequest, @NotNull RolloutGroup rolloutGroup); + /** + * Retrieves a single {@link RolloutGroup} by its ID. + * + * @param rolloutGroupId + * the ID of the rollout group to find + * @return the found {@link RolloutGroup} by its ID or {@code null} if it + * does not exists + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + RolloutGroup findRolloutGroupById(@NotNull Long rolloutGroupId); + + /** + * Retrieves a page of {@link RolloutGroup}s filtered by a given + * {@link Rollout} and the given {@link Specification}. + * + * @param rolloutId + * the ID of the rollout to filter the {@link RolloutGroup}s + * @param specification + * the specification to filter the result set based on attributes + * of the {@link RolloutGroup} + * @param page + * the page request to sort and limit the result + * @return a page of found {@link RolloutGroup}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findRolloutGroupsAll(@NotNull Rollout rollout, + @NotNull Specification specification, @NotNull Pageable page); + + /** + * Retrieves a page of {@link RolloutGroup}s filtered by a given + * {@link Rollout}. + * + * @param rolloutId + * the ID of the rollout to filter the {@link RolloutGroup}s + * @param page + * the page request to sort and limit the result + * @return a page of found {@link RolloutGroup}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable page); + + // TODO discuss: target read perm missing? + /** + * Get targets of specified rollout group. + * + * @param rolloutGroup + * rollout group + * @param page + * the page request to sort and limit the result + * + * @return Page list of targets of a rollout group + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull Pageable page); + + // TODO discuss: target read perm missing? + /** + * Get targets of specified rollout group. + * + * @param rolloutGroup + * rollout group + * @param specification + * the specification for filtering the targets of a rollout group + * @param page + * the page request to sort and limit the result + * + * @return Page list of targets of a rollout group + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, + @NotNull Specification specification, @NotNull Pageable page); + + /** + * Get count of targets in different status in rollout group. + * + * @param rolloutGroupId + * rollout group id + * @return rolloutGroup with details of targets count for different statuses + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + RolloutGroup findRolloutGroupWithDetailedStatus(@NotNull Long rolloutGroupId); + } \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 357108576..118be12fa 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -33,38 +33,54 @@ import org.springframework.security.access.prepost.PreAuthorize; public interface RolloutManagement { /** - * Retrieves all rollouts. + * Checking running rollouts. Rollouts which are checked updating the + * {@link Rollout#setLastCheck(long)} to indicate that the current instance + * is handling the specific rollout. This code should run as system-code. * - * @param page - * the page request to sort and limit the result - * @return a page of found rollouts + *
+     * {@code
+     *  SystemSecurityContext.runAsSystem(new Callable() {
+     *     public Void call() throws Exception {
+     *        //run system-code
+     *     }
+     * });
+     *  }
+     * 
+ * + * This method is attend to be called by a scheduler. + * {@link RolloutScheduler}. And must be running in an transaction so it's + * splitted from the scheduler. + * + * Rollouts which are currently running are investigated, by means the + * error- and finish condition of running groups in this rollout are + * evaluated. + * + * @param delayBetweenChecks + * the time in milliseconds of the delay between the further and + * this check. This check is only applied if the last check is + * less than (lastcheck-delay). */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAll(@NotNull Pageable page); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_SYSTEM_CODE) + void checkRunningRollouts(long delayBetweenChecks); /** - * Retrieves all rollouts found by the given specification. + * Counts all {@link Rollout}s in the repository. * - * @param specification - * the specification to filter rollouts - * @param page - * the page request to sort and limit the result - * @return a page of found rollouts + * @return number of roll outs */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAllWithDetailedStatusByPredicate(@NotNull Specification specification, - @NotNull Pageable page); + Long countRolloutsAll(); /** - * Retrieves a specific rollout by its ID. + * Count rollouts by given text in name or description. * - * @param rolloutId - * the ID of the rollout to retrieve - * @return the founded rollout or {@code null} if rollout with given ID does - * not exists + * @param searchText + * name or description + * @return total count rollouts for specified filter text. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Rollout findRolloutById(@NotNull Long rolloutId); + Long countRolloutsAllByFilters(@NotEmpty String searchText); /** * Persists a new rollout entity. The filter within the @@ -131,6 +147,138 @@ public interface RolloutManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE) Rollout createRolloutAsync(@NotNull Rollout rollout, int amountGroup, @NotNull RolloutGroupConditions conditions); + /** + * Retrieves all rollouts. + * + * @param page + * the page request to sort and limit the result + * @return a page of found rollouts + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findAll(@NotNull Pageable page); + + /** + * Get count of targets in different status in rollout. + * + * @param page + * the page request to sort and limit the result + * @return a list of rollouts with details of targets count for different + * statuses + * + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findAllRolloutsWithDetailedStatus(@NotNull Pageable page); + + /** + * Retrieves all rollouts found by the given specification. + * + * @param specification + * the specification to filter rollouts + * @param page + * the page request to sort and limit the result + * @return a page of found rollouts + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Page findAllWithDetailedStatusByPredicate(@NotNull Specification specification, + @NotNull Pageable page); + + /** + * Finds rollouts by given text in name or description. + * + * @param pageable + * the page request to sort and limit the result + * @param searchText + * search text which matches name or description of rollout + * @return the founded rollout or {@code null} if rollout with given ID does + * not exists + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Slice findRolloutByFilters(@NotNull Pageable pageable, @NotEmpty String searchText); + + /** + * Retrieves a specific rollout by its ID. + * + * @param rolloutId + * the ID of the rollout to retrieve + * @return the founded rollout or {@code null} if rollout with given ID does + * not exists + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Rollout findRolloutById(@NotNull Long rolloutId); + + /** + * Retrieves a specific rollout by its name. + * + * @param rolloutName + * the name of the rollout to retrieve + * @return the founded rollout or {@code null} if rollout with given name + * does not exists + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Rollout findRolloutByName(@NotNull String rolloutName); + + /** + * Get count of targets in different status in rollout. + * + * @param rolloutId + * rollout id + * @return rollout details of targets count for different statuses + * + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + Rollout findRolloutWithDetailedStatus(@NotNull Long rolloutId); + + /*** + * Get finished percentage details for a specified group which is in running + * state. + * + * @param rolloutId + * the ID of the {@link Rollout} + * @param rolloutGroup + * the ID of the {@link RolloutGroup} + * @return percentage finished + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) + float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull RolloutGroup rolloutGroup); + + /** + * Pauses a rollout which is currently running. The Rollout switches + * {@link RolloutStatus#PAUSED}. {@link RolloutGroup}s which are currently + * running will be untouched. {@link RolloutGroup}s which are + * {@link RolloutGroupStatus#SCHEDULED} will not be started and keep in + * {@link RolloutGroupStatus#SCHEDULED} state until the rollout is + * {@link RolloutManagement#resumeRollout(Rollout)}. + * + * Switching the rollout status to {@link RolloutStatus#PAUSED} is + * sufficient due the {@link #checkRunningRollouts(long)} will not check + * this rollout anymore. + * + * @param rollout + * the rollout to be paused. + * + * @throws RolloutIllegalStateException + * if given rollout is not in {@link RolloutStatus#RUNNING}. + * Only running rollouts can be paused. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_SYSTEM_CODE) + void pauseRollout(@NotNull Rollout rollout); + + /** + * Resumes a paused rollout. The rollout switches back to + * {@link RolloutStatus#RUNNING} state which is then picked up again by the + * {@link #checkRunningRollouts(long)}. + * + * @param rollout + * the rollout to be resumed + * @throws RolloutIllegalStateException + * if given rollout is not in {@link RolloutStatus#PAUSED}. Only + * paused rollouts can be resumed. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_SYSTEM_CODE) + void resumeRollout(@NotNull Rollout rollout); + /** * Starts a rollout which has been created. The rollout must be in * {@link RolloutStatus#READY} state. The according actions will be created @@ -176,118 +324,6 @@ public interface RolloutManagement { + SpringEvalExpressions.IS_SYSTEM_CODE) Rollout startRolloutAsync(@NotNull Rollout rollout); - /** - * Pauses a rollout which is currently running. The Rollout switches - * {@link RolloutStatus#PAUSED}. {@link RolloutGroup}s which are currently - * running will be untouched. {@link RolloutGroup}s which are - * {@link RolloutGroupStatus#SCHEDULED} will not be started and keep in - * {@link RolloutGroupStatus#SCHEDULED} state until the rollout is - * {@link RolloutManagement#resumeRollout(Rollout)}. - * - * Switching the rollout status to {@link RolloutStatus#PAUSED} is - * sufficient due the {@link #checkRunningRollouts(long)} will not check - * this rollout anymore. - * - * @param rollout - * the rollout to be paused. - * - * @throws RolloutIllegalStateException - * if given rollout is not in {@link RolloutStatus#RUNNING}. - * Only running rollouts can be paused. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_SYSTEM_CODE) - void pauseRollout(@NotNull Rollout rollout); - - /** - * Resumes a paused rollout. The rollout switches back to - * {@link RolloutStatus#RUNNING} state which is then picked up again by the - * {@link #checkRunningRollouts(long)}. - * - * @param rollout - * the rollout to be resumed - * @throws RolloutIllegalStateException - * if given rollout is not in {@link RolloutStatus#PAUSED}. Only - * paused rollouts can be resumed. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_SYSTEM_CODE) - void resumeRollout(@NotNull Rollout rollout); - - /** - * Checking running rollouts. Rollouts which are checked updating the - * {@link Rollout#setLastCheck(long)} to indicate that the current instance - * is handling the specific rollout. This code should run as system-code. - * - *
-     * {@code
-     *  SystemSecurityContext.runAsSystem(new Callable() {
-     *     public Void call() throws Exception {
-     *        //run system-code
-     *     }
-     * });
-     *  }
-     * 
- * - * This method is attend to be called by a scheduler. - * {@link RolloutScheduler}. And must be running in an transaction so it's - * splitted from the scheduler. - * - * Rollouts which are currently running are investigated, by means the - * error- and finish condition of running groups in this rollout are - * evaluated. - * - * @param delayBetweenChecks - * the time in milliseconds of the delay between the further and - * this check. This check is only applied if the last check is - * less than (lastcheck-delay). - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_SYSTEM_CODE) - void checkRunningRollouts(long delayBetweenChecks); - - /** - * Counts all {@link Rollout}s in the repository. - * - * @return number of roll outs - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Long countRolloutsAll(); - - /** - * Count rollouts by given text in name or description. - * - * @param searchText - * name or description - * @return total count rollouts for specified filter text. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Long countRolloutsAllByFilters(@NotEmpty String searchText); - - /** - * Finds rollouts by given text in name or description. - * - * @param pageable - * the page request to sort and limit the result - * @param searchText - * search text which matches name or description of rollout - * @return the founded rollout or {@code null} if rollout with given ID does - * not exists - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Slice findRolloutByFilters(@NotNull Pageable pageable, @NotEmpty String searchText); - - /** - * Retrieves a specific rollout by its name. - * - * @param rolloutName - * the name of the rollout to retrieve - * @return the founded rollout or {@code null} if rollout with given name - * does not exists - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Rollout findRolloutByName(@NotNull String rolloutName); - /** * Update rollout details. * @@ -299,40 +335,4 @@ public interface RolloutManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE) Rollout updateRollout(@NotNull Rollout rollout); - /** - * Get count of targets in different status in rollout. - * - * @param page - * the page request to sort and limit the result - * @return a list of rollouts with details of targets count for different - * statuses - * - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAllRolloutsWithDetailedStatus(@NotNull Pageable page); - - /** - * Get count of targets in different status in rollout. - * - * @param rolloutId - * rollout id - * @return rollout details of targets count for different statuses - * - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Rollout findRolloutWithDetailedStatus(@NotNull Long rolloutId); - - /*** - * Get finished percentage details for a specified group which is in running - * state. - * - * @param rolloutId - * the ID of the {@link Rollout} - * @param rolloutGroup - * the ID of the {@link RolloutGroup} - * @return percentage finished - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull RolloutGroup rolloutGroup); - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutProperties.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutProperties.java index 2384fa480..9b3a37093 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutProperties.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutProperties.java @@ -18,12 +18,6 @@ import org.springframework.stereotype.Component; @Component @ConfigurationProperties("hawkbit.rollout") public class RolloutProperties { - private final Scheduler scheduler = new Scheduler(); - - public Scheduler getScheduler() { - return scheduler; - } - /** * Rollout scheduler configuration. */ @@ -47,4 +41,10 @@ public class RolloutProperties { } + private final Scheduler scheduler = new Scheduler(); + + public Scheduler getScheduler() { + return scheduler; + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutScheduler.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutScheduler.java index 1d4150217..bc8f25feb 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutScheduler.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutScheduler.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository; import java.util.List; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java index 063a3a0f1..b3b9e7380 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java @@ -36,235 +36,6 @@ import org.springframework.security.access.prepost.PreAuthorize; */ public interface SoftwareManagement { - /** - * Updates existing {@link SoftwareModule}. Update-able values are - * {@link SoftwareModule#getDescription()} - * {@link SoftwareModule#getVendor()}. - * - * @param sm - * to update - * - * @return the saved {@link Entity}. - * - * @throws NullPointerException - * of {@link SoftwareModule#getId()} is null - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - SoftwareModule updateSoftwareModule(@NotNull SoftwareModule sm); - - /** - * Updates existing {@link SoftwareModuleType}. Update-able value is - * {@link SoftwareModuleType#getDescription()} and - * {@link SoftwareModuleType#getColour()}. - * - * @param sm - * to update - * @return updated {@link Entity} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm); - - /** - * - * @param swModule - * SoftwareModule to create - * @return SoftwareModule - * @throws EntityAlreadyExistsException - * if a given entity already exists - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - SoftwareModule createSoftwareModule(@NotNull SoftwareModule swModule); - - /** - * Create {@link SoftwareModule}s in the repository. - * - * @param swModules - * {@link SoftwareModule}s to create - * @return SoftwareModule - * @throws EntityAlreadyExistsException - * if a given entity already exists - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - List createSoftwareModule(@NotNull Iterable swModules); - - /** - * retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType} - * . - * - * @param pageable - * page parameters - * @param type - * to be filtered on - * @return the found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Slice findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull SoftwareModuleType type); - - /** - * Counts {@link SoftwareModule}s with given {@link SoftwareModuleType}. - * - * @param type - * to count - * @return number of found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Long countSoftwareModulesByType(@NotNull SoftwareModuleType type); - - /** - * Finds {@link SoftwareModule} by given id. - * - * @param id - * to search for - * @return the found {@link SoftwareModule}s or null if not - * found. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_CONTROLLER) - SoftwareModule findSoftwareModuleById(@NotNull Long id); - - /** - * retrieves {@link SoftwareModule} by their name AND version AND type.. - * - * @param name - * of the {@link SoftwareModule} - * @param version - * of the {@link SoftwareModule} - * @param type - * of the {@link SoftwareModule} - * @return the found {@link SoftwareModule} or null - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version, - @NotNull SoftwareModuleType type); - - /** - * Deletes the given {@link SoftwareModule} {@link Entity}. - * - * @param bsm - * is the {@link SoftwareModule} to be deleted - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - void deleteSoftwareModule(@NotNull SoftwareModule bsm); - - /** - * Deletes {@link SoftwareModule}s which is any if the given ids. - * - * @param ids - * of the Software Modules to be deleted - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - void deleteSoftwareModules(@NotNull Iterable ids); - - /** - * Retrieves all software modules. Deleted ones are filtered. - * - * @param pageable - * pagination parameter - * @return the found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Slice findSoftwareModulesAll(@NotNull Pageable pageable); - - /** - * Count all {@link SoftwareModule}s in the repository that are not marked - * as deleted. - * - * @return number of {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Long countSoftwareModulesAll(); - - /** - * Retrieves software module including details ( - * {@link SoftwareModule#getArtifacts()}). - * - * @param id - * parameter - * @param isDeleted - * parameter - * @return the found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id); - - /** - * Retrieves all {@link SoftwareModule}s with a given specification. - * - * @param spec - * the specification to filter the software modules - * @param pageable - * pagination parameter - * @return the found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findSoftwareModulesByPredicate(@NotNull Specification spec, - @NotNull Pageable pageable); - - /** - * Retrieves all {@link SoftwareModuleType}s with a given specification. - * - * @param spec - * the specification to filter the software modules types - * @param pageable - * pagination parameter - * @return the found {@link SoftwareModuleType}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findSoftwareModuleTypesByPredicate(@NotNull Specification spec, - @NotNull Pageable pageable); - - /** - * Retrieves all software modules with a given list of ids - * {@link SoftwareModule#getId()}. - * - * @param ids - * to search for - * @return {@link List} of found {@link SoftwareModule}s - */ - List findSoftwareModulesById(@NotEmpty Collection ids); - - /** - * Filter {@link SoftwareModule}s with given - * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} - * and {@link SoftwareModule#getType()} that are not marked as deleted. - * - * @param pageable - * page parameter - * @param searchText - * to be filtered as "like" on {@link SoftwareModule#getName()} - * @param type - * to be filtered as "like" on {@link SoftwareModule#getType()} - * @return the page of found {@link SoftwareModule} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Slice findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText, - SoftwareModuleType type); - - /** - * Filter {@link SoftwareModule}s with given - * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} - * search text and {@link SoftwareModule#getType()} that are not marked as - * deleted and sort them by means of given distribution set related modules - * on top of the list. - * - * After that the modules are sorted by {@link SoftwareModule#getName()} and - * {@link SoftwareModule#getVersion()} in ascending order. - * - * @param pageable - * page parameter - * @param orderByDistributionId - * the ID of distribution set to be ordered on top - * @param searchText - * filtered as "like" on {@link SoftwareModule#getName()} - * @param type - * filtered as "equal" on {@link SoftwareModule#getType()} - * @return the page of found {@link SoftwareModule} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Slice findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( - @NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, - SoftwareModuleType type); - /** * Counts {@link SoftwareModule}s with given * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} @@ -280,12 +51,23 @@ public interface SoftwareManagement { Long countSoftwareModuleByFilters(String searchText, SoftwareModuleType type); /** - * @param pageable - * parameter - * @return all {@link SoftwareModuleType}s in the repository. + * Count all {@link SoftwareModule}s in the repository that are not marked + * as deleted. + * + * @return number of {@link SoftwareModule}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findSoftwareModuleTypesAll(@NotNull Pageable pageable); + Long countSoftwareModulesAll(); + + /** + * Counts {@link SoftwareModule}s with given {@link SoftwareModuleType}. + * + * @param type + * to count + * @return number of found {@link SoftwareModule}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Long countSoftwareModulesByType(@NotNull SoftwareModuleType type); /** * @return number of {@link SoftwareModuleType}s in the repository. @@ -294,34 +76,63 @@ public interface SoftwareManagement { Long countSoftwareModuleTypesAll(); /** + * Create {@link SoftwareModule}s in the repository. * - * @param key - * to search for - * @return {@link SoftwareModuleType} in the repository with given - * {@link SoftwareModuleType#getKey()} + * @param swModules + * {@link SoftwareModule}s to create + * @return SoftwareModule + * @throws EntityAlreadyExistsException + * if a given entity already exists */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull String key); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + List createSoftwareModule(@NotNull Collection swModules); /** * - * @param id - * to search for - * @return {@link SoftwareModuleType} in the repository with given - * {@link SoftwareModuleType#getId()} + * @param swModule + * SoftwareModule to create + * @return SoftwareModule + * @throws EntityAlreadyExistsException + * if a given entity already exists */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModuleType findSoftwareModuleTypeById(@NotNull Long id); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + SoftwareModule createSoftwareModule(@NotNull SoftwareModule swModule); /** + * creates a list of software module meta data entries. * - * @param name - * to search for - * @return all {@link SoftwareModuleType}s in the repository with given - * {@link SoftwareModuleType#getName()} + * @param metadata + * the meta data entries to create or update + * @return the updated or created software module meta data entries + * @throws EntityAlreadyExistsException + * in case one of the meta data entry already exists for the + * specific key */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModuleType findSoftwareModuleTypeByName(@NotNull String name); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + List createSoftwareModuleMetadata(@NotNull Collection metadata); + + /** + * creates or updates a single software module meta data entry. + * + * @param metadata + * the meta data entry to create or update + * @return the updated or created software module meta data entry + * @throws EntityAlreadyExistsException + * in case the meta data entry already exists for the specific + * key + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata); + + /** + * Creates multiple {@link SoftwareModuleType}s. + * + * @param types + * to create + * @return created {@link Entity} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + List createSoftwareModuleType(@NotNull final Collection types); /** * Creates new {@link SoftwareModuleType}. @@ -334,14 +145,31 @@ public interface SoftwareManagement { SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleType type); /** - * Creates multiple {@link SoftwareModuleType}s. + * Deletes the given {@link SoftwareModule} {@link Entity}. * - * @param types - * to create - * @return created {@link Entity} + * @param bsm + * is the {@link SoftwareModule} to be deleted */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - List createSoftwareModuleType(@NotNull final Collection types); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) + void deleteSoftwareModule(@NotNull SoftwareModule bsm); + + /** + * deletes a software module meta data entry. + * + * @param id + * the ID of the software module meta data to delete + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + void deleteSoftwareModuleMetadata(@NotNull SwMetadataCompositeKey id); + + /** + * Deletes {@link SoftwareModule}s which is any if the given ids. + * + * @param ids + * of the Software Modules to be deleted + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) + void deleteSoftwareModules(@NotNull Collection ids); /** * Deletes or marks as delete in case the type is in use. @@ -378,52 +206,61 @@ public interface SoftwareManagement { @NotNull SoftwareModuleType type); /** - * creates or updates a single software module meta data entry. + * Filter {@link SoftwareModule}s with given + * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} + * and {@link SoftwareModule#getType()} that are not marked as deleted. * - * @param metadata - * the meta data entry to create or update - * @return the updated or created software module meta data entry - * @throws EntityAlreadyExistsException - * in case the meta data entry already exists for the specific - * key + * @param pageable + * page parameter + * @param searchText + * to be filtered as "like" on {@link SoftwareModule#getName()} + * @param type + * to be filtered as "like" on {@link SoftwareModule#getType()} + * @return the page of found {@link SoftwareModule} */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Slice findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText, + SoftwareModuleType type); /** - * creates a list of software module meta data entries. - * - * @param metadata - * the meta data entries to create or update - * @return the updated or created software module meta data entries - * @throws EntityAlreadyExistsException - * in case one of the meta data entry already exists for the - * specific key - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - List createSoftwareModuleMetadata(@NotNull Collection metadata); - - /** - * updates a distribution set meta data value if corresponding entry exists. - * - * @param metadata - * the meta data entry to be updated - * @return the updated meta data entry - * @throws EntityNotFoundException - * in case the meta data entry does not exists and cannot be - * updated - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata); - - /** - * deletes a software module meta data entry. + * Finds {@link SoftwareModule} by given id. * * @param id - * the ID of the software module meta data to delete + * to search for + * @return the found {@link SoftwareModule}s or null if not + * found. */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - void deleteSoftwareModuleMetadata(@NotNull SwMetadataCompositeKey id); + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_CONTROLLER) + SoftwareModule findSoftwareModuleById(@NotNull Long id); + + /** + * retrieves {@link SoftwareModule} by their name AND version AND type.. + * + * @param name + * of the {@link SoftwareModule} + * @param version + * of the {@link SoftwareModule} + * @param type + * of the {@link SoftwareModule} + * @return the found {@link SoftwareModule} or null + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version, + @NotNull SoftwareModuleType type); + + /** + * finds a single software module meta data by its id. + * + * @param id + * the id of the software module meta data containing the meta + * data key and the ID of the software module + * @return the found SoftwareModuleMetadata or {@code null} if not exits + * @throws EntityNotFoundException + * in case the meta data does not exists for the given key + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SwMetadataCompositeKey id); /** * finds all meta data by the given software module id. @@ -456,16 +293,179 @@ public interface SoftwareManagement { @NotNull Specification spec, @NotNull Pageable pageable); /** - * finds a single software module meta data by its id. + * Filter {@link SoftwareModule}s with given + * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} + * search text and {@link SoftwareModule#getType()} that are not marked as + * deleted and sort them by means of given distribution set related modules + * on top of the list. + * + * After that the modules are sorted by {@link SoftwareModule#getName()} and + * {@link SoftwareModule#getVersion()} in ascending order. * - * @param id - * the id of the software module meta data containing the meta - * data key and the ID of the software module - * @return the found SoftwareModuleMetadata or {@code null} if not exits - * @throws EntityNotFoundException - * in case the meta data does not exists for the given key + * @param pageable + * page parameter + * @param orderByDistributionId + * the ID of distribution set to be ordered on top + * @param searchText + * filtered as "like" on {@link SoftwareModule#getName()} + * @param type + * filtered as "equal" on {@link SoftwareModule#getType()} + * @return the page of found {@link SoftwareModule} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SwMetadataCompositeKey id); + Slice findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( + @NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, + SoftwareModuleType type); + + /** + * Retrieves all software modules. Deleted ones are filtered. + * + * @param pageable + * pagination parameter + * @return the found {@link SoftwareModule}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Slice findSoftwareModulesAll(@NotNull Pageable pageable); + + /** + * Retrieves all software modules with a given list of ids + * {@link SoftwareModule#getId()}. + * + * @param ids + * to search for + * @return {@link List} of found {@link SoftwareModule}s + */ + List findSoftwareModulesById(@NotEmpty Collection ids); + + /** + * Retrieves all {@link SoftwareModule}s with a given specification. + * + * @param spec + * the specification to filter the software modules + * @param pageable + * pagination parameter + * @return the found {@link SoftwareModule}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModulesByPredicate(@NotNull Specification spec, + @NotNull Pageable pageable); + + /** + * retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType} + * . + * + * @param pageable + * page parameters + * @param type + * to be filtered on + * @return the found {@link SoftwareModule}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Slice findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull SoftwareModuleType type); + + /** + * + * @param id + * to search for + * @return {@link SoftwareModuleType} in the repository with given + * {@link SoftwareModuleType#getId()} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + SoftwareModuleType findSoftwareModuleTypeById(@NotNull Long id); + + /** + * + * @param key + * to search for + * @return {@link SoftwareModuleType} in the repository with given + * {@link SoftwareModuleType#getKey()} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull String key); + + /** + * + * @param name + * to search for + * @return all {@link SoftwareModuleType}s in the repository with given + * {@link SoftwareModuleType#getName()} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + SoftwareModuleType findSoftwareModuleTypeByName(@NotNull String name); + + /** + * @param pageable + * parameter + * @return all {@link SoftwareModuleType}s in the repository. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleTypesAll(@NotNull Pageable pageable); + + /** + * Retrieves all {@link SoftwareModuleType}s with a given specification. + * + * @param spec + * the specification to filter the software modules types + * @param pageable + * pagination parameter + * @return the found {@link SoftwareModuleType}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleTypesByPredicate(@NotNull Specification spec, + @NotNull Pageable pageable); + + /** + * Retrieves software module including details ( + * {@link SoftwareModule#getArtifacts()}). + * + * @param id + * parameter + * @param isDeleted + * parameter + * @return the found {@link SoftwareModule}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id); + + /** + * Updates existing {@link SoftwareModule}. Update-able values are + * {@link SoftwareModule#getDescription()} + * {@link SoftwareModule#getVendor()}. + * + * @param sm + * to update + * + * @return the saved {@link Entity}. + * + * @throws NullPointerException + * of {@link SoftwareModule#getId()} is null + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + SoftwareModule updateSoftwareModule(@NotNull SoftwareModule sm); + + /** + * updates a distribution set meta data value if corresponding entry exists. + * + * @param metadata + * the meta data entry to be updated + * @return the updated meta data entry + * @throws EntityNotFoundException + * in case the meta data entry does not exists and cannot be + * updated + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata); + + /** + * Updates existing {@link SoftwareModuleType}. Update-able value is + * {@link SoftwareModuleType#getDescription()} and + * {@link SoftwareModuleType#getColour()}. + * + * @param sm + * to update + * @return updated {@link Entity} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java new file mode 100644 index 000000000..b62ed0ad3 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import java.util.List; + +import javax.validation.constraints.NotNull; + +import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.report.model.SystemUsageReport; +import org.eclipse.hawkbit.repository.model.TenantMetaData; +import org.eclipse.hawkbit.tenancy.TenantAware; +import org.springframework.cache.interceptor.KeyGenerator; +import org.springframework.context.annotation.Bean; +import org.springframework.security.access.prepost.PreAuthorize; + +/** + * Central system management operations of the update server. + * + */ +public interface SystemManagement { + + /** + * Checks if a specific tenant exists. The tenant will not be created lazy. + * + * @return {@code true} in case the tenant exits or {@code false} if not + */ + String currentTenant(); + + /** + * Deletes all data related to a given tenant. + * + * @param tenant + * to delete + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) + void deleteTenant(@NotNull String tenant); + + /** + * + * @return list of all tenant names in the system. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_SYSTEM_CODE) + List findTenants(); + + /** + * Calculated system usage statistics, both overall for the entire system + * and per tenant; + * + * @return SystemUsageReport of the current system + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) + SystemUsageReport getSystemUsageStatistics(); + + /** + * @return {@link TenantMetaData} of {@link TenantAware#getCurrentTenant()} + */ + TenantMetaData getTenantMetadata(); + + // TODO figure out why this is necessary and clean this up + @Bean + KeyGenerator currentTenantKeyGenerator(); + + /** + * Returns {@link TenantMetaData} of given and current tenant. + * + * DISCLAIMER: this variant is used during initial login (where the tenant + * is not yet in the session). Please user {@link #getTenantMetadata()} for + * regular requests. + * + * @param tenant + * to retrieve data for + * @return {@link TenantMetaData} of given tenant + */ + TenantMetaData getTenantMetadata(@NotNull String tenant); + + /** + * Update call for {@link TenantMetaData}. + * + * @param metaData + * to update + * @return updated {@link TenantMetaData} entity + */ + TenantMetaData updateTenantMetadata(@NotNull TenantMetaData metaData); + +} \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java new file mode 100644 index 000000000..929bd745c --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java @@ -0,0 +1,236 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import java.util.Collection; +import java.util.List; + +import javax.validation.constraints.NotNull; + +import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.repository.model.Tag; +import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.repository.model.TargetTag; +import org.hibernate.validator.constraints.NotEmpty; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.security.access.prepost.PreAuthorize; + +/** + * Management service for {@link Tag}s. + * + */ +public interface TagManagement { + + /** + * count {@link TargetTag}s. + * + * @return size of {@link TargetTag}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + long countTargetTags(); + + /** + * Creates a {@link DistributionSet}. + * + * @param distributionSetTag + * to be created. + * @return the new {@link DistributionSet} + * @throws EntityAlreadyExistsException + * if distributionSetTag already exists + * + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + DistributionSetTag createDistributionSetTag(@NotNull DistributionSetTag distributionSetTag); + + /** + * Creates multiple {@link DistributionSetTag}s. + * + * @param distributionSetTags + * to be created + * @return the new {@link DistributionSetTag} + * @throws EntityAlreadyExistsException + * if a given entity already exists + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + List createDistributionSetTags(@NotNull Collection distributionSetTags); + + /** + * Creates a new {@link TargetTag}. + * + * @param targetTag + * to be created + * + * @return the new created {@link TargetTag} + * + * @throws EntityAlreadyExistsException + * if given object already exists + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) + TargetTag createTargetTag(@NotNull TargetTag targetTag); + + /** + * created multiple {@link TargetTag}s. + * + * @param targetTags + * to be created + * @return the new created {@link TargetTag}s + * + * @throws EntityAlreadyExistsException + * if given object has already an ID. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) + List createTargetTags(@NotNull Iterable targetTags); + + /** + * Deletes {@link DistributionSetTag} by given + * {@link DistributionSetTag#getName()}. + * + * @param tagName + * to be deleted + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) + void deleteDistributionSetTag(@NotEmpty String tagName); + + /** + * Deletes {@link TargetTag} with given name. + * + * @param targetTagName + * tag name of the {@link TargetTag} to be deleted + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET) + void deleteTargetTag(@NotEmpty String targetTagName); + + /** + * + * @return all {@link DistributionSetTag}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + List findAllDistributionSetTags(); + + /** + * returns all {@link DistributionSetTag}s. + * + * @param pageReq + * page parameter + * @return all {@link DistributionSetTag}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findAllDistributionSetTags(@NotNull Pageable pageReq); + + /** + * Retrieves all DistributionSet tags based on the given specification. + * + * @param spec + * the specification for the query + * @param pageable + * pagination parameter + * @return the found {@link DistributionSetTag}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findAllDistributionSetTags(@NotNull Specification spec, + @NotNull Pageable pageable); + + /** + * @return all {@link TargetTag}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findAllTargetTags(); + + /** + * returns all {@link TargetTag}s. + * + * @param pageReq + * page parameter + * + * @return all {@link TargetTag}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findAllTargetTags(@NotNull Pageable pageReq); + + /** + * Retrieves all target tags based on the given specification. + * + * @param spec + * the specification for the query + * @param pageable + * pagination parameter + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findAllTargetTags(@NotNull Specification spec, @NotNull Pageable pageable); + + /** + * Find {@link DistributionSet} based on given name. + * + * @param name + * to look for. + * @return {@link DistributionSet} or null if it does not exist + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + DistributionSetTag findDistributionSetTag(@NotEmpty String name); + + /** + * Finds {@link DistributionSetTag} by given id. + * + * @param id + * to search for + * @return the found {@link DistributionSetTag}s or null if not + * found. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + DistributionSetTag findDistributionSetTagById(@NotNull Long id); + + /** + * Find {@link TargetTag} based on given Name. + * + * @param name + * to look for. + * @return {@link TargetTag} or null if it does not exist + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + TargetTag findTargetTag(@NotEmpty String name); + + /** + * Finds {@link TargetTag} by given id. + * + * @param id + * to search for + * @return the found {@link TargetTag}s or null if not found. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + TargetTag findTargetTagById(@NotNull Long id); + + /** + * Updates an existing {@link DistributionSetTag}. + * + * @param distributionSetTag + * to be updated + * @return the updated {@link DistributionSet} + * @throws NullPointerException + * of {@link DistributionSetTag#getName()} is null + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + DistributionSetTag updateDistributionSetTag(@NotNull DistributionSetTag distributionSetTag); + + /** + * updates the {@link TargetTag}. + * + * @param targetTag + * the {@link TargetTag} with updated values + * @return the updated {@link TargetTag} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + TargetTag updateTargetTag(@NotNull TargetTag targetTag); + +} \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java new file mode 100644 index 000000000..caf045c93 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import javax.validation.constraints.NotNull; + +import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.repository.model.TargetFilterQuery; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.security.access.prepost.PreAuthorize; + +/** + * Management service for {@link TargetFilterQuery}s. + * + */ +public interface TargetFilterQueryManagement { + + /** + * creating new {@link TargetFilterQuery}. + * + * @param customTargetFilter + * @return the created {@link TargetFilterQuery} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) + TargetFilterQuery createTargetFilterQuery(@NotNull TargetFilterQuery customTargetFilter); + + /** + * Delete target filter query. + * + * @param targetFilterQueryId + * IDs of target filter query to be deleted + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET) + void deleteTargetFilterQuery(@NotNull Long targetFilterQueryId); + + /** + * + * Retrieves all target filter query{@link TargetFilterQuery}. + * + * @param pageable + * pagination parameter + * @return the found {@link TargetFilterQuery}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findAllTargetFilterQuery(@NotNull Pageable pageable); + + /** + * Retrieves all target filter query which {@link TargetFilterQuery}. + * + * + * @param pageable + * pagination parameter + * @param name + * target filter query name + * @return the page with the found {@link TargetFilterQuery} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findTargetFilterQueryByFilters(@NotNull Pageable pageable, String name); + + /** + * Find target filter query by id. + * + * @param targetFilterQueryId + * Target filter query id + * @return the found {@link TargetFilterQuery} + * + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + TargetFilterQuery findTargetFilterQueryById(@NotNull Long targetFilterQueryId); + + /** + * Find target filter query by name. + * + * @param targetFilterQueryName + * Target filter query name + * @return the found {@link TargetFilterQuery} + * + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + TargetFilterQuery findTargetFilterQueryByName(@NotNull String targetFilterQueryName); + + /** + * updates the {@link TargetFilterQuery}. + * + * @param targetFilterQuery + * to be updated + * @return the updated {@link TargetFilterQuery} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery); + +} \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java new file mode 100644 index 000000000..ae7724e31 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -0,0 +1,604 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import java.net.URI; +import java.util.Collection; +import java.util.List; + +import javax.persistence.Entity; +import javax.validation.constraints.NotNull; + +import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.Tag; +import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.repository.model.TargetFilterQuery; +import org.eclipse.hawkbit.repository.model.TargetIdName; +import org.eclipse.hawkbit.repository.model.TargetInfo; +import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; +import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; +import org.hibernate.validator.constraints.NotEmpty; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.security.access.prepost.PreAuthorize; + +/** + * Management service for {@link Target}s. + * + */ +public interface TargetManagement { + + /** + * Assign a {@link TargetTag} assignment to given {@link Target}s. + * + * @param targetIds + * to assign for + * @param tag + * to assign + * @return list of assigned targets + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + List assignTag(@NotEmpty Collection targetIds, @NotNull TargetTag tag); + + /** + * Counts number of targets with given + * {@link Target#getAssignedDistributionSet()}. + * + * @param distId + * to search for + * + * @return number of found {@link Target}s. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Long countTargetByAssignedDistributionSet(@NotNull Long distId); + + /** + * Count {@link Target}s for all the given filter parameters. + * + * @param status + * find targets having on of these {@link TargetUpdateStatus}s. + * Set to null in case this is not required. + * @param searchText + * to find targets having the text anywhere in name or + * description. Set null in case this is not + * required. + * @param installedOrAssignedDistributionSetId + * to find targets having the {@link DistributionSet} as + * installed or assigned. Set to null in case this + * is not required. + * @param tagNames + * to find targets which are having any one in this tag names. + * Set null in case this is not required. + * @param selectTargetWithNoTag + * flag to select targets with no tag assigned + * + * @return the found number {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Long countTargetByFilters(Collection status, String searchText, + Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames); + + /** + * Counts number of targets with given + * {@link TargetInfo#getInstalledDistributionSet()}. + * + * @param distId + * to search for + * @return number of found {@link Target}s. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Long countTargetByInstalledDistributionSet(@NotNull Long distId); + + /** + * Count {@link TargetFilterQuery}s for given target filter query. + * + * @param targetFilterQuery + * {link TargetFilterQuery} + * @return the found number {@link TargetFilterQuery}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Long countTargetByTargetFilterQuery(@NotEmpty String targetFilterQuery); + + /** + * Count {@link TargetFilterQuery}s for given filter parameter. + * + * @param targetFilterQuery + * {link TargetFilterQuery} + * @return the found number {@link TargetFilterQuery}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Long countTargetByTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery); + + /** + * Counts all {@link Target}s in the repository. + * + * @return number of targets + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Long countTargetsAll(); + + /** + * creating a new {@link Target}. + * + * @param target + * to be created + * @return the created {@link Target} + * + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_CONTROLLER) + Target createTarget(@NotNull Target target); + + /** + * creating new {@link Target}s including poll status data. useful + * especially in plug and play scenarios. + * + * @param target + * to be created * + * @param status + * of the target + * @param lastTargetQuery + * if a plug and play case + * @param address + * if a plug and play case + * + * @throws EntityAlreadyExistsException + * if {@link Target} with given {@link Target#getControllerId()} + * already exists. + * + * @return created {@link Target} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_CONTROLLER) + Target createTarget(@NotNull Target target, @NotNull TargetUpdateStatus status, Long lastTargetQuery, URI address); + + /** + * creates multiple {@link Target}s. If some of the given {@link Target}s + * already exists in the DB a {@link EntityAlreadyExistsException} is + * thrown. {@link Target}s contain all objects of the parameter targets, + * including duplicates. + * + * @param targets + * to be created. + * @return the created {@link Target}s + * + * @throws EntityAlreadyExistsException + * of one of the given targets already exist. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) + List createTargets(@NotNull Collection targets); + + /** + * creating a new {@link Target} including poll status data. useful + * especially in plug and play scenarios. + * + * @param targets + * to be created * + * @param status + * of the target + * @param lastTargetQuery + * if a plug and play case + * @param address + * if a plug and play case + * + * @return newly created target + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) + List createTargets(@NotNull Collection targets, @NotNull TargetUpdateStatus status, + Long lastTargetQuery, URI address); + + /** + * 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); + + /** + * finds all {@link Target#getControllerId()} which are currently in the + * database. + * + * @return all IDs of all {@link Target} in the system + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findAllTargetIds(); + + /** + * Finds all targets for all the given parameters but returns not the full + * target but {@link TargetIdName}. + * + * @param pageRequest + * the pageRequest to enhance the query for paging and sorting + * + * @param filterByStatus + * find targets having this {@link TargetUpdateStatus}s. Set to + * null in case this is not required. + * @param filterBySearchText + * to find targets having the text anywhere in name or + * description. Set null in case this is not + * required. + * @param installedOrAssignedDistributionSetId + * to find targets having the {@link DistributionSet} as + * installed or assigned. Set to null in case this + * is not required. + * @param filterByTagNames + * to find targets which are having any one in this tag names. + * Set null in case this is not required. + * @param selectTargetWithNoTag + * flag to select targets with no tag assigned + * + * @return the found {@link TargetIdName}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findAllTargetIdsByFilters(@NotNull Pageable pageRequest, + Collection filterByStatus, String filterBySearchText, + Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... filterByTagNames); + + /** + * Finds all targets for all the given parameter {@link TargetFilterQuery} + * and returns not the full target but {@link TargetIdName}. + * + * @param pageRequest + * the pageRequest to enhance the query for paging and sorting + * @param targetFilterQuery + * {@link TargetFilterQuery} + * @return the found {@link TargetIdName}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest, + @NotNull TargetFilterQuery targetFilterQuery); + + /** + * retrieves {@link Target}s by the assigned {@link DistributionSet} without + * details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()} + * possible. + * + * + * @param distributionSetID + * the ID of the {@link DistributionSet} + * @param pageReq + * page parameter + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) + Page findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq); + + /** + * Retrieves {@link Target}s by the assigned {@link DistributionSet} without + * details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()} + * possible including additional filtering based on the given {@code spec}. + * + * @param distributionSetID + * the ID of the {@link DistributionSet} + * @param spec + * the specification to filter the result set + * @param pageReq + * page parameter + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) + Page findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, + @NotNull Specification spec, @NotNull Pageable pageReq); + + /** + * Find {@link Target} based on given ID returns found Target without + * details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()} + * possible. + * + * @param controllerIDs + * to look for. + * @return List of found{@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findTargetByControllerID(@NotEmpty Collection controllerIDs); + + /** + * Find {@link Target} based on given ID returns found Target without + * details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()} + * possible. + * + * @param controllerId + * to look for. + * @return {@link Target} or null if it does not exist + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Target findTargetByControllerID(@NotEmpty String controllerId); + + /** + * Find {@link Target} based on given ID returns found Target with details, + * i.e. {@link Target#getTags()} and {@link Target#getActions()} are + * possible. + * + * Note: try to use {@link #findTargetByControllerID(String)} as much as + * possible. + * + * @param controllerId + * to look for. + * @return {@link Target} or null if it does not exist + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Target findTargetByControllerIDWithDetails(@NotEmpty String controllerId); + + /** + * Filter {@link Target}s for all the given parameters. If all parameters + * except pageable are null, all available {@link Target}s are returned. + * + * @param pageable + * page parameters + * @param status + * find targets having this {@link TargetUpdateStatus}s. Set to + * null in case this is not required. + * @param searchText + * to find targets having the text anywhere in name or + * description. Set null in case this is not + * required. + * @param installedOrAssignedDistributionSetId + * to find targets having the {@link DistributionSet} as + * installed or assigned. Set to null in case this + * is not required. + * @param tagNames + * to find targets which are having any one in this tag names. + * Set null in case this is not required. + * @param selectTargetWithNoTag + * flag to select targets with no tag assigned + * + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Slice findTargetByFilters(@NotNull Pageable pageable, Collection status, + String searchText, Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, + String... tagNames); + + /** + * retrieves {@link Target}s by the installed {@link DistributionSet}without + * details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()} + * possible. + * + * @param distributionSetID + * the ID of the {@link DistributionSet} + * @param pageReq + * page parameter + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) + Page findTargetByInstalledDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq); + + /** + * retrieves {@link Target}s by the installed {@link DistributionSet}without + * details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()} + * possible including additional filtering based on the given {@code spec}. + * + * @param distributionSetId + * the ID of the {@link DistributionSet} + * @param spec + * the specification to filter the result + * @param pageable + * page parameter + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) + Page findTargetByInstalledDistributionSet(@NotNull Long distributionSetId, + @NotNull Specification spec, @NotNull Pageable pageable); + + /** + * Retrieves the {@link Target} which have a certain + * {@link TargetUpdateStatus} without details, i.e. NO + * {@link Target#getTags()} and {@link Target#getActions()} possible. + * + * @param pageable + * page parameter + * @param status + * the {@link TargetUpdateStatus} to be filtered on + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findTargetByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status); + + /** + * Retrieves all targets without details, i.e. NO {@link Target#getTags()} + * and {@link Target#getActions()} possible + * + * @param pageable + * pagination parameter + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Slice findTargetsAll(@NotNull Pageable pageable); + + /** + * Retrieves all targets based on the given specification. + * + * @param spec + * the specification for the query + * @param pageable + * pagination parameter + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Page findTargetsAll(@NotNull Specification spec, @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 + * in string notation + * @param pageable + * pagination parameter + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Slice findTargetsAll(@NotNull String targetFilterQuery, @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 pageable + * pagination parameter + * + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Slice findTargetsAll(@NotNull TargetFilterQuery targetFilterQuery, @NotNull Pageable pageable); + + /** + * method retrieves all {@link Target}s from the repo in the following + * order: + *

+ * 1) {@link Target}s which have the given {@link DistributionSet} as + * {@link Target#getTargetInfo()} + * {@link TargetInfo#getInstalledDistributionSet()} + *

+ * 2) {@link Target}s which have the given {@link DistributionSet} as + * {@link Target#getAssignedDistributionSet()} + *

+ * 3) {@link Target}s which have no connection to the given + * {@link DistributionSet}. + * + * @param pageable + * the page request to page the result set + * @param orderByDistributionId + * {@link DistributionSet#getId()} to be ordered by + * @param filterByDistributionId + * {@link DistributionSet#getId()} to be filter the result. Set + * to null in case this is not required. + * @param filterByStatus + * find targets having this {@link TargetUpdateStatus}s. Set to + * null in case this is not required. + * @param filterBySearchText + * to find targets having the text anywhere in name or + * description. Set null in case this is not + * required. + * @param installedOrAssignedDistributionSetId + * to find targets having the {@link DistributionSet} as + * installed or assigned. Set to null in case this + * is not required. + * @param filterByTagNames + * to find targets which are having any one in this tag names. + * Set null in case this is not required. + * @param selectTargetWithNoTag + * flag to select targets with no tag assigned + * @return a paged result {@link Page} of the {@link Target}s in a defined + * order. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Slice findTargetsAllOrderByLinkedDistributionSet(@NotNull Pageable pageable, + @NotNull Long orderByDistributionId, Long filterByDistributionId, + Collection filterByStatus, String filterBySearchText, Boolean selectTargetWithNoTag, + String... filterByTagNames); + + /** + * retrieves a list of {@link Target}s by their controller ID with details, + * i.e. {@link Target#getTags()} are possible. + * + * Note: try to use {@link #findTargetByControllerID(String)} as much as + * possible. + * + * @param controllerIDs + * {@link Target}s Names parameter + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findTargetsByControllerIDsWithTags(@NotNull List controllerIDs); + + /** + * Find targets by tag name. + * + * @param tagName + * tag name + * @return list of matching targets + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findTargetsByTag(@NotEmpty String tagName); + + /** + * Toggles {@link TargetTag} assignment to given {@link Target}s by means + * that if some (or all) of the targets in the list have the {@link Tag} not + * yet assigned, they will be. If all of theme have the tag already assigned + * they will be removed instead. + * + * @param targetIds + * to toggle for + * @param tagName + * to toggle + * @return TagAssigmentResult with all meta data of the assignment outcome. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection targetIds, @NotEmpty String tagName); + + /** + * {@link Entity} 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 targets, @NotNull TargetTag tag); + + /** + * Un-assign all {@link Target} from a given {@link TargetTag} . + * + * @param tag + * to un-assign all targets + * @return list of unassigned targets + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + List unAssignAllTargetsByTag(@NotNull TargetTag tag); + + /** + * Un-assign a {@link TargetTag} assignment to given {@link Target}. + * + * @param controllerID + * to un-assign for + * @param targetTag + * to un-assign + * @return the unassigned target or if no target is unassigned + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + Target unAssignTag(@NotEmpty String controllerID, @NotNull TargetTag targetTag); + + /** + * updates the {@link Target}. + * + * @param target + * to be updated + * @return the updated {@link Target} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_CONTROLLER) + Target updateTarget(@NotNull Target target); + + /** + * updates multiple {@link Target}s. + * + * @param targets + * to be updated + * @return the updated {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_CONTROLLER) + List updateTargets(@NotNull Iterable targets); + +} \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java index a5eaf4006..d9647e610 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java @@ -23,6 +23,74 @@ import org.springframework.security.access.prepost.PreAuthorize; */ public interface TenantConfigurationManagement { + /** + * Adds or updates a specific configuration for a specific tenant. + * + * + * @param configurationKey + * the key of the configuration + * @param value + * the configuration value which will be written into the + * database. + * @return the configuration value which was just written into the database. + * @throws TenantConfigurationValidatorException + * if the {@code propertyType} and the value in general does not + * match the expected type and format defined by the Key + * @throws ConversionFailedException + * if the property cannot be converted to the given + */ + @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) + TenantConfigurationValue addOrUpdateConfiguration(TenantConfigurationKey configurationKey, T value); + + /** + * Build the tenant configuration by the given key + * + * @param configurationKey + * the key + * @param propertyType + * the property type + * @param tenantConfiguration + * the configuration + * @return if no default value is set and no database value available + * or returns the tenant configuration value + */ + @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_SYSTEM_CODE) + TenantConfigurationValue buildTenantConfigurationValueByKey(TenantConfigurationKey configurationKey, + Class propertyType, TenantConfiguration tenantConfiguration); + + /** + * Deletes a specific configuration for the current tenant. Does nothing in + * case there is no tenant specific configuration value. + * + * @param configurationKey + * the configuration key to be deleted + */ + @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) + void deleteConfiguration(TenantConfigurationKey configurationKey); + + /** + * Retrieves a configuration value from the e.g. tenant overwritten + * configuration values or in case the tenant does not a have a specific + * configuration the global default value hold in the {@link Environment}. + * + * @param configurationKey + * the key of the configuration + * @return the converted configuration value either from the tenant specific + * configuration stored or from the fall back default values or + * {@code null} in case key has not been configured and not default + * value exists + * @throws TenantConfigurationValidatorException + * if the {@code propertyType} and the value in general does not + * match the expected type and format defined by the Key + * @throws ConversionFailedException + * if the property cannot be converted to the given + * {@code propertyType} + */ + @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR + + SpringEvalExpressions.IS_SYSTEM_CODE) + TenantConfigurationValue getConfigurationValue(TenantConfigurationKey configurationKey); + /** * Retrieves a configuration value from the e.g. tenant overwritten * configuration values or in case the tenant does not a have a specific @@ -51,45 +119,6 @@ public interface TenantConfigurationManagement { TenantConfigurationValue getConfigurationValue(TenantConfigurationKey configurationKey, Class propertyType); - /** - * Build the tenant configuration by the given key - * - * @param configurationKey - * the key - * @param propertyType - * the property type - * @param tenantConfiguration - * the configuration - * @return if no default value is set and no database value available - * or returns the tenant configuration value - */ - @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_SYSTEM_CODE) - TenantConfigurationValue buildTenantConfigurationValueByKey(TenantConfigurationKey configurationKey, - Class propertyType, TenantConfiguration tenantConfiguration); - - /** - * Retrieves a configuration value from the e.g. tenant overwritten - * configuration values or in case the tenant does not a have a specific - * configuration the global default value hold in the {@link Environment}. - * - * @param configurationKey - * the key of the configuration - * @return the converted configuration value either from the tenant specific - * configuration stored or from the fall back default values or - * {@code null} in case key has not been configured and not default - * value exists - * @throws TenantConfigurationValidatorException - * if the {@code propertyType} and the value in general does not - * match the expected type and format defined by the Key - * @throws ConversionFailedException - * if the property cannot be converted to the given - * {@code propertyType} - */ - @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_SYSTEM_CODE) - TenantConfigurationValue getConfigurationValue(TenantConfigurationKey configurationKey); - /** * returns the global configuration property either defined in the property * file or an default value otherwise. @@ -114,33 +143,4 @@ public interface TenantConfigurationManagement { + SpringEvalExpressions.IS_SYSTEM_CODE) T getGlobalConfigurationValue(TenantConfigurationKey configurationKey, Class propertyType); - /** - * Adds or updates a specific configuration for a specific tenant. - * - * - * @param configurationKey - * the key of the configuration - * @param value - * the configuration value which will be written into the - * database. - * @return the configuration value which was just written into the database. - * @throws TenantConfigurationValidatorException - * if the {@code propertyType} and the value in general does not - * match the expected type and format defined by the Key - * @throws ConversionFailedException - * if the property cannot be converted to the given - */ - @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) - TenantConfigurationValue addOrUpdateConfiguration(TenantConfigurationKey configurationKey, T value); - - /** - * Deletes a specific configuration for the current tenant. Does nothing in - * case there is no tenant specific configuration value. - * - * @param configurationKey - * the configuration key to be deleted - */ - @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) - void deleteConfiguration(TenantConfigurationKey configurationKey); - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java new file mode 100644 index 000000000..bb4ca8ef0 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.report.model.TenantUsage; +import org.springframework.security.access.prepost.PreAuthorize; + +/** + * Management service for statistics of a single tenant. + * + */ +public interface TenantStatsManagement { + + /** + * Service for stats of a single tenant. Opens a new transaction and as a + * result can an be used for multiple tenants, i.e. to allow in one session + * to collect data of all tenants in the system. + * + * @param tenant + * to collect for + * @return collected statistics + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) + TenantUsage getStatsOfTenant(String tenant); + +} \ No newline at end of file diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/DeploymentHelper.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/DeploymentHelper.java index adcca7c73..f5123c792 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/DeploymentHelper.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/DeploymentHelper.java @@ -14,6 +14,7 @@ import java.util.stream.Collectors; import javax.persistence.EntityManager; import javax.validation.constraints.NotNull; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Target; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java index 8834b2ae0..a7706440d 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java @@ -19,6 +19,7 @@ import javax.persistence.criteria.Root; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.repository.ControllerManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java index d905fb7b1..0c5df3b3f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.repository.jpa; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -33,6 +34,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.ForceQuitActionNotAllowedException; @@ -75,7 +77,7 @@ import com.google.common.collect.Lists; import com.google.common.eventbus.EventBus; /** - * JPA implementation for DeploymentManagement. + * JPA implementation for {@link DeploymentManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @@ -156,7 +158,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true) public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, - final List targets) { + final Collection targets) { final DistributionSet set = distributoinSetRepository.findOne(dsID); if (set == null) { throw new EntityNotFoundException( @@ -171,7 +173,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true) public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, - final List targets, final Rollout rollout, final RolloutGroup rolloutGroup) { + final Collection targets, final Rollout rollout, final RolloutGroup rolloutGroup) { final DistributionSet set = distributoinSetRepository.findOne(dsID); if (set == null) { throw new EntityNotFoundException( @@ -200,7 +202,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { * {@link DistributionSetType}. */ private DistributionSetAssignmentResult assignDistributionSetToTargets(@NotNull final DistributionSet set, - final List targetsWithActionType, final Rollout rollout, + final Collection targetsWithActionType, final Rollout rollout, final RolloutGroup rolloutGroup) { if (!set.isComplete()) { @@ -456,7 +458,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Override @Modifying @Transactional(isolation = Isolation.READ_COMMITTED) - public void createScheduledAction(final List targets, final DistributionSet distributionSet, + public void createScheduledAction(final Collection targets, final DistributionSet distributionSet, final ActionType actionType, final long forcedTime, final Rollout rollout, final RolloutGroup rolloutGroup) { // cancel all current scheduled actions for this target. E.g. an action diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java index d045cd549..da999e7cb 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java @@ -27,6 +27,8 @@ import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.repository.DistributionSetFilter; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.SystemManagement; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityLockedException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -59,7 +61,7 @@ import com.google.common.base.Strings; import com.google.common.eventbus.EventBus; /** - * Business facade for managing the {@link DistributionSet}s. + * JPA implementation of {@link DistributionSetManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaReportManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaReportManagement.java index f0f704352..523f91374 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaReportManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaReportManagement.java @@ -51,7 +51,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; /** - * Service layer for generating hawkBit reports. + * JPA implementation of {@link ReportManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java index 3de83d381..b7ced5511 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java @@ -40,15 +40,13 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; /** - * RolloutGroupManagement to control rollout groups. This service secures all - * the functionality based on the {@link PreAuthorize} annotation on methods. + * JPA implementation of {@link RolloutGroupManagement}. */ @Validated @Service diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java index 1f6e9b9a4..e4636f890 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java @@ -20,6 +20,7 @@ import javax.persistence.EntityManager; import org.eclipse.hawkbit.cache.CacheWriteNotify; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.RolloutManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; @@ -52,7 +53,6 @@ import org.springframework.data.domain.Sort.Direction; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.Modifying; import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; @@ -65,9 +65,7 @@ import org.springframework.util.Assert; import org.springframework.validation.annotation.Validated; /** - * RolloutManagement to control rollouts e.g. like creating, starting, resuming - * and pausing rollouts. This service secures all the functionality based on the - * {@link PreAuthorize} annotation on methods. + * JPA implementation of {@link RolloutManagement}. */ @Validated @Service diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java index a3566f07f..3f25dff29 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java @@ -59,7 +59,7 @@ import com.google.common.base.Strings; import com.google.common.collect.Sets; /** - * JPA implementation of SoftwareManagement. + * JPA implementation of {@link SoftwareManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @@ -148,7 +148,7 @@ public class JpaSoftwareManagement implements SoftwareManagement { @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - public List createSoftwareModule(final Iterable swModules) { + public List createSoftwareModule(final Collection swModules) { swModules.forEach(swModule -> { if (null != swModule.getId()) { throw new EntityAlreadyExistsException(); @@ -222,7 +222,7 @@ public class JpaSoftwareManagement implements SoftwareManagement { @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - public void deleteSoftwareModules(final Iterable ids) { + public void deleteSoftwareModules(final Collection ids) { final List swModulesToDelete = softwareModuleRepository.findByIdIn(ids); final Set assignedModuleIds = new HashSet<>(); swModulesToDelete.forEach(swModule -> { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java similarity index 82% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagement.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java index 67f7bf93f..b7a08fc2e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java @@ -14,11 +14,11 @@ import java.util.List; import java.util.stream.Collectors; import javax.persistence.EntityManager; -import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.cache.TenancyCacheManager; -import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.report.model.SystemUsageReport; +import org.eclipse.hawkbit.repository.SystemManagement; +import org.eclipse.hawkbit.repository.TenantStatsManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; @@ -33,7 +33,6 @@ import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleKeyGenerator; import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.Modifying; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -41,13 +40,13 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; /** - * Central system management operations of the SP server. + * JPA implementation of {@link SystemManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @Validated @Service -public class SystemManagement { +public class JpaSystemManagement implements SystemManagement { @Autowired private EntityManager entityManager; @@ -107,14 +106,7 @@ public class SystemManagement { private final ThreadLocal createInitialTenant = new ThreadLocal<>(); - /** - * Calculated system usage statistics, both overall for the entire system - * and per tenant; - * - * @return SystemUsageReport of the current system - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) + @Override public SystemUsageReport getSystemUsageStatistics() { BigDecimal sumOfArtifacts = (BigDecimal) entityManager @@ -156,35 +148,18 @@ public class SystemManagement { })); } - /** - * Registers the key generator for the {@link #currentTenant()} method - * because this key generator is aware of the {@link #createInitialTenant} - * thread local in case we are currently creating a tenant and insert the - * default distribution set types. - * - * @return the {@link CurrentTenantKeyGenerator} - */ - @Bean + @Override @Transactional(propagation = Propagation.SUPPORTS) - public CurrentTenantKeyGenerator currentTenantKeyGenerator() { + @Bean + public KeyGenerator currentTenantKeyGenerator() { return new CurrentTenantKeyGenerator(); } - /** - * Returns {@link TenantMetaData} of given and current tenant. - * - * DISCLAIMER: this variant is used during initial login (where the tenant - * is not yet in the session). Please user {@link #getTenantMetadata()} for - * regular requests. - * - * @param tenant - * @return - */ + @Override @Cacheable(value = "tenantMetadata", key = "#tenant.toUpperCase()") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @NotNull - public TenantMetaData getTenantMetadata(@NotNull final String tenant) { + public TenantMetaData getTenantMetadata(final String tenant) { final TenantMetaData result = tenantMetaDataRepository.findByTenantIgnoreCase(tenant); // Create if it does not exist @@ -201,28 +176,16 @@ public class SystemManagement { return result; } - /** - * - * @return list of all tenant names in the system. - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_SYSTEM_CODE) + @Override public List findTenants() { return tenantMetaDataRepository.findAll().stream().map(md -> md.getTenant()).collect(Collectors.toList()); } - /** - * Deletes all data related to a given tenant. - * - * @param tenant - * to delete - */ + @Override @CacheEvict(value = { "tenantMetadata" }, key = "#tenant.toUpperCase()") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) - public void deleteTenant(@NotNull final String tenant) { + public void deleteTenant(final String tenant) { cacheManager.evictCaches(tenant); cacheManager.getCache("currentTenant").evict(currentTenantKeyGenerator().generate(null, null)); tenantAware.runAsTenant(tenant, () -> { @@ -246,13 +209,10 @@ public class SystemManagement { }); } - /** - * @return {@link TenantMetaData} of {@link TenantAware#getCurrentTenant()} - */ + @Override @Cacheable(value = "tenantMetadata", keyGenerator = "tenantKeyGenerator") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @NotNull public TenantMetaData getTenantMetadata() { if (tenantAware.getCurrentTenant() == null) { throw new IllegalStateException("Tenant not set"); @@ -261,13 +221,7 @@ public class SystemManagement { return getTenantMetadata(tenantAware.getCurrentTenant()); } - /** - * Checks if a specific tenant exists. The tenant will not be created lazy. - * - * @param tenant - * the tenant to check - * @return {@code true} in case the tenant exits or {@code false} if not - */ + @Override @Cacheable(value = "currentTenant", keyGenerator = "currentTenantKeyGenerator") // set transaction to not supported, due we call this in // BaseEntity#prePersist methods @@ -290,18 +244,11 @@ public class SystemManagement { return initialTenantCreation; } - /** - * Update call for {@link TenantMetaData}. - * - * @param metaData - * to update - * @return updated {@link TenantMetaData} entity - */ + @Override @CachePut(value = "tenantMetadata", key = "#metaData.tenant.toUpperCase()") @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @NotNull - public TenantMetaData updateTenantMetadata(@NotNull final TenantMetaData metaData) { + public TenantMetaData updateTenantMetadata(final TenantMetaData metaData) { if (!tenantMetaDataRepository.exists(metaData.getId())) { throw new EntityNotFoundException("Metadata does not exist: " + metaData.getId()); } @@ -340,7 +287,7 @@ public class SystemManagement { * currently created and not the one currently in the {@link TenantAware}. * */ - private class CurrentTenantKeyGenerator implements KeyGenerator { + public class CurrentTenantKeyGenerator implements KeyGenerator { @Override // Exception squid:S923 - override @SuppressWarnings({ "squid:S923" }) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java similarity index 51% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TagManagement.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java index dbca65a00..f1b885b13 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TagManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTagManagement.java @@ -10,11 +10,10 @@ package org.eclipse.hawkbit.repository.jpa; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Collection; import java.util.LinkedList; import java.util.List; -import javax.validation.constraints.NotNull; - import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; @@ -22,21 +21,18 @@ import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; -import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; -import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.tenancy.TenantAware; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.Modifying; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; @@ -45,13 +41,13 @@ import org.springframework.validation.annotation.Validated; import com.google.common.eventbus.EventBus; /** - * Management service class for {@link Tag}s. + * JP>A implementation of {@link TagManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @Validated @Service -public class TagManagement { +public class JpaTagManagement implements TagManagement { @Autowired private TargetTagRepository targetTagRepository; @@ -74,34 +70,14 @@ public class TagManagement { @Autowired private AfterTransactionCommitExecutor afterCommit; - /** - * Find {@link TargetTag} based on given Name. - * - * @param name - * to look for. - * @return {@link TargetTag} or null if it does not exist - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public TargetTag findTargetTag(@NotEmpty final String name) { + @Override + public TargetTag findTargetTag(final String name) { return targetTagRepository.findByNameEquals(name); } - /** - * Creates a new {@link TargetTag}. - * - * @param targetTag - * to be created - * - * @return the new created {@link TargetTag} - * - * @throws EntityAlreadyExistsException - * if given object already exists - */ - @Modifying + @Override @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - public TargetTag createTargetTag(@NotNull final TargetTag targetTag) { + public TargetTag createTargetTag(final TargetTag targetTag) { if (null != targetTag.getId()) { throw new EntityAlreadyExistsException(); } @@ -118,21 +94,10 @@ public class TagManagement { return save; } - /** - * created multiple {@link TargetTag}s. - * - * @param targetTags - * to be created - * @return the new created {@link TargetTag}s - * - * @throws EntityAlreadyExistsException - * if given object has already an ID. - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - public List createTargetTags(@NotNull final Iterable targetTags) { + public List createTargetTags(final Iterable targetTags) { targetTags.forEach(tag -> { if (tag.getId() != null) { throw new EntityAlreadyExistsException(); @@ -144,16 +109,10 @@ public class TagManagement { return save; } - /** - * Deletes {@link TargetTag} with given name. - * - * @param targetTagName - * tag name of the {@link TargetTag} to be deleted - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET) - public void deleteTargetTag(@NotEmpty final String targetTagName) { + public void deleteTargetTag(final String targetTagName) { final TargetTag tag = targetTagRepository.findByNameEquals(targetTagName); final List changed = new LinkedList<>(); @@ -172,54 +131,25 @@ public class TagManagement { } - /** - * returns all {@link TargetTag}s. - * - * @return all {@link TargetTag}s - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public List findAllTargetTags() { return targetTagRepository.findAll(); } - /** - * Retrieves all target tags based on the given specification. - * - * @param spec - * the specification for the query - * @param pageable - * pagination parameter - * @return the found {@link Target}s, never {@code null} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findAllTargetTags(@NotNull final Specification spec, - @NotNull final Pageable pageable) { + @Override + public Page findAllTargetTags(final Specification spec, final Pageable pageable) { return targetTagRepository.findAll(spec, pageable); } - /** - * count {@link TargetTag}s. - * - * @return size of {@link TargetTag}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public long countTargetTags() { return targetTagRepository.count(); } - /** - * updates the {@link TargetTag}. - * - * @param targetTag - * the {@link TargetTag} - * @return the new {@link TargetTag} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public TargetTag updateTargetTag(@NotNull final TargetTag targetTag) { + public TargetTag updateTargetTag(final TargetTag targetTag) { checkNotNull(targetTag.getName()); checkNotNull(targetTag.getId()); final TargetTag save = targetTagRepository.save(targetTag); @@ -227,32 +157,15 @@ public class TagManagement { return save; } - /** - * Find {@link DistributionSet} based on given name. - * - * @param name - * to look for. - * @return {@link DistributionSet} or null if it does not exist - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public DistributionSetTag findDistributionSetTag(@NotEmpty final String name) { + @Override + public DistributionSetTag findDistributionSetTag(final String name) { return distributionSetTagRepository.findByNameEquals(name); } - /** - * Creates a {@link DistributionSet}. - * - * @param distributionSetTag - * to be created. - * @return the new {@link DistributionSet} - * @throws EntityAlreadyExistsException - * if distributionSetTag already exists - * - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - public DistributionSetTag createDistributionSetTag(@NotNull final DistributionSetTag distributionSetTag) { + public DistributionSetTag createDistributionSetTag(final DistributionSetTag distributionSetTag) { if (null != distributionSetTag.getId()) { throw new EntityAlreadyExistsException(); } @@ -268,20 +181,11 @@ public class TagManagement { return save; } - /** - * Creates multiple {@link DistributionSetTag}s. - * - * @param distributionSetTags - * to be created - * @return the new {@link DistributionSetTag} - * @throws EntityAlreadyExistsException - * if a given entity already exists - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) public List createDistributionSetTags( - @NotNull final Iterable distributionSetTags) { + final Collection distributionSetTags) { for (final DistributionSetTag dsTag : distributionSetTags) { if (dsTag.getId() != null) { throw new EntityAlreadyExistsException(); @@ -294,17 +198,10 @@ public class TagManagement { return save; } - /** - * Deletes {@link DistributionSetTag} by given - * {@link DistributionSetTag#getName()}. - * - * @param tagNames - * to be deleted - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - public void deleteDistributionSetTag(@NotEmpty final String tagName) { + public void deleteDistributionSetTag(final String tagName) { final DistributionSetTag tag = distributionSetTagRepository.findByNameEquals(tagName); final List changed = new LinkedList<>(); @@ -321,20 +218,10 @@ public class TagManagement { afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagDeletedEvent(tag))); } - /** - * Updates an existing {@link DistributionSetTag}. - * - * @param distributionSetTag - * to be updated - * @return the updated {@link DistributionSet} - * @throws NullPointerException - * of {@link DistributionSetTag#getName()} is null - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public DistributionSetTag updateDistributionSetTag(@NotNull final DistributionSetTag distributionSetTag) { + public DistributionSetTag updateDistributionSetTag(final DistributionSetTag distributionSetTag) { checkNotNull(distributionSetTag.getName()); checkNotNull(distributionSetTag.getId()); final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag); @@ -343,80 +230,34 @@ public class TagManagement { return save; } - /** - * returns all {@link DistributionTag}s. - * - * @return all {@link DistributionTag}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + @Override public List findAllDistributionSetTags() { return distributionSetTagRepository.findAll(); } - /** - * Finds {@link TargetTag} by given id. - * - * @param id - * to search for - * @return the found {@link TargetTag}s or null if not found. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public TargetTag findTargetTagById(@NotNull final Long id) { + @Override + public TargetTag findTargetTagById(final Long id) { return targetTagRepository.findOne(id); } - /** - * Finds {@link DistributionSetTag} by given id. - * - * @param id - * to search for - * @return the found {@link DistributionSetTag}s or null if not - * found. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public DistributionSetTag findDistributionSetTagById(@NotNull final Long id) { + @Override + public DistributionSetTag findDistributionSetTagById(final Long id) { return distributionSetTagRepository.findOne(id); } - /** - * returns all {@link TargetTag}s. - * - * @param pageReq - * page parameter - * - * @return all {@link TargetTag}s - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findAllTargetTags(@NotNull final Pageable pageReq) { + @Override + public Page findAllTargetTags(final Pageable pageReq) { return targetTagRepository.findAll(pageReq); } - /** - * returns all {@link DistributionSetTag}s. - * - * @param pageReq - * page parameter - * @return all {@link DistributionSetTag}s - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Page findAllDistributionSetTags(@NotNull final Pageable pageReq) { + @Override + public Page findAllDistributionSetTags(final Pageable pageReq) { return distributionSetTagRepository.findAll(pageReq); } - /** - * Retrieves all DistributionSet tags based on the given specification. - * - * @param spec - * the specification for the query - * @param pageable - * pagination parameter - * @return the found {@link DistributionSetTag}s, never {@code null} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findAllDistributionSetTags(@NotNull final Specification spec, - @NotNull final Pageable pageable) { + @Override + public Page findAllDistributionSetTags(final Specification spec, + final Pageable pageable) { return distributionSetTagRepository.findAll(spec, pageable); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetFilterQueryManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java similarity index 51% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetFilterQueryManagement.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java index 18ab0c486..a8c6b014f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetFilterQueryManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java @@ -11,9 +11,7 @@ package org.eclipse.hawkbit.repository.jpa; import java.util.ArrayList; import java.util.List; -import javax.validation.constraints.NotNull; - -import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder; @@ -24,7 +22,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specifications; import org.springframework.data.jpa.repository.Modifying; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; @@ -34,28 +31,21 @@ import org.springframework.validation.annotation.Validated; import com.google.common.base.Strings; /** - * Business service facade for managing {@link TargetFilterQuery}s. + * JPA implementation of {@link TargetFilterQueryManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @Validated @Service -public class TargetFilterQueryManagement { +public class JpaTargetFilterQueryManagement implements TargetFilterQueryManagement { @Autowired private TargetFilterQueryRepository targetFilterQueryRepository; - /** - * creating new {@link TargetFilterQuery}. - * - * @param customTargetFilter - * @return the created {@link TargetFilterQuery} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - public TargetFilterQuery createTargetFilterQuery(@NotNull final TargetFilterQuery customTargetFilter) { + public TargetFilterQuery createTargetFilterQuery(final TargetFilterQuery customTargetFilter) { if (targetFilterQueryRepository.findByName(customTargetFilter.getName()) != null) { throw new EntityAlreadyExistsException(customTargetFilter.getName()); @@ -63,44 +53,20 @@ public class TargetFilterQueryManagement { return targetFilterQueryRepository.save(customTargetFilter); } - /** - * Delete target filter query. - * - * @param targetFilterQueryId - * IDs of target filter query to be deleted - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET) - public void deleteTargetFilterQuery(@NotNull final Long targetFilterQueryId) { + public void deleteTargetFilterQuery(final Long targetFilterQueryId) { targetFilterQueryRepository.delete(targetFilterQueryId); } - /** - * - * Retrieves all target filter query{@link TargetFilterQuery}. - * - * @param pageable - * pagination parameter - * @return the found {@link TargetFilterQuery}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findAllTargetFilterQuery(@NotNull final Pageable pageable) { + @Override + public Page findAllTargetFilterQuery(final Pageable pageable) { return targetFilterQueryRepository.findAll(pageable); } - /** - * Retrieves all target filter query which {@link TargetFilterQuery}. - * - * - * @param pageable - * pagination parameter - * @param name - * target filter query name - * @return the page with the found {@link TargetFilterQuery} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findTargetFilterQueryByFilters(@NotNull final Pageable pageable, final String name) { + @Override + public Page findTargetFilterQueryByFilters(final Pageable pageable, final String name) { final List> specList = new ArrayList<>(); if (!Strings.isNullOrEmpty(name)) { specList.add(TargetFilterQuerySpecification.likeName(name)); @@ -108,15 +74,7 @@ public class TargetFilterQueryManagement { return findTargetFilterQueryByCriteriaAPI(pageable, specList); } - /** - * - * @param pageable - * pagination parameter - * @param specList - * list of @link {@link Specification} - * @return the page with the found {@link TargetFilterQuery} - */ - private Page findTargetFilterQueryByCriteriaAPI(@NotNull final Pageable pageable, + private Page findTargetFilterQueryByCriteriaAPI(final Pageable pageable, final List> specList) { if (specList == null || specList.isEmpty()) { return targetFilterQueryRepository.findAll(pageable); @@ -126,44 +84,20 @@ public class TargetFilterQueryManagement { return targetFilterQueryRepository.findAll(specs, pageable); } - /** - * Find target filter query by name. - * - * @param targetFilterQueryName - * Target filter query name - * @return the found {@link TargetFilterQuery} - * - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public TargetFilterQuery findTargetFilterQueryByName(@NotNull final String targetFilterQueryName) { + @Override + public TargetFilterQuery findTargetFilterQueryByName(final String targetFilterQueryName) { return targetFilterQueryRepository.findByName(targetFilterQueryName); } - /** - * Find target filter query by id. - * - * @param targetFilterQueryId - * Target filter query id - * @return the found {@link TargetFilterQuery} - * - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public TargetFilterQuery findTargetFilterQueryById(@NotNull final Long targetFilterQueryId) { + @Override + public TargetFilterQuery findTargetFilterQueryById(final Long targetFilterQueryId) { return targetFilterQueryRepository.findOne(targetFilterQueryId); } - /** - * updates the {@link TargetFilterQuery}. - * - * @param targetFilterQuery - * to be updated - * @return the updated {@link TargetFilterQuery} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public TargetFilterQuery updateTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) { + public TargetFilterQuery updateTargetFilterQuery(final TargetFilterQuery targetFilterQuery) { Assert.notNull(targetFilterQuery.getId()); return targetFilterQueryRepository.save(targetFilterQuery); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java similarity index 52% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetManagement.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java index 01d6eb527..513d5b52c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.stream.Collectors; import javax.annotation.PreDestroy; -import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; @@ -27,17 +26,14 @@ import javax.persistence.criteria.JoinType; import javax.persistence.criteria.Order; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.Constants; import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; -import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.TargetFields; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; -import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet_; -import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetIdName; @@ -50,7 +46,6 @@ import org.eclipse.hawkbit.repository.model.Target_; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder; import org.eclipse.hawkbit.repository.specifications.TargetSpecifications; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; import org.springframework.data.domain.Page; @@ -61,7 +56,6 @@ import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.Modifying; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; @@ -73,13 +67,13 @@ import com.google.common.collect.Lists; import com.google.common.eventbus.EventBus; /** - * Business service facade for managing {@link Target}s. + * JPA implementation of {@link TargetManagement}. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @Validated @Service -public class TargetManagement { +public class JpaTargetManagement implements TargetManagement { @Autowired private EntityManager entityManager; @@ -102,34 +96,13 @@ public class TargetManagement { @Autowired private AfterTransactionCommitExecutor afterCommit; - /** - * Find {@link Target} based on given ID returns found Target without - * details, i.e. NO {@link Target#getTags()} and - * {@link Target#getActiveActions()} possible. - * - * @param controllerId - * to look for. - * @return {@link Target} or null if it does not exist - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Target findTargetByControllerID(@NotEmpty final String controllerId) { + @Override + public Target findTargetByControllerID(final String controllerId) { return targetRepository.findByControllerId(controllerId); } - /** - * Find {@link Target} based on given ID returns found Target with details, - * i.e. {@link Target#getTags()} and {@link Target#getActiveActions()} are - * possible. - * - * Note: try to use {@link #findTargetByControllerID(String)} as much as - * possible. - * - * @param controllerId - * to look for. - * @return {@link Target} or null if it does not exist - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Target findTargetByControllerIDWithDetails(@NotEmpty final String controllerId) { + @Override + public Target findTargetByControllerIDWithDetails(final String controllerId) { final Target result = targetRepository.findByControllerId(controllerId); // load lazy relations if (result != null) { @@ -146,40 +119,18 @@ public class TargetManagement { return result; } - /** - * Find {@link Target} based on given ID returns found Target without - * details, i.e. NO {@link Target#getTags()} and - * {@link Target#getActiveActions()} possible. - * - * @param controllerIDs - * to look for. - * @return List of found{@link Target}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public List findTargetByControllerID(@NotEmpty final Collection controllerIDs) { + @Override + public List findTargetByControllerID(final Collection controllerIDs) { return targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs)); } - /** - * Counts all {@link Target}s in the repository. - * - * @return number of targets - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public Long countTargetsAll() { return targetRepository.count(); } - /** - * Retrieves all targets without details, i.e. NO {@link Target#getTags()} - * and {@link Target#getActiveActions()} possible - * - * @param pageable - * pagination parameter - * @return the found {@link Target}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Slice findTargetsAll(@NotNull final Pageable pageable) { + @Override + public Slice findTargetsAll(final Pageable pageable) { // workarround - no join fetch allowed that is why we need specification // instead of query for // count() of Pageable @@ -192,113 +143,50 @@ public class TargetManagement { return criteriaNoCountDao.findAll(spec, pageable, Target.class); } - /** - * Retrieves all targets without details, i.e. NO {@link Target#getTags()} - * and {@link Target#getActiveActions()} possible based on - * {@link TargetFilterQuery#getQuery()} - * - * @param targetFilterQuery - * @param pageable - * @return - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Slice findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery, - @NotNull final Pageable pageable) { + @Override + public Slice findTargetsAll(final TargetFilterQuery targetFilterQuery, final Pageable pageable) { return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class), pageable); } - /** - * Retrieves all targets without details, i.e. NO {@link Target#getTags()} - * and {@link Target#getActiveActions()} possible based on - * {@link TargetFilterQuery#getQuery()} - * - * @param targetFilterQuery - * @param pageable - * @return - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Slice findTargetsAll(@NotNull final String targetFilterQuery, @NotNull final Pageable pageable) { + @Override + public Slice findTargetsAll(final String targetFilterQuery, final Pageable pageable) { return findTargetsAll(RSQLUtility.parse(targetFilterQuery, TargetFields.class), pageable); } - /** - * Retrieves all targets based on the given specification. - * - * @param spec - * the specification for the query - * @param pageable - * pagination parameter - * @return the found {@link Target}s, never {@code null} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findTargetsAll(@NotNull final Specification spec, @NotNull final Pageable pageable) { + @Override + public Page findTargetsAll(final Specification spec, final Pageable pageable) { return targetRepository.findAll(spec, pageable); } - /** - * retrieves a list of {@link Target}s by their controller ID with details, - * i.e. {@link Target#getTags()} are possible. - * - * Note: try to use {@link #findTargetByControllerID(String)} as much as - * possible. - * - * @param controllerIDs - * {@link Target}s Names parameter - * @return the found {@link Target}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public List findTargetsByControllerIDsWithTags(@NotNull final List controllerIDs) { + @Override + public List findTargetsByControllerIDsWithTags(final List controllerIDs) { final List> partition = Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT); return partition.stream() .map(ids -> targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(ids))) .flatMap(t -> t.stream()).collect(Collectors.toList()); } - /** - * updates the {@link Target}. - * - * @param target - * to be updated - * @return the updated {@link Target} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_CONTROLLER) - public Target updateTarget(@NotNull final Target target) { + public Target updateTarget(final Target target) { Assert.notNull(target.getId()); target.setNew(false); return targetRepository.save(target); } - /** - * updates multiple {@link Target}s. - * - * @param targets - * to be updated - * @return the updated {@link Target}s - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_CONTROLLER) - public List updateTargets(@NotNull final List targets) { + public List updateTargets(final Iterable targets) { targets.forEach(target -> target.setNew(false)); return targetRepository.save(targets); } - /** - * Deletes all targets with the given IDs. - * - * @param targetIDs - * the technical IDs of the targets to be deleted - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET) - public void deleteTargets(@NotEmpty final Long... targetIDs) { + public void deleteTargets(final Long... targetIDs) { // we need to select the target IDs first to check the if the targetIDs // belonging to the // tenant! Delete statement are not automatically enhanced with the @@ -312,81 +200,25 @@ public class TargetManagement { } } - /** - * retrieves {@link Target}s by the assigned {@link DistributionSet} without - * details, i.e. NO {@link Target#getTags()} and - * {@link Target#getActiveActions()} possible. - * - * - * @param distributionSetID - * the ID of the {@link DistributionSet} - * @param pageReq - * page parameter - * @return the found {@link Target}s - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - public Page findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID, - @NotNull final Pageable pageReq) { + @Override + public Page findTargetByAssignedDistributionSet(final Long distributionSetID, final Pageable pageReq) { return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID); } - /** - * Retrieves {@link Target}s by the assigned {@link DistributionSet} without - * details, i.e. NO {@link Target#getTags()} and - * {@link Target#getActiveActions()} possible including additional filtering - * based on the given {@code spec}. - * - * @param distributionSetID - * the ID of the {@link DistributionSet} - * @param spec - * the specification to filter the result set - * @param pageReq - * page parameter - * @return the found {@link Target}s, never {@code null} - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - public Page findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID, - final Specification spec, @NotNull final Pageable pageReq) { + @Override + public Page findTargetByAssignedDistributionSet(final Long distributionSetID, + final Specification spec, final Pageable pageReq) { return targetRepository.findAll((Specification) (root, query, cb) -> cb.and( TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb), spec.toPredicate(root, query, cb)), pageReq); } - /** - * retrieves {@link Target}s by the installed {@link DistributionSet}without - * details, i.e. NO {@link Target#getTags()} and - * {@link Target#getActiveActions()} possible. - * - * @param distributionSetID - * the ID of the {@link DistributionSet} - * @param pageReq - * page parameter - * @return the found {@link Target}s - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - public Page findTargetByInstalledDistributionSet(@NotNull final Long distributionSetID, - @NotNull final Pageable pageReq) { + @Override + public Page findTargetByInstalledDistributionSet(final Long distributionSetID, final Pageable pageReq) { return targetRepository.findByTargetInfoInstalledDistributionSetId(pageReq, distributionSetID); } - /** - * retrieves {@link Target}s by the installed {@link DistributionSet}without - * details, i.e. NO {@link Target#getTags()} and - * {@link Target#getActiveActions()} possible including additional filtering - * based on the given {@code spec}. - * - * @param distributionSetId - * the ID of the {@link DistributionSet} - * @param spec - * the specification to filter the result - * @param pageable - * page parameter - * @return the found {@link Target}s, never {@code null} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) + @Override public Page findTargetByInstalledDistributionSet(final Long distributionSetId, final Specification spec, final Pageable pageable) { return targetRepository.findAll((Specification) (root, query, cb) -> cb.and( @@ -394,82 +226,21 @@ public class TargetManagement { spec.toPredicate(root, query, cb)), pageable); } - /** - * Retrieves the {@link Target} which have a certain - * {@link TargetUpdateStatus} without details, i.e. NO - * {@link Target#getTags()} and {@link Target#getActiveActions()} possible. - * - * @param pageable - * page parameter - * @param status - * the {@link TargetUpdateStatus} to be filtered on - * @return the found {@link Target}s - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Page findTargetByUpdateStatus(@NotNull final Pageable pageable, - @NotNull final TargetUpdateStatus status) { + @Override + public Page findTargetByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) { return targetRepository.findByTargetInfoUpdateStatus(pageable, status); } - /** - * Filter {@link Target}s for all the given parameters. If all parameters - * except pageable are null, all available {@link Target}s are returned. - * - * @param pageable - * page parameters - * @param status - * find targets having this {@link TargetUpdateStatus}s. Set to - * null in case this is not required. - * @param searchText - * to find targets having the text anywhere in name or - * description. Set null in case this is not - * required. - * @param installedOrAssignedDistributionSetId - * to find targets having the {@link DistributionSet} as - * installed or assigned. Set to null in case this - * is not required. - * @param tagNames - * to find targets which are having any one in this tag names. - * Set null in case this is not required. - * @param selectTargetWithNoTag - * flag to select targets with no tag assigned - * - * @return the found {@link Target}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Slice findTargetByFilters(@NotNull final Pageable pageable, - final Collection status, final String searchText, - final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag, - final String... tagNames) { + @Override + public Slice findTargetByFilters(final Pageable pageable, final Collection status, + final String searchText, final Long installedOrAssignedDistributionSetId, + final Boolean selectTargetWithNoTag, final String... tagNames) { final List> specList = buildSpecificationList(status, searchText, installedOrAssignedDistributionSetId, selectTargetWithNoTag, true, tagNames); return findByCriteriaAPI(pageable, specList); } - /** - * Count {@link Target}s for all the given filter parameters. - * - * @param status - * find targets having on of these {@link TargetUpdateStatus}s. - * Set to null in case this is not required. - * @param searchText - * to find targets having the text anywhere in name or - * description. Set null in case this is not - * required. - * @param installedOrAssignedDistributionSetId - * to find targets having the {@link DistributionSet} as - * installed or assigned. Set to null in case this - * is not required. - * @param tagNames - * to find targets which are having any one in this tag names. - * Set null in case this is not required. - * @param selectTargetWithNoTag - * flag to select targets with no tag assigned - * - * @return the found number {@link Target}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public Long countTargetByFilters(final Collection status, final String searchText, final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag, final String... tagNames) { @@ -498,15 +269,6 @@ public class TargetManagement { return specList; } - /** - * executes findAll with the given {@link Target} {@link Specification}s. - * - * @param pageable - * paging parameter - * @param specList - * list of @link {@link Specification} - * @return the page with the found {@link Target} - */ private Slice findByCriteriaAPI(final Pageable pageable, final List> specList) { if (specList == null || specList.isEmpty()) { return criteriaNoCountDao.findAll(pageable, Target.class); @@ -522,44 +284,18 @@ public class TargetManagement { return targetRepository.count(SpecificationsBuilder.combineWithAnd(specList)); } - /** - * {@link Entity} based method call for - * {@link #toggleTagAssignment(Collection, String)}. - * - * @param targets - * to toggle for - * @param tag - * to toggle - * @return TagAssigmentResult with all metadata of the assignment outcome. - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final List targets, - @NotNull final TargetTag tag) { + public TargetTagAssignmentResult toggleTagAssignment(final Collection targets, final TargetTag tag) { return toggleTagAssignment( targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName()); } - /** - * Toggles {@link TargetTag} assignment to given {@link Target}s by means - * that if some (or all) of the targets in the list have the {@link Tag} not - * yet assigned, they will be. If all of theme have the tag already assigned - * they will be removed instead. - * - * @param targetIds - * to toggle for - * @param tagName - * to toogle - * @return TagAssigmentResult with all metadata of the assigment outcome. - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection targetIds, - @NotNull final String tagName) { + public TargetTagAssignmentResult toggleTagAssignment(final Collection targetIds, final String tagName) { final TargetTag tag = targetTagRepository.findByNameEquals(tagName); final List alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds); final List allTargets = targetRepository @@ -588,20 +324,10 @@ public class TargetManagement { return result; } - /** - * Assign a {@link TargetTag} assignment to given {@link Target}s. - * - * @param targetIds - * to assign for - * @param tagName - * to assign - * @return list of assigned targets - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public List assignTag(@NotEmpty final Collection targetIds, @NotNull final TargetTag tag) { + public List assignTag(final Collection targetIds, final TargetTag tag) { final List allTargets = targetRepository .findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds)); @@ -617,7 +343,7 @@ public class TargetManagement { return save; } - private List unAssignTag(@NotEmpty final Collection targets, @NotNull final TargetTag tag) { + private List unAssignTag(final Collection targets, final TargetTag tag) { targets.forEach(target -> target.getTags().remove(tag)); final List save = targetRepository.save(targets); @@ -629,83 +355,26 @@ public class TargetManagement { return save; } - /** - * Unassign all {@link Target} from a given {@link TargetTag} . - * - * @param tag - * to unassign all targets - * @return list of unassigned targets - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public List unAssignAllTargetsByTag(@NotNull final TargetTag tag) { + public List unAssignAllTargetsByTag(final TargetTag tag) { return unAssignTag(tag.getAssignedToTargets(), tag); } - /** - * Unassign a {@link TargetTag} assignment to given {@link Target}. - * - * @param controllerID - * to unassign for - * @param targetTag - * to unassign - * @return the unassigned target or if no target is unassigned - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) { + public Target unAssignTag(final String controllerID, final TargetTag targetTag) { final List allTargets = targetRepository .findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID))); final List unAssignTag = unAssignTag(allTargets, targetTag); return unAssignTag.isEmpty() ? null : unAssignTag.get(0); } - /** - * method retrieves all {@link Target}s from the repo in the following - * order: - *

- * 1) {@link Target}s which have the given {@link DistributionSet} as - * {@link Target#getTargetStatus()} - * {@link TargetStatus#getInstalledDistributionSet()} - *

- * 2) {@link Target}s which have the given {@link DistributionSet} as - * {@link Target#getAssignedDistributionSet()} - *

- * 3) {@link Target}s which have no connection to the given - * {@link DistributionSet}. - * - * @param pageable - * the page request to page the result set - * @param orderByDistributionId - * {@link DistributionSet#getId()} to be ordered by - * @param filterByDistributionId - * {@link DistributionSet#getId()} to be filter the result. Set - * to null in case this is not required. - * @param filterByStatus - * find targets having this {@link TargetUpdateStatus}s. Set to - * null in case this is not required. - * @param filterBySearchText - * to find targets having the text anywhere in name or - * description. Set null in case this is not - * required. - * @param installedOrAssignedDistributionSetId - * to find targets having the {@link DistributionSet} as - * installed or assigned. Set to null in case this - * is not required. - * @param filterByTagNames - * to find targets which are having any one in this tag names. - * Set null in case this is not required. - * @param selectTargetWithNoTag - * flag to select targets with no tag assigned - * @return a paged result {@link Page} of the {@link Target}s in a defined - * order. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Slice findTargetsAllOrderByLinkedDistributionSet(@NotNull final Pageable pageable, - @NotNull final Long orderByDistributionId, final Long filterByDistributionId, + @Override + public Slice findTargetsAllOrderByLinkedDistributionSet(final Pageable pageable, + final Long orderByDistributionId, final Long filterByDistributionId, final Collection filterByStatus, final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); @@ -756,9 +425,6 @@ public class TargetManagement { return new SliceImpl<>(resultList, pageable, hasNext); } - /** - * @param specifications - */ private static Predicate[] specificationsToPredicate(final List> specifications, final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { final Predicate[] predicates = new Predicate[specifications.size()]; @@ -768,40 +434,17 @@ public class TargetManagement { return predicates; } - /** - * Counts number of targets with given - * {@link Target#getAssignedDistributionSet()}. - * - * @param distId - * to search for - * - * @return number of found {@link Target}s. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public Long countTargetByAssignedDistributionSet(final Long distId) { return targetRepository.countByAssignedDistributionSetId(distId); } - /** - * Counts number of targets with given - * {@link TargetStatus#getInstalledDistributionSet()}. - * - * @param distId - * to search for - * @return number of found {@link Target}s. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public Long countTargetByInstalledDistributionSet(final Long distId) { return targetRepository.countByTargetInfoInstalledDistributionSetId(distId); } - /** - * finds all {@link Target#getControllerId()} which are currently in the - * database. - * - * @return all IDs of all {@link Target} in the system - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public List findAllTargetIds() { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(TargetIdName.class); @@ -811,34 +454,8 @@ public class TargetManagement { } - /** - * Finds all targets for all the given parameters but returns not the full - * target but {@link TargetIdName}. - * - * @param pageRequest - * the pageRequest to enhance the query for paging and sorting - * - * @param filterByStatus - * find targets having this {@link TargetUpdateStatus}s. Set to - * null in case this is not required. - * @param filterBySearchText - * to find targets having the text anywhere in name or - * description. Set null in case this is not - * required. - * @param installedOrAssignedDistributionSetId - * to find targets having the {@link DistributionSet} as - * installed or assigned. Set to null in case this - * is not required. - * @param filterByTagNames - * to find targets which are having any one in this tag names. - * Set null in case this is not required. - * @param selectTargetWithNoTag - * flag to select targets with no tag assigned - * - * @return the found {@link TargetIdName}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public List findAllTargetIdsByFilters(@NotNull final Pageable pageRequest, + @Override + public List findAllTargetIdsByFilters(final Pageable pageRequest, final Collection filterByStatus, final String filterBySearchText, final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag, final String... filterByTagNames) { @@ -871,19 +488,9 @@ public class TargetManagement { .collect(Collectors.toList()); } - /** - * Finds all targets for all the given parameter {@link TargetFilterQuery} - * and returns not the full target but {@link TargetIdName}. - * - * @param pageRequest - * the pageRequest to enhance the query for paging and sorting - * @param targetFilterQuery - * {@link TargetFilterQuery} - * @return the found {@link TargetIdName}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + @Override public List findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest, - @NotNull final TargetFilterQuery targetFilterQuery) { + final TargetFilterQuery targetFilterQuery) { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(Object[].class); final Root targetRoot = query.from(Target.class); @@ -918,31 +525,12 @@ public class TargetManagement { eventBus.unregister(this); } - /** - * creating new {@link Target}s including poll status data. useful - * especially in plug and play scenarios. - * - * @param target - * to be created * - * @param status - * of the target - * @param lastTargetQuery - * if a plug and play case - * @param address - * if a plug and play case - * - * @throws EntityAlreadyExistsException - * - * @return - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_CONTROLLER) @CacheEvict(value = { "targetsCreatedOverPeriod" }, allEntries = true) - public Target createTarget(@NotNull final Target target, @NotNull final TargetUpdateStatus status, - final Long lastTargetQuery, final URI address) { + public Target createTarget(final Target target, final TargetUpdateStatus status, final Long lastTargetQuery, + final URI address) { if (targetRepository.findByControllerId(target.getControllerId()) != null) { throw new EntityAlreadyExistsException(target.getControllerId()); @@ -965,43 +553,18 @@ public class TargetManagement { } - /** - * creating a new {@link Target}. - * - * @param target - * to be created - * @return the created {@link Target} - * - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR - + SpringEvalExpressions.IS_CONTROLLER) @CacheEvict(value = { "targetsCreatedOverPeriod" }, allEntries = true) - public Target createTarget(@NotNull final Target target) { + public Target createTarget(final Target target) { return createTarget(target, TargetUpdateStatus.UNKNOWN, null, null); } - /** - * creates multiple {@link Target}s. If some of the given {@link Target}s - * already exists in the DB a {@link EntityAlreadyExistsException} is - * thrown. {@link Target}s contain all objects of the parameter targets, - * including duplicates. - * - * @param targets - * to be created. - * @return the created {@link Target}s - * - * @throws {@link - * EntityAlreadyExistsException} of one of the given targets - * already exist. - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - public List createTargets(@NotNull final List targets) { + public List createTargets(final Collection targets) { if (!targets.isEmpty() && targetRepository.countByControllerIdIn( targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) { throw new EntityAlreadyExistsException(); @@ -1014,27 +577,11 @@ public class TargetManagement { return savedTargets; } - /** - * creating a new {@link Target} including poll status data. useful - * especially in plug and play scenarios. - * - * @param targets - * to be created * - * @param status - * of the target - * @param lastTargetQuery - * if a plug and play case - * @param address - * if a plug and play case - * - * @return newly created target - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - public List createTargets(@NotNull final Collection targets, - @NotNull final TargetUpdateStatus status, final long lastTargetQuery, final URI address) { + public List createTargets(final Collection targets, final TargetUpdateStatus status, + final Long lastTargetQuery, final URI address) { if (targetRepository.countByControllerIdIn( targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) { throw new EntityAlreadyExistsException(); @@ -1047,42 +594,20 @@ public class TargetManagement { return savedTargets; } - /** - * Find targets by tag name. - * - * @param tagName - * tag name - * @return list of matching targets - */ - @NotNull - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public List findTargetsByTag(@NotNull final String tagName) { + @Override + public List findTargetsByTag(final String tagName) { final TargetTag tag = targetTagRepository.findByNameEquals(tagName); return targetRepository.findByTag(tag); } - /** - * Count {@link TargetFilterQuery}s for given filter parameter. - * - * @param targetFilterQuery - * {link TargetFilterQuery} - * @return the found number {@link TargetFilterQuery}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) { + @Override + public Long countTargetByTargetFilterQuery(final TargetFilterQuery targetFilterQuery) { final Specification specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class); return targetRepository.count(specs); } - /** - * Count {@link TargetFilterQuery}s for given target filter query. - * - * @param targetFilterQuery - * {link TargetFilterQuery} - * @return the found number {@link TargetFilterQuery}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) { + @Override + public Long countTargetByTargetFilterQuery(final String targetFilterQuery) { final Specification specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class); return targetRepository.count(specs); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TenantStatsManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTenantStatsManagement.java similarity index 73% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TenantStatsManagement.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTenantStatsManagement.java index 451a6e401..5c9cb7223 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/TenantStatsManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTenantStatsManagement.java @@ -10,10 +10,9 @@ package org.eclipse.hawkbit.repository.jpa; import java.util.Optional; -import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.report.model.TenantUsage; +import org.eclipse.hawkbit.repository.TenantStatsManagement; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -21,12 +20,12 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; /** - * Management service for stats of a single tenant. + * Management service for statistics of a single tenant. * */ @Validated @Service -public class TenantStatsManagement { +public class JpaTenantStatsManagement implements TenantStatsManagement { @Autowired private TargetRepository targetRepository; @@ -37,17 +36,8 @@ public class TenantStatsManagement { @Autowired private ActionRepository actionRepository; - /** - * Service for stats of a single tenant. Opens a new transaction and as a - * result can an be used for multiple tenants, i.e. to allow in one session - * to collect data of all tenants in the system. - * - * @param tenant - * to collect for - * @return collected statistics - */ + @Override @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) public TenantUsage getStatsOfTenant(final String tenant) { final TenantUsage result = new TenantUsage(tenant); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java index fd1d81280..d1327c690 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.repository.model.helper; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; +import org.eclipse.hawkbit.repository.SystemManagement; import org.springframework.beans.factory.annotation.Autowired; /** diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java index dafc21eef..b134a3315 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java @@ -23,6 +23,10 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.SystemManagement; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.jpa.ActionRepository; import org.eclipse.hawkbit.repository.jpa.ActionStatusRepository; @@ -36,11 +40,7 @@ import org.eclipse.hawkbit.repository.jpa.RolloutRepository; import org.eclipse.hawkbit.repository.jpa.SoftwareModuleMetadataRepository; import org.eclipse.hawkbit.repository.jpa.SoftwareModuleRepository; import org.eclipse.hawkbit.repository.jpa.SoftwareModuleTypeRepository; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; -import org.eclipse.hawkbit.repository.jpa.TagManagement; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.jpa.TargetInfoRepository; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.jpa.TargetRepository; import org.eclipse.hawkbit.repository.jpa.TargetTagRepository; import org.eclipse.hawkbit.repository.jpa.TenantMetaDataRepository; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java index 03a9b230f..1787d29e4 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java @@ -19,7 +19,7 @@ import org.apache.commons.io.IOUtils; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetType; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java index 3deba1a56..4c6af0d83 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java @@ -21,7 +21,6 @@ import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; -import org.eclipse.hawkbit.repository.jpa.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java index 37d4ea683..99e08f331 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java @@ -13,7 +13,6 @@ import static org.junit.Assert.fail; import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.junit.Test; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java index f27c7b707..73958e6fa 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java @@ -31,8 +31,8 @@ import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; -import org.eclipse.hawkbit.repository.jpa.TagManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java index a30927ebf..1a766c8c4 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java @@ -19,10 +19,10 @@ import org.eclipse.hawkbit.repository.DistributionSetFields; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetMetadataFields; import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TargetFields; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.jpa.TargetWithActionType; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java index e630003c5..eaa0fec28 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java @@ -13,8 +13,8 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.TagFields; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java index c5663f9f5..27cfdb924 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java @@ -16,8 +16,8 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.report.model.SystemUsageReport; import org.eclipse.hawkbit.report.model.TenantUsage; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; import org.eclipse.hawkbit.rest.resource.model.systemmanagement.CacheRest; import org.eclipse.hawkbit.rest.resource.model.systemmanagement.SystemStatisticsRest; import org.eclipse.hawkbit.rest.resource.model.systemmanagement.TenantSystemUsageRest; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java index df779c688..4b068a41e 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java @@ -19,8 +19,8 @@ import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.TargetFields; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.ActionStatus; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java index b6946145d..1a9155828 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java @@ -12,9 +12,9 @@ import java.util.List; import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.TagFields; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.TagManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java index ac1c95374..3705e8da3 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java @@ -33,9 +33,9 @@ import org.eclipse.hawkbit.WithUser; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.jpa.ActionRepository; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java index 1e3ab9b03..ce9f101f3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.common.tagdetails; import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; -import org.eclipse.hawkbit.repository.jpa.TagManagement; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.TargetTag; import org.springframework.beans.factory.annotation.Autowired; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java index bc46f50fd..178610c23 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java @@ -19,7 +19,7 @@ import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.TagManagement; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java index e607c99d2..6f03c5860 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index e92e4e735..c1ee96146 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -20,7 +20,7 @@ import java.util.Set; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.SoftwareModule; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java index c22e63241..1fd306816 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java @@ -15,8 +15,8 @@ import java.util.List; import java.util.Map; import org.eclipse.hawkbit.repository.DistributionSetFilter; -import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; +import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java index 940323b53..5bc1627a9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java @@ -15,7 +15,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java index 2abfcb731..b41f3dfe9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java @@ -14,7 +14,7 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.components.SPUIButton; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java index fe0ecf489..35f88f5a1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTarget; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java index 591a2f457..4f528c74a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.TargetFields; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.rsql.RSQLParameterSyntaxException; import org.eclipse.hawkbit.repository.rsql.RSQLParameterUnsupportedFieldException; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java index 37e25f152..4a2d6da6c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyTargetFilter; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java index b2b6d5913..17bfefe56 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java @@ -17,7 +17,7 @@ import java.util.Map; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.ui.common.ConfirmationDialog; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 1910aafdf..d13dc94cf 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -16,8 +16,8 @@ import java.util.Map; import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; import org.eclipse.hawkbit.repository.jpa.TenantMetaDataRepository; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java index 5d154dced..353ef3e95 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java @@ -14,8 +14,8 @@ import java.util.List; import java.util.Map; import org.eclipse.hawkbit.repository.DistributionSetFilter; -import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; +import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index a9cccc8c1..0df1b0ea5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -19,7 +19,7 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java index 0021f7bd1..9b66f2836 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.ui.management.tag.ProxyTag; import org.eclipse.hawkbit.ui.management.tag.TagIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java index 65b5dcdbd..ed002defb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java @@ -13,7 +13,7 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java index 4a6f8d824..ad537e626 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.management.footer; import java.util.Set; -import org.eclipse.hawkbit.repository.jpa.TagManagement; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java index 4e34ef606..56e11a6fe 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java @@ -22,7 +22,7 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java index ff88d2004..6bed7dd4f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java @@ -14,7 +14,7 @@ import java.util.Set; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.jpa.TagManagement; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.ui.common.CoordinatesToColor; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java index 1d720da22..2369893c7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java @@ -26,8 +26,8 @@ import java.util.concurrent.Executor; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.TagManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.Target; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java index d5eb6be5c..e54911d86 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.management.targettable; import java.util.HashSet; import java.util.Set; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index 3645e82d1..f3e0078f3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -13,8 +13,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java index 95e1da7b7..657cd97af 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java @@ -16,7 +16,7 @@ import java.util.Map; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.DeploymentManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 47e896a79..4ed2580f6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -22,8 +22,8 @@ import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent; import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent; import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java index 26d36c254..ac85b928b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.management.targettag; import java.io.Serializable; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick; import org.eclipse.hawkbit.ui.management.event.TargetFilterEvent; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java index b57d4d1c9..066383d8a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.TagManagement; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.ui.management.tag.ProxyTag; import org.eclipse.hawkbit.ui.management.tag.TagIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java index 8d76f45b7..48447f112 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -16,7 +16,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java index 92b24e301..7e8d45e1b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java @@ -14,7 +14,7 @@ import java.util.List; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.RolloutManagement; -import org.eclipse.hawkbit.repository.jpa.TargetManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java index 9422e431f..75d2741af 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java @@ -15,8 +15,8 @@ import java.util.List; import java.util.Map; import org.eclipse.hawkbit.repository.DistributionSetFilter; -import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; +import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; import org.eclipse.hawkbit.ui.components.ProxyDistribution; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java index c03b9e5d0..8a9675564 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; import org.eclipse.hawkbit.repository.RolloutManagement; -import org.eclipse.hawkbit.repository.jpa.TargetFilterQueryManagement; +import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java index 4660937cd..0162f6ed8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration; import javax.annotation.PostConstruct; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.SystemManagement; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.TenantMetaData; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;