diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java index ee73a1354..167b6019f 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java @@ -60,9 +60,17 @@ public interface ArtifactManagement { ExternalArtifact createExternalArtifact(@NotNull ExternalArtifactProvider externalRepository, String urlSuffix, @NotNull Long moduleId); + /** + * @return the total amount of local artifacts stored in the artifact + * management + */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) Long countLocalArtifactsAll(); + /** + * @return the total amount of external artifacts stored in the artifact + * management + */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) Long countExternalArtifactsAll(); diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 59518f854..1c2c71f8e 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -187,9 +187,15 @@ public interface DeploymentManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Long countActionsByTarget(@NotNull String rsqlParam, @NotNull Target target); + /** + * @return the total amount of stored action status + */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Long countActionStatusAll(); + /** + * @return the total amount of stored actions + */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Long countActionsAll(); @@ -280,8 +286,20 @@ public interface DeploymentManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Slice findActionsByTarget(@NotNull Pageable pageable, @NotNull Target target); + /** + * Retrieves all {@link Action} which assigned to a specific + * {@link DistributionSet}. + * + * @param pageable + * the page request parameter for paging and sorting the result + * @param distributionSet + * the distribution set which should be assigned to the actions + * in the result + * @return a list of {@link Action} which are assigned to a specific + * {@link DistributionSet} + */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull DistributionSet ds); + Slice findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull DistributionSet distributionSet); /** * Retrieves all {@link Action}s assigned to a specific {@link Target} and a @@ -345,8 +363,18 @@ public interface DeploymentManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Page findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action); + /** + * Retrieves all {@link ActionStatus} inclusive their messages by a specific + * {@link Action}. + * + * @param pageable + * the page request parameter for paging and sorting the result + * @param action + * the {@link Action} to retrieve the {@link ActionStatus} from + * @return a page of {@link ActionStatus} by a speciifc {@link Action} + */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findActionStatusByActionWithMessages(@NotNull Pageable pageReq, @NotNull Action action); + Page findActionStatusByActionWithMessages(@NotNull Pageable pageable, @NotNull Action action); /** * Retrieves all {@link Action}s of a specific target ordered by action ID. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java index 8ee3b7600..039e4ae13 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -18,8 +18,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.TenantMetaData; import org.eclipse.hawkbit.repository.report.model.SystemUsageReport; 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; /** @@ -67,10 +65,6 @@ public interface SystemManagement { */ TenantMetaData getTenantMetadata(); - // TODO figure out why this is necessary and clean this up - @Bean - KeyGenerator currentTenantKeyGenerator(); - /** * Returns {@link TenantMetaData} of given and current tenant. Creates for * new tenants also two {@link SoftwareModuleType} (os and app) and diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java index 9937084eb..734704f05 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java @@ -89,7 +89,7 @@ public interface TenantConfigurationManagement { */ @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_SYSTEM_CODE) - TenantConfigurationValue getConfigurationValue(TenantConfigurationKey configurationKey); + TenantConfigurationValue getConfigurationValue(TenantConfigurationKey configurationKey); /** * Retrieves a configuration value from the e.g. tenant overwritten diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java index e4d9f5bb7..3180fdb6a 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java @@ -16,44 +16,145 @@ package org.eclipse.hawkbit.repository.model; */ public interface RolloutGroup extends NamedEntity { + /** + * @return the corresponding {@link Rollout} of this group + */ Rollout getRollout(); + /** + * @param rollout + * sets the {@link Rollout} for this group + */ void setRollout(Rollout rollout); + /** + * @return the current {@link RolloutGroupStatus} for this group + */ RolloutGroupStatus getStatus(); + /** + * @param status + * the {@link RolloutGroupStatus} to set for this group + */ void setStatus(RolloutGroupStatus status); + /** + * @return the parent group of this group, in case the group is the root + * group it does not have a parent and so return {@code null} + */ RolloutGroup getParent(); + /** + * @return the {@link RolloutGroupSuccessCondition} for this group to + * indicate when a group is successful + */ RolloutGroupSuccessCondition getSuccessCondition(); - void setSuccessCondition(RolloutGroupSuccessCondition finishCondition); + /** + * @param successCondition + * the {@link RolloutGroupSuccessCondition} to be set for this + * group to indicate when a group is successfully and a next + * group might be started + */ + void setSuccessCondition(RolloutGroupSuccessCondition successCondition); + /** + * @return a String representation of the expression to be evaluated by the + * {@link RolloutGroupSuccessCondition} to indicate if the condition + * is true, might be {@code null} if no expression must be set for + * the {@link RolloutGroupSuccessCondition} + */ String getSuccessConditionExp(); - void setSuccessConditionExp(String finishExp); + /** + * @param successConditionExp + * sets a String represented expression which is evaluated by the + * {@link RolloutGroupSuccessCondition}, might be {@code null} if + * the set {@link RolloutGroupSuccessCondition} can handle + * {@code null} value + */ + void setSuccessConditionExp(String successConditionExp); + /** + * @return the {@link RolloutGroupErrorCondition} for this group to indicate + * when a group should marked as failed + */ RolloutGroupErrorCondition getErrorCondition(); + /** + * + * @param errorCondition + * the {@link RolloutGroupErrorCondition} to be set for this + * group to indicate when a group is marked as failed and the + * corresponding {@link RolloutGroupErrorAction} should be + * executed + */ void setErrorCondition(RolloutGroupErrorCondition errorCondition); + /** + * @return a String representation of the expression to be evaluated by the + * {@link RolloutGroupErrorCondition} to indicate if the condition + * is true, might be {@code null} if no expression must be set for + * the {@link RolloutGroupErrorCondition} + */ String getErrorConditionExp(); + /** + * @param errorExp + * sets a String represented expression which is evaluated by the + * {@link RolloutGroupErrorCondition}, might be {@code null} if + * the set {@link RolloutGroupErrorCondition} can handle + * {@code null} value + */ void setErrorConditionExp(String errorExp); + /** + * @return a {@link RolloutGroupErrorAction} which is executed when the + * given {@link RolloutGroupErrorCondition} is met, might be + * {@code null} if no error action is set + */ RolloutGroupErrorAction getErrorAction(); + /** + * @param errorAction + * the {@link RolloutGroupErrorAction} to be set which should be + * executed if the {@link RolloutGroupErrorCondition} is met, + * might be {@code null} if no error action should be executed + */ void setErrorAction(RolloutGroupErrorAction errorAction); + /** + * @return a String representation of the expression to be evaluated by the + * {@link RolloutGroupErrorAction} might be {@code null} if no + * expression must be set for the {@link RolloutGroupErrorAction} + */ String getErrorActionExp(); + /** + * @param errorActionExp + * sets a String represented expression which is evaluated by the + * {@link RolloutGroupErrorAction}, might be {@code null} if the + * set {@link RolloutGroupErrorAction} can handle {@code null} + * value + */ void setErrorActionExp(String errorActionExp); + /** + * @return the {@link RolloutGroupSuccessAction} which is executed if the + * {@link RolloutGroupSuccessCondition} is met + */ RolloutGroupSuccessAction getSuccessAction(); + /** + * @return a String representation of the expression to be evaluated by the + * {@link RolloutGroupSuccessAction} might be {@code null} if no + * expression must be set for the {@link RolloutGroupSuccessAction} + */ String getSuccessActionExp(); + /** + * @return the total amount of targets containing in this group + */ long getTotalTargets(); /** diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CurrentTenantCacheKeyGenerator.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CurrentTenantCacheKeyGenerator.java new file mode 100644 index 000000000..029246d2d --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CurrentTenantCacheKeyGenerator.java @@ -0,0 +1,40 @@ +/** + * 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.jpa; + +import org.springframework.cache.interceptor.KeyGenerator; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Service; + +/** + * Defines the interfaces to register the {@link KeyGenerator} as bean which is + * used by spring caching framework to resolve the key-generator. The + * key-generator must registered as bean so spring can resolve the key-generator + * by its name. + * + * When using the {@link Service} annotation e.g. by {@link JpaSystemManagement} + * the bean registration must be declared by the interface due spring registers + * the bean by the implemented interfaces. So introduce a single interface for + * the {@link JpaSystemManagement} implementation to allow it to register the + * key-generator bean. + * + */ +@FunctionalInterface +public interface CurrentTenantCacheKeyGenerator { + + /** + * Bean declaration to register a {@code currentTenantKeyGenerator} bean + * which is used by the caching framework. + * + * @return the {@link KeyGenerator} to be used to cache the values of the + * current used tenant in the {@link JpaSystemManagement} + */ + @Bean + KeyGenerator currentTenantKeyGenerator(); +} diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java index be46362a5..8f9e8c5f9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java @@ -49,7 +49,7 @@ import org.springframework.validation.annotation.Validated; @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @Validated @Service -public class JpaSystemManagement implements SystemManagement { +public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, SystemManagement { @Autowired private EntityManager entityManager;