From 3c0d5396b043434f1e2de19364584f971818a3fa Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 18 May 2016 16:16:30 +0200 Subject: [PATCH] Removed default implementations as JaCoCo has problems with those. Split software management. Signed-off-by: Kai Zimmermann --- .../SecurityManagedConfiguration.java | 6 +- .../amqp/AmqpMessageHandlerService.java | 8 +- .../amqp/AmqpMessageHandlerServiceTest.java | 2 +- .../repository/ArtifactManagement.java | 27 +- .../repository/ControllerManagement.java | 6 +- .../repository/DeploymentManagement.java | 19 +- .../repository/DistributionSetFilter.java | 3 - .../repository/DistributionSetManagement.java | 24 +- .../hawkbit/repository/ReportManagement.java | 2 +- .../repository/RolloutGroupManagement.java | 4 + .../hawkbit/repository/RolloutManagement.java | 2 +- .../hawkbit/repository/RolloutScheduler.java | 6 +- .../repository/SoftwareManagement.java | 471 ++++++++++++++++ .../TenantConfigurationManagement.java | 14 +- .../repository/jpa/DeploymentHelper.java | 100 ++++ .../repository/jpa/JpaArtifactManagement.java | 16 + .../jpa/JpaControllerManagement.java | 8 +- .../jpa/JpaDeploymentManagement.java | 1 - .../jpa/JpaDistributionSetManagement.java | 25 +- ...gement.java => JpaSoftwareManagement.java} | 508 ++++-------------- .../hawkbit/AbstractIntegrationTest.java | 2 +- .../org/eclipse/hawkbit/TestDataUtil.java | 2 +- .../repository/SoftwareManagementTest.java | 2 +- .../utils/RepositoryDataGenerator.java | 2 +- .../hawkbit/controller/RootController.java | 2 +- .../rest/resource/DistributionSetMapper.java | 2 +- .../resource/DistributionSetResource.java | 2 +- .../resource/DistributionSetTypeMapper.java | 2 +- .../resource/DistributionSetTypeResource.java | 2 +- .../resource/DownloadArtifactResource.java | 2 +- .../rest/resource/SoftwareModuleMapper.java | 2 +- .../rest/resource/SoftwareModuleResource.java | 2 +- .../resource/SoftwareModuleTypeResource.java | 2 +- .../resource/DistributionSetResourceTest.java | 2 +- .../UploadViewConfirmationWindowLayout.java | 2 +- .../smtable/BaseSwModuleBeanQuery.java | 2 +- .../SoftwareModuleAddUpdateWindow.java | 2 +- .../smtable/SoftwareModuleTable.java | 2 +- .../CreateUpdateSoftwareTypeLayout.java | 2 +- .../smtype/SMTypeFilterButtonClick.java | 2 +- .../common/SoftwareModuleTypeBeanQuery.java | 2 +- .../CreateUpdateDistSetTypeLayout.java | 2 +- .../dstable/DistributionSetDetails.java | 2 +- .../dstable/DistributionSetTable.java | 2 +- ...DistributionsConfirmationWindowLayout.java | 2 +- .../smtable/SwModuleBeanQuery.java | 2 +- .../distributions/smtable/SwModuleTable.java | 2 +- .../smtype/DistSMTypeFilterButtonClick.java | 2 +- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 2 +- pom.xml | 2 +- 50 files changed, 789 insertions(+), 523 deletions(-) create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/DeploymentHelper.java rename hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/{SoftwareManagement.java => JpaSoftwareManagement.java} (55%) 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 9638377eb..0b321842f 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-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java index f26d7f3f7..3756688c2 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java @@ -371,18 +371,18 @@ public class AmqpMessageHandlerService extends BaseAmqpService { logAndThrowMessageError(message, "Status for action does not exisit."); } - final Action addUpdateActionStatus = getUpdateActionStatus(action, actionStatus); + final Action addUpdateActionStatus = getUpdateActionStatus(actionStatus); if (!addUpdateActionStatus.isActive()) { lookIfUpdateAvailable(action.getTarget()); } } - private Action getUpdateActionStatus(final Action action, final ActionStatus actionStatus) { + private Action getUpdateActionStatus(final ActionStatus actionStatus) { if (actionStatus.getStatus().equals(Status.CANCELED)) { - return controllerManagement.addCancelActionStatus(actionStatus, action); + return controllerManagement.addCancelActionStatus(actionStatus); } - return controllerManagement.addUpdateActionStatus(actionStatus, action); + return controllerManagement.addUpdateActionStatus(actionStatus); } private Action checkActionExist(final Message message, final ActionUpdateStatus actionUpdateStatus) { diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index 3051e4e22..e057144df 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -346,7 +346,7 @@ public class AmqpMessageHandlerServiceTest { // Mock final Action action = createActionWithTarget(22L, Status.FINISHED); when(controllerManagementMock.findActionWithDetails(Matchers.any())).thenReturn(action); - when(controllerManagementMock.addUpdateActionStatus(Matchers.any(), Matchers.any())).thenReturn(action); + when(controllerManagementMock.addUpdateActionStatus(Matchers.any())).thenReturn(action); // for the test the same action can be used final List actionList = new ArrayList<>(); actionList.add(action); 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 977b9f171..19f3bcee2 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 @@ -32,8 +32,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.hateoas.Identifiable; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.transaction.annotation.Isolation; -import org.springframework.transaction.annotation.Transactional; /** * Service for {@link Artifact} management operations. @@ -99,11 +97,8 @@ public interface ArtifactManagement { * @throw ArtifactUploadFailedException if upload fails */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - @Transactional(isolation = Isolation.READ_UNCOMMITTED) - default LocalArtifact createLocalArtifact(final InputStream inputStream, final Long moduleId, final String filename, - final boolean overrideExisting) { - return createLocalArtifact(inputStream, moduleId, filename, null, null, overrideExisting, null); - } + LocalArtifact createLocalArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename, + final boolean overrideExisting); /** * Persists artifact binary as provided by given InputStream. assign the @@ -126,11 +121,8 @@ public interface ArtifactManagement { * @throw ArtifactUploadFailedException if upload fails */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - @Transactional(isolation = Isolation.READ_UNCOMMITTED) - default LocalArtifact createLocalArtifact(final InputStream inputStream, final Long moduleId, final String filename, - final boolean overrideExisting, final String contentType) { - return createLocalArtifact(inputStream, moduleId, filename, null, null, overrideExisting, contentType); - } + LocalArtifact createLocalArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, + @NotNull String filename, final boolean overrideExisting, @NotNull String contentType); /** * Persists artifact binary as provided by given InputStream. assign the @@ -282,14 +274,7 @@ public interface ArtifactManagement { * @return the found {@link SoftwareModule}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - default SoftwareModule findSoftwareModuleWithDetails(@NotNull final Long id) { - final SoftwareModule result = findSoftwareModuleById(id); - if (result != null) { - result.getArtifacts().size(); - } - - return result; - } + SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id); /** * Loads {@link org.eclipse.hawkbit.artifact.server.json.model.Artifact} @@ -307,4 +292,4 @@ public interface ArtifactManagement { + SpringEvalExpressions.HAS_CONTROLLER_DOWNLOAD) DbArtifact loadLocalArtifactBinary(@NotNull LocalArtifact artifact); -} \ No newline at end of file +} 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 b70ad3bdd..2b18ab7ff 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 @@ -249,9 +249,7 @@ public interface ControllerManagement { */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) @Transactional(isolation = Isolation.READ_UNCOMMITTED) - default TargetInfo updateLastTargetQuery(@NotNull final TargetInfo target, @NotNull final URI address) { - return updateTargetStatus(target, null, System.currentTimeMillis(), address); - } + TargetInfo updateLastTargetQuery(@NotNull TargetInfo target, @NotNull URI address); /** * Update selective the target status of a given {@code target}. @@ -273,4 +271,4 @@ public interface ControllerManagement { TargetInfo updateTargetStatus(@NotNull TargetInfo targetInfo, TargetUpdateStatus status, Long lastTargetQuery, URI address); -} \ No newline at end of file +} 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 789383ce7..cffc3b8ad 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,9 +8,7 @@ */ package org.eclipse.hawkbit.repository; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import javax.validation.constraints.NotNull; @@ -82,14 +80,8 @@ public interface DeploymentManagement { * {@link DistributionSetType}. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - // Exception squid:S2095: see - // https://jira.sonarsource.com/browse/SONARJAVA-1478 - @SuppressWarnings({ "squid:S2095" }) - default DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType, - final long forcedTimestamp, @NotEmpty final String... targetIDs) { - return assignDistributionSet(dsID, Arrays.stream(targetIDs) - .map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)).collect(Collectors.toList())); - } + DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType, + final long forcedTimestamp, @NotEmpty final String... targetIDs); /** * method assigns the {@link DistributionSet} to all {@link Target}s by @@ -154,10 +146,7 @@ public interface DeploymentManagement { * {@link DistributionSetType}. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - default DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, - @NotEmpty final String... targetIDs) { - return assignDistributionSet(dsID, ActionType.FORCED, Action.NO_FORCE_TIME, targetIDs); - } + DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, @NotEmpty String... targetIDs); /** * Cancels given {@link Action} for given {@link Target}. The method will @@ -450,4 +439,4 @@ public interface DeploymentManagement { + SpringEvalExpressions.IS_SYSTEM_CODE) Action startScheduledAction(@NotNull Action action); -} \ No newline at end of file +} 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 a545209e4..728a4d0c5 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 @@ -14,9 +14,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; /** * Holds distribution set filter parameters. - * - * - * */ public final class DistributionSetFilter { private final Boolean isDeleted; 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 965ecd9f6..bea9f2719 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 @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository; import java.util.Collection; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import javax.persistence.Entity; import javax.validation.constraints.NotNull; @@ -163,9 +162,7 @@ public interface DistributionSetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) @Transactional(isolation = Isolation.READ_UNCOMMITTED) - default List createDistributionSetTypes(@NotNull final Collection types) { - return types.stream().map(this::createDistributionSetType).collect(Collectors.toList()); - } + List createDistributionSetTypes(@NotNull Collection types); /** *

@@ -183,10 +180,7 @@ public interface DistributionSetManagement { * to delete */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - @Transactional(isolation = Isolation.READ_UNCOMMITTED) - default void deleteDistributionSet(@NotNull final DistributionSet set) { - deleteDistributionSet(set.getId()); - } + void deleteDistributionSet(@NotNull DistributionSet set); /** * Deleted {@link DistributionSet}s by their IDs. That is either a soft @@ -235,11 +229,8 @@ public interface DistributionSetManagement { * to look for. * @return {@link DistributionSet} or null if it does not exist */ - @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - default DistributionSet findDistributionSetById(@NotNull final Long distid) { - return findDistributionSetByIdWithDetails(distid); - } + DistributionSet findDistributionSetById(@NotNull Long distid); /** * Find {@link DistributionSet} based on given ID including (lazy loaded) @@ -487,11 +478,8 @@ public interface DistributionSetManagement { * the assignment outcome. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - @Transactional(isolation = Isolation.READ_UNCOMMITTED) - default DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection sets, - @NotNull final DistributionSetTag tag) { - return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName()); - } + DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection sets, + @NotNull DistributionSetTag tag); /** * Toggles {@link DistributionSetTag} assignment to given @@ -588,4 +576,4 @@ public interface DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) DistributionSetType updateDistributionSetType(@NotNull DistributionSetType dsType); -} \ No newline at end of file +} 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 40ee21d9b..6208d395c 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 @@ -206,4 +206,4 @@ public interface ReportManagement { } -} \ No newline at end of file +} 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 7c5503c19..9654b8368 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 @@ -21,6 +21,10 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.security.access.prepost.PreAuthorize; +/** + * Repository management service for RolloutGroup. + * + */ public interface RolloutGroupManagement { /** 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 bf4924692..357108576 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 @@ -335,4 +335,4 @@ public interface RolloutManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull RolloutGroup rolloutGroup); -} \ No newline at end of file +} 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 03ece28ee..1d4150217 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 @@ -32,7 +32,7 @@ import org.springframework.stereotype.Component; @Profile("!test") public class RolloutScheduler { - private static final Logger logger = LoggerFactory.getLogger(RolloutScheduler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(RolloutScheduler.class); @Autowired private TenantAware tenantAware; @@ -57,7 +57,7 @@ public class RolloutScheduler { */ @Scheduled(initialDelayString = RolloutProperties.Scheduler.PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = RolloutProperties.Scheduler.PROP_SCHEDULER_DELAY_PLACEHOLDER) public void rolloutScheduler() { - logger.debug("rollout schedule checker has been triggered."); + LOGGER.debug("rollout schedule checker has been triggered."); // run this code in system code privileged to have the necessary // permission to query and create entities. systemSecurityContext.runAsSystem(() -> { @@ -68,7 +68,7 @@ public class RolloutScheduler { // iterate through all tenants and execute the rollout check for // each tenant seperately. final List tenants = systemManagement.findTenants(); - logger.info("Checking rollouts for {} tenants", tenants.size()); + LOGGER.info("Checking rollouts for {} tenants", tenants.size()); for (final String tenant : tenants) { tenantAware.runAsTenant(tenant, () -> { rolloutManagement.checkRunningRollouts(rolloutProperties.getScheduler().getFixedDelay()); 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 new file mode 100644 index 000000000..063a3a0f1 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java @@ -0,0 +1,471 @@ +/** + * 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.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.exception.EntityNotFoundException; +import org.eclipse.hawkbit.repository.model.CustomSoftwareModule; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; +import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey; +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; + +/** + * Service for managing {@link SoftwareModule}s. + * + */ +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()} + * and {@link SoftwareModule#getType()} that are not marked as deleted. + * + * @param searchText + * to search for in name and version + * @param type + * to filter the result + * @return number of found {@link SoftwareModule}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Long countSoftwareModuleByFilters(String searchText, SoftwareModuleType type); + + /** + * @param pageable + * parameter + * @return all {@link SoftwareModuleType}s in the repository. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleTypesAll(@NotNull Pageable pageable); + + /** + * @return number of {@link SoftwareModuleType}s in the repository. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Long countSoftwareModuleTypesAll(); + + /** + * + * @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 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 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); + + /** + * Creates new {@link SoftwareModuleType}. + * + * @param type + * to create + * @return created {@link Entity} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleType type); + + /** + * 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); + + /** + * Deletes or marks as delete in case the type is in use. + * + * @param type + * to delete + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) + void deleteSoftwareModuleType(@NotNull SoftwareModuleType type); + + /** + * @param pageable + * the page request to page the result set + * @param set + * to search for + * @return all {@link SoftwareModule}s that are assigned to given + * {@link DistributionSet}. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull DistributionSet set); + + /** + * @param pageable + * the page request to page the result set + * @param set + * to search for + * @param type + * to filter + * @return all {@link SoftwareModule}s that are assigned to given + * {@link DistributionSet} filtered by {@link SoftwareModuleType}. + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleByAssignedToAndType(@NotNull Pageable pageable, @NotNull DistributionSet set, + @NotNull SoftwareModuleType type); + + /** + * 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 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. + * + * @param id + * the ID of the software module meta data to delete + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) + void deleteSoftwareModuleMetadata(@NotNull SwMetadataCompositeKey id); + + /** + * finds all meta data by the given software module id. + * + * @param swId + * the software module id to retrieve the meta data from + * @param pageable + * the page request to page the result + * @return a paged result of all meta data entries for a given software + * module id + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long swId, + @NotNull Pageable pageable); + + /** + * finds all meta data by the given software module id. + * + * @param softwareModuleId + * the software module id to retrieve the meta data from + * @param spec + * the specification to filter the result + * @param pageable + * the page request to page the result + * @return a paged result of all meta data entries for a given software + * module id + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + Page findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long softwareModuleId, + @NotNull Specification spec, @NotNull Pageable pageable); + + /** + * 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); + +} 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 10a88b232..a5eaf4006 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 @@ -1,3 +1,11 @@ +/** + * 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; @@ -9,6 +17,10 @@ import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.env.Environment; import org.springframework.security.access.prepost.PreAuthorize; +/** + * Management service for tenant configurations. + * + */ public interface TenantConfigurationManagement { /** @@ -131,4 +143,4 @@ public interface TenantConfigurationManagement { @PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) void deleteConfiguration(TenantConfigurationKey configurationKey); -} \ 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 new file mode 100644 index 000000000..adcca7c73 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/DeploymentHelper.java @@ -0,0 +1,100 @@ +/** + * 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 java.util.List; +import java.util.stream.Collectors; + +import javax.persistence.EntityManager; +import javax.validation.constraints.NotNull; + +import org.eclipse.hawkbit.repository.model.Action; +import org.eclipse.hawkbit.repository.model.Action.Status; +import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.repository.model.TargetInfo; +import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; + +/** + * Utility class for deployment related topics. + * + */ +public final class DeploymentHelper { + + private DeploymentHelper() { + // utility class + } + + /** + * Internal helper method used only inside service level. As a result is no + * additional security necessary. + * + * @param target + * to update + * @param status + * of the target + * @param setInstalledDate + * to set + * @param entityManager + * for the operation + * @param targetInfoRepository + * for the operation + * + * @return updated target + */ + static Target updateTargetInfo(@NotNull final Target target, @NotNull final TargetUpdateStatus status, + final boolean setInstalledDate, final TargetInfoRepository targetInfoRepository, + final EntityManager entityManager) { + final TargetInfo ts = target.getTargetInfo(); + ts.setUpdateStatus(status); + + if (setInstalledDate) { + ts.setInstallationDate(System.currentTimeMillis()); + } + targetInfoRepository.save(ts); + return entityManager.merge(target); + } + + /** + * This method is called, when cancellation has been successful. It sets the + * action to canceled, resets the meta data of the target and in case there + * is a new action this action is triggered. + * + * @param action + * the action which is set to canceled + * @param actionRepository + * for the operation + * @param targetManagement + * for the operation + * @param entityManager + * for the operation + * @param targetInfoRepository + * for the operation + */ + static void successCancellation(final Action action, final ActionRepository actionRepository, + final TargetManagement targetManagement, final TargetInfoRepository targetInfoRepository, + final EntityManager entityManager) { + + // set action inactive + action.setActive(false); + action.setStatus(Status.CANCELED); + + final Target target = action.getTarget(); + final List nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true).stream() + .filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList()); + + if (nextActiveActions.isEmpty()) { + target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet()); + updateTargetInfo(target, TargetUpdateStatus.IN_SYNC, false, targetInfoRepository, entityManager); + } else { + target.setAssignedDistributionSet(nextActiveActions.get(0).getDistributionSet()); + } + targetManagement.updateTarget(target); + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java index c6d30208c..7bae73a8b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java @@ -267,4 +267,20 @@ public class JpaArtifactManagement implements ArtifactManagement { LOG.debug("storing new artifact into repository {}", artifact); return localArtifactRepository.save(artifact); } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public LocalArtifact createLocalArtifact(final InputStream inputStream, final Long moduleId, final String filename, + final boolean overrideExisting) { + return createLocalArtifact(inputStream, moduleId, filename, null, null, overrideExisting, null); + } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public LocalArtifact createLocalArtifact(final InputStream inputStream, final Long moduleId, final String filename, + final boolean overrideExisting, final String contentType) { + return createLocalArtifact(inputStream, moduleId, filename, null, null, overrideExisting, contentType); + } } 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 76363cca9..8834b2ae0 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 @@ -409,9 +409,15 @@ public class JpaControllerManagement implements ControllerManagement { } @Override - @Transactional(isolation = Isolation.READ_UNCOMMITTED) public String getSecurityTokenByControllerId(final String controllerId) { final Target target = targetRepository.findByControllerId(controllerId); return target != null ? target.getSecurityToken() : null; } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public TargetInfo updateLastTargetQuery(final TargetInfo target, final URI address) { + return updateTargetStatus(target, null, System.currentTimeMillis(), address); + } } 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 50bbd2d31..d905fb7b1 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 @@ -133,7 +133,6 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Override @Modifying @Transactional(isolation = Isolation.READ_COMMITTED) - @CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true) public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, final String... targetIDs) { return assignDistributionSet(dsID, ActionType.FORCED, Action.NO_FORCE_TIME, targetIDs); 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 160cf613c..d045cd549 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 @@ -18,14 +18,15 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import javax.persistence.EntityManager; import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; 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.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityLockedException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -660,4 +661,26 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { distributionSets.forEach(ds -> ds.getTags().remove(tag)); return distributionSetRepository.save(distributionSets); } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public List createDistributionSetTypes(final Collection types) { + return types.stream().map(this::createDistributionSetType).collect(Collectors.toList()); + } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public void deleteDistributionSet(final DistributionSet set) { + deleteDistributionSet(set.getId()); + } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public DistributionSetTagAssignmentResult toggleTagAssignment(final Collection sets, + final DistributionSetTag tag) { + return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName()); + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java similarity index 55% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagement.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java index 813f2e5a6..a3566f07f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareManagement.java @@ -17,17 +17,16 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.ListJoin; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.ArtifactManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.CustomSoftwareModule; @@ -42,7 +41,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule_; import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey; import org.eclipse.hawkbit.repository.specifications.SoftwareModuleSpecification; import org.eclipse.hawkbit.repository.specifications.SpecificationsBuilder; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.AuditorAware; import org.springframework.data.domain.Page; @@ -61,13 +59,13 @@ import com.google.common.base.Strings; import com.google.common.collect.Sets; /** - * Business facade for managing {@link SoftwareModule}s. + * JPA implementation of SoftwareManagement. * */ @Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED) @Validated @Service -public class SoftwareManagement { +public class JpaSoftwareManagement implements SoftwareManagement { @Autowired private EntityManager entityManager; @@ -96,23 +94,10 @@ public class SoftwareManagement { @Autowired private ArtifactManagement artifactManagement; - /** - * 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 - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public SoftwareModule updateSoftwareModule(@NotNull final SoftwareModule sm) { + public SoftwareModule updateSoftwareModule(final SoftwareModule sm) { checkNotNull(sm.getId()); final SoftwareModule module = softwareModuleRepository.findOne(sm.getId()); @@ -130,19 +115,10 @@ public class SoftwareManagement { return updated ? softwareModuleRepository.save(module) : module; } - /** - * Updates existing {@link SoftwareModuleType}. Update-able value is - * {@link SoftwareModuleType#getDescription()} and - * {@link SoftwareModuleType#getColour()}. - * - * @param sm - * to update - * @return updated {@link Entity} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public SoftwareModuleType updateSoftwareModuleType(@NotNull final SoftwareModuleType sm) { + public SoftwareModuleType updateSoftwareModuleType(final SoftwareModuleType sm) { checkNotNull(sm.getId()); final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId()); @@ -159,37 +135,20 @@ public class SoftwareManagement { return updated ? softwareModuleTypeRepository.save(type) : type; } - /** - * - * @param swModule - * SoftwareModule to create - * @return SoftwareModule - * @throws EntityAlreadyExistsException - * if a given entity already exists - */ + @Override @Modifying - @Transactional - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - public SoftwareModule createSoftwareModule(@NotNull final SoftwareModule swModule) { + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public SoftwareModule createSoftwareModule(final SoftwareModule swModule) { if (null != swModule.getId()) { throw new EntityAlreadyExistsException(); } return softwareModuleRepository.save(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 - */ + @Override @Modifying - @Transactional - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - public List createSoftwareModule(@NotNull final Iterable swModules) { + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public List createSoftwareModule(final Iterable swModules) { swModules.forEach(swModule -> { if (null != swModule.getId()) { throw new EntityAlreadyExistsException(); @@ -200,19 +159,8 @@ public class SoftwareManagement { } - /** - * 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) - public Slice findSoftwareModulesByType(@NotNull final Pageable pageable, - @NotNull final SoftwareModuleType type) { + @Override + public Slice findSoftwareModulesByType(final Pageable pageable, final SoftwareModuleType type) { final List> specList = new ArrayList<>(); @@ -225,15 +173,8 @@ public class SoftwareManagement { return findSwModuleByCriteriaAPI(pageable, specList); } - /** - * 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) - public Long countSoftwareModulesByType(@NotNull final SoftwareModuleType type) { + @Override + public Long countSoftwareModulesByType(final SoftwareModuleType type) { final List> specList = new ArrayList<>(); @@ -246,63 +187,29 @@ public class SoftwareManagement { return countSwModuleByCriteriaAPI(specList); } - /** - * 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) - public SoftwareModule findSoftwareModuleById(@NotNull final Long id) { + @Override + public SoftwareModule findSoftwareModuleById(final Long id) { return artifactManagement.findSoftwareModuleById(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) - public SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty final String name, - @NotEmpty final String version, @NotNull final SoftwareModuleType type) { + @Override + public SoftwareModule findSoftwareModuleByNameAndVersion(final String name, final String version, + final SoftwareModuleType type) { return softwareModuleRepository.findOneByNameAndVersionAndType(name, version, type); } - /** - * Deletes the given {@link SoftwareModule} {@link Entity}. - * - * @param bsm - * is the {@link SoftwareModule} to be deleted - */ - @Modifying - @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - public void deleteSoftwareModule(@NotNull final SoftwareModule bsm) { - - deleteSoftwareModules(Sets.newHashSet(bsm.getId())); - } - private boolean isUnassigned(final SoftwareModule bsmMerged) { return distributionSetRepository.findByModules(bsmMerged).isEmpty(); } - private Slice findSwModuleByCriteriaAPI(@NotNull final Pageable pageable, - @NotEmpty final List> specList) { + private Slice findSwModuleByCriteriaAPI(final Pageable pageable, + final List> specList) { return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable, SoftwareModule.class); } - private Long countSwModuleByCriteriaAPI(@NotEmpty final List> specList) { + private Long countSwModuleByCriteriaAPI(final List> specList) { return softwareModuleRepository.count(SpecificationsBuilder.combineWithAnd(specList)); } @@ -312,16 +219,10 @@ public class SoftwareManagement { } } - /** - * Deletes {@link SoftwareModule}s which is any if the given ids. - * - * @param ids - * of the Software Modules to be deleted - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - public void deleteSoftwareModules(@NotNull final Iterable ids) { + public void deleteSoftwareModules(final Iterable ids) { final List swModulesToDelete = softwareModuleRepository.findByIdIn(ids); final Set assignedModuleIds = new HashSet<>(); swModulesToDelete.forEach(swModule -> { @@ -349,15 +250,8 @@ public class SoftwareManagement { } } - /** - * Retrieves all software modules. Deleted ones are filtered. - * - * @param pageable - * pagination parameter - * @return the found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Slice findSoftwareModulesAll(@NotNull final Pageable pageable) { + @Override + public Slice findSoftwareModulesAll(final Pageable pageable) { final List> specList = new ArrayList<>(); @@ -376,13 +270,7 @@ public class SoftwareManagement { return findSwModuleByCriteriaAPI(pageable, specList); } - /** - * 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) + @Override public Long countSoftwareModulesAll() { final List> specList = new ArrayList<>(); @@ -393,79 +281,31 @@ public class SoftwareManagement { return countSwModuleByCriteriaAPI(specList); } - /** - * 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) - public SoftwareModule findSoftwareModuleWithDetails(@NotNull final Long id) { + @Override + public SoftwareModule findSoftwareModuleWithDetails(final Long id) { return artifactManagement.findSoftwareModuleWithDetails(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) - public Page findSoftwareModulesByPredicate(@NotNull final Specification spec, - @NotNull final Pageable pageable) { + @Override + public Page findSoftwareModulesByPredicate(final Specification spec, + final Pageable pageable) { return softwareModuleRepository.findAll(spec, 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) - public Page findSoftwareModuleTypesByPredicate( - @NotNull final Specification spec, @NotNull final Pageable pageable) { + @Override + public Page findSoftwareModuleTypesByPredicate(final Specification spec, + final Pageable pageable) { return softwareModuleTypeRepository.findAll(spec, 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 - */ + @Override @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public List findSoftwareModulesById(@NotEmpty final List ids) { + public List findSoftwareModulesById(final Collection ids) { return softwareModuleRepository.findByIdIn(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) - public Slice findSoftwareModuleByFilters(@NotNull final Pageable pageable, final String searchText, + @Override + public Slice findSoftwareModuleByFilters(final Pageable pageable, final String searchText, final SoftwareModuleType type) { final List> specList = new ArrayList<>(); @@ -495,29 +335,9 @@ public class SoftwareManagement { return findSwModuleByCriteriaAPI(pageable, specList); } - /** - * 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) + @Override public Slice findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( - @NotNull final Pageable pageable, @NotNull final Long orderByDistributionId, final String searchText, + final Pageable pageable, final Long orderByDistributionId, final String searchText, final SoftwareModuleType type) { final List resultList = new ArrayList<>(); @@ -594,9 +414,6 @@ public class SoftwareManagement { return specList; } - /** - * @param specifications - */ private Predicate[] specificationsToPredicate(final List> specifications, final Root root, final CriteriaQuery query, final CriteriaBuilder cb, final Predicate... additionalPredicates) { @@ -608,18 +425,7 @@ public class SoftwareManagement { return predicates.toArray(new Predicate[predicates.size()]); } - /** - * Counts {@link SoftwareModule}s with given - * {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()} - * and {@link SoftwareModule#getType()} that are not marked as deleted. - * - * @param searchText - * to search for in name and version - * @param type - * to filter the result - * @return number of found {@link SoftwareModule}s - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + @Override public Long countSoftwareModuleByFilters(final String searchText, final SoftwareModuleType type) { final List> specList = new ArrayList<>(); @@ -640,71 +446,35 @@ public class SoftwareManagement { return countSwModuleByCriteriaAPI(specList); } - /** - * @param pageable - * parameter - * @return all {@link SoftwareModuleType}s in the repository. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Page findSoftwareModuleTypesAll(@NotNull final Pageable pageable) { + @Override + public Page findSoftwareModuleTypesAll(final Pageable pageable) { return softwareModuleTypeRepository.findByDeleted(pageable, false); } - /** - * @return number of {@link SoftwareModuleType}s in the repository. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + @Override public Long countSoftwareModuleTypesAll() { return softwareModuleTypeRepository.countByDeleted(false); } - /** - * - * @param key - * to search for - * @return {@link SoftwareModuleType} in the repository with given - * {@link SoftwareModuleType#getKey()} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull final String key) { + @Override + public SoftwareModuleType findSoftwareModuleTypeByKey(final String key) { return softwareModuleTypeRepository.findByKey(key); } - /** - * - * @param id - * to search for - * @return {@link SoftwareModuleType} in the repository with given - * {@link SoftwareModuleType#getId()} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public SoftwareModuleType findSoftwareModuleTypeById(@NotNull final Long id) { + @Override + public SoftwareModuleType findSoftwareModuleTypeById(final Long id) { return softwareModuleTypeRepository.findOne(id); } - /** - * - * @param name - * to search for - * @return all {@link SoftwareModuleType}s in the repository with given - * {@link SoftwareModuleType#getName()} - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public SoftwareModuleType findSoftwareModuleTypeByName(@NotNull final String name) { + @Override + public SoftwareModuleType findSoftwareModuleTypeByName(final String name) { return softwareModuleTypeRepository.findByName(name); } - /** - * Creates new {@link SoftwareModuleType}. - * - * @param type - * to create - * @return created {@link Entity} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - public SoftwareModuleType createSoftwareModuleType(@NotNull final SoftwareModuleType type) { + public SoftwareModuleType createSoftwareModuleType(final SoftwareModuleType type) { if (type.getId() != null) { throw new EntityAlreadyExistsException("Given type contains an Id!"); } @@ -712,30 +482,10 @@ public class SoftwareManagement { return softwareModuleTypeRepository.save(type); } - /** - * Creates multiple {@link SoftwareModuleType}s. - * - * @param types - * to create - * @return created {@link Entity} - */ + @Override @Modifying @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - public List createSoftwareModuleType(@NotNull final Collection types) { - return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList()); - } - - /** - * Deletes or markes as delete in case the type is in use. - * - * @param type - * to delete - */ - @Modifying - @Transactional(isolation = Isolation.READ_UNCOMMITTED) - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - public void deleteSoftwareModuleType(@NotNull final SoftwareModuleType type) { + public void deleteSoftwareModuleType(final SoftwareModuleType type) { if (softwareModuleRepository.countByType(type) > 0 || distributionSetTypeRepository.countByElementsSmType(type) > 0) { @@ -747,50 +497,21 @@ public class SoftwareManagement { } } - /** - * @param pageable - * the page request to page the result set - * @param set - * to search for - * @return all {@link SoftwareModule}s that are assigned to given - * {@link DistributionSet}. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Page findSoftwareModuleByAssignedTo(@NotNull final Pageable pageable, - @NotNull final DistributionSet set) { + @Override + public Page findSoftwareModuleByAssignedTo(final Pageable pageable, final DistributionSet set) { return softwareModuleRepository.findByAssignedTo(pageable, set); } - /** - * @param pageable - * the page request to page the result set - * @param set - * to search for - * @param type - * to filter - * @return all {@link SoftwareModule}s that are assigned to given - * {@link DistributionSet} filtered by {@link SoftwareModuleType}. - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Page findSoftwareModuleByAssignedToAndType(@NotNull final Pageable pageable, - @NotNull final DistributionSet set, @NotNull final SoftwareModuleType type) { + @Override + public Page findSoftwareModuleByAssignedToAndType(final Pageable pageable, + final DistributionSet set, final SoftwareModuleType type) { return softwareModuleRepository.findByAssignedToAndType(pageable, set, type); } - /** - * 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 - */ + @Override @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) { + public SoftwareModuleMetadata createSoftwareModuleMetadata(final SoftwareModuleMetadata metadata) { if (softwareModuleMetadataRepository.exists(metadata.getId())) { throwMetadataKeyAlreadyExists(metadata.getId().getKey()); } @@ -802,21 +523,11 @@ public class SoftwareManagement { return softwareModuleMetadataRepository.save(metadata); } - /** - * 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 - */ + @Override @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) public List createSoftwareModuleMetadata( - @NotEmpty final Collection metadata) { + final Collection metadata) { for (final SoftwareModuleMetadata softwareModuleMetadata : metadata) { checkAndThrowAlreadyExistsIfSoftwareModuleMetadataExists(softwareModuleMetadata.getId()); } @@ -824,20 +535,10 @@ public class SoftwareManagement { return softwareModuleMetadataRepository.save(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 - */ + @Override @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) { + public SoftwareModuleMetadata updateSoftwareModuleMetadata(final SoftwareModuleMetadata metadata) { // check if exists otherwise throw entity not found exception findSoftwareModuleMetadata(metadata.getId()); // touch it to update the lock revision because we are modifying the @@ -847,50 +548,22 @@ public class SoftwareManagement { return softwareModuleMetadataRepository.save(metadata); } - /** - * deletes a software module meta data entry. - * - * @param id - * the ID of the software module meta data to delete - */ + @Override @Transactional(isolation = Isolation.READ_UNCOMMITTED) @Modifying - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public void deleteSoftwareModuleMetadata(@NotNull final SwMetadataCompositeKey id) { + public void deleteSoftwareModuleMetadata(final SwMetadataCompositeKey id) { softwareModuleMetadataRepository.delete(id); } - /** - * finds all meta data by the given software module id. - * - * @param swId - * the software module id to retrieve the meta data from - * @param pageable - * the page request to page the result - * @return a paged result of all meta data entries for a given software - * module id - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Page findSoftwareModuleMetadataBySoftwareModuleId(@NotNull final Long swId, - @NotNull final Pageable pageable) { + @Override + public Page findSoftwareModuleMetadataBySoftwareModuleId(final Long swId, + final Pageable pageable) { return softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable); } - /** - * finds all meta data by the given software module id. - * - * @param softwareModuleId - * the software module id to retrieve the meta data from - * @param spec - * the specification to filter the result - * @param pageable - * the page request to page the result - * @return a paged result of all meta data entries for a given software - * module id - */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) + @Override public Page findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId, - @NotNull final Specification spec, @NotNull final Pageable pageable) { + final Specification spec, final Pageable pageable) { return softwareModuleMetadataRepository .findAll( (Specification) (root, query, @@ -901,18 +574,8 @@ public class SoftwareManagement { pageable); } - /** - * 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) - public SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull final SwMetadataCompositeKey id) { + @Override + public SoftwareModuleMetadata findSoftwareModuleMetadata(final SwMetadataCompositeKey id) { final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id); if (findOne == null) { throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist"); @@ -931,4 +594,19 @@ public class SoftwareManagement { throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataKey + "' already exists"); } + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public void deleteSoftwareModule(final SoftwareModule bsm) { + deleteSoftwareModules(Sets.newHashSet(bsm.getId())); + } + + @Override + @Modifying + @Transactional(isolation = Isolation.READ_UNCOMMITTED) + public List createSoftwareModuleType(final Collection types) { + + return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList()); + } + } 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 99b93926f..dafc21eef 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java @@ -22,6 +22,7 @@ import org.eclipse.hawkbit.repository.DeploymentManagement; 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.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.jpa.ActionRepository; import org.eclipse.hawkbit.repository.jpa.ActionStatusRepository; @@ -32,7 +33,6 @@ import org.eclipse.hawkbit.repository.jpa.ExternalArtifactRepository; import org.eclipse.hawkbit.repository.jpa.LocalArtifactRepository; import org.eclipse.hawkbit.repository.jpa.RolloutGroupRepository; import org.eclipse.hawkbit.repository.jpa.RolloutRepository; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.SoftwareModuleMetadataRepository; import org.eclipse.hawkbit.repository.jpa.SoftwareModuleRepository; import org.eclipse.hawkbit.repository.jpa.SoftwareModuleTypeRepository; 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 11106eaf1..03a9b230f 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java @@ -18,7 +18,7 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java index 849cf8e30..04eccb13e 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java @@ -270,7 +270,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { @Description("Searches for software modules based on a list of IDs.") public void findSoftwareModulesById() { - final List modules = new ArrayList(); + final List modules = new ArrayList<>(); modules.add(softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky-una", "3.0.2", null, "")) .getId()); 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 e2e86bed1..f27c7b707 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 @@ -30,7 +30,7 @@ import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +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.model.Action; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java index 9dfcbae55..db5efd37c 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java @@ -30,8 +30,8 @@ import org.eclipse.hawkbit.controller.model.DeploymentBase; import org.eclipse.hawkbit.controller.model.Result.FinalResult; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ControllerManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; 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/DistributionSetMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java index 95e3f0c8d..8051146a1 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java @@ -16,8 +16,8 @@ import java.util.List; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetType; 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 9e9dc2369..a30927ebf 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 @@ -18,9 +18,9 @@ import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; 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.TargetFields; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.SystemManagement; import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.jpa.TargetWithActionType; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java index fbe22af5c..409caf01d 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java @@ -14,8 +14,8 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.rest.resource.api.DistributionSetTypeRestApi; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java index 32e87e05e..8798f0ec8 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java @@ -12,8 +12,8 @@ import java.util.List; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeFields; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java index 5c057acd4..00f8f4756 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadArtifactResource.java @@ -13,8 +13,8 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; import org.eclipse.hawkbit.repository.ArtifactManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java index 8732cc1d1..01dfae9cd 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java @@ -14,8 +14,8 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.ArrayList; import java.util.List; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java index 0d7a4b8f0..830443cbd 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java @@ -12,10 +12,10 @@ import java.io.IOException; import java.util.List; import org.eclipse.hawkbit.repository.ArtifactManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareModuleFields; import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java index df042d38c..e3498f141 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java @@ -10,9 +10,9 @@ package org.eclipse.hawkbit.rest.resource; import java.util.List; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; 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 9d823e832..ac1c95374 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 @@ -32,9 +32,9 @@ import org.eclipse.hawkbit.TestDataUtil; 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.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.jpa.ActionRepository; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java index 364b659da..e6284d5d6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; import org.eclipse.hawkbit.ui.artifacts.state.CustomFile; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java index d1d034555..ea49d2f1f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.common.UserDetailsFormatter; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java index 6a033bfd8..1e4029087 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtable; import java.io.Serializable; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index 4fea3df08..478438891 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -12,7 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index 4039a2be2..f2e43c1fb 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -13,8 +13,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent; import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java index 4727ecae7..4a4006c2a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtype; import java.io.Serializable; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java index f8d6dba66..b1c274672 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java @@ -11,8 +11,8 @@ package org.eclipse.hawkbit.ui.common; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index 0e3ed8da3..d7f5d2748 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -14,9 +14,9 @@ import java.util.List; 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.DistributionSetRepository; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.common.CoordinatesToColor; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java index 32bb0ce86..a1d1ffcfe 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java @@ -14,7 +14,7 @@ import java.util.Map; import java.util.Set; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; 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/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index ca469c967..e92e4e735 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 @@ -18,8 +18,8 @@ import java.util.Map.Entry; 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.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java index 45e02b2ca..a97c5786d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java @@ -17,7 +17,7 @@ import java.util.Set; import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; 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/smtable/SwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java index 84ac0f1dc..eb53cef55 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.jpa.OffsetBasedPageRequest; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; import org.eclipse.hawkbit.repository.model.CustomSoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index 17b565774..eeea33723 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java index d270c36f2..6f29ed661 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.distributions.smtype; import java.io.Serializable; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.ui.artifacts.event.SMFilterEvent; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterSingleButtonClick; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index abd1942c4..0e71567af 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -20,7 +20,7 @@ import java.util.Map.Entry; import java.util.TimeZone; import org.apache.commons.lang3.StringUtils; -import org.eclipse.hawkbit.repository.jpa.SoftwareManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.NamedEntity; diff --git a/pom.xml b/pom.xml index b6d09758e..10e60e763 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ https://projects.eclipse.org/projects/iot.hawkbit https://circleci.com/gh/eclipse/hawkbit - 0.7.2.201409121644 + 0.7.6.201602180812 1.4