FileSystem implementation of ArtifiactRepository moved in mgmt and ddi starters only (#2020)
* it's not needed for dmf * also made optional when not needed (e.g. some JpaArtifactManagement) _release_notes_ Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -19,9 +19,37 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>hawkbit-ddi-starter</artifactId>
|
||||
<name>hawkBit :: Spring Boot Starter DDI API</name>
|
||||
<name>hawkBit :: DDI API :: Spring Boot Starter</name>
|
||||
|
||||
<dependencies>
|
||||
<!-- hawkBit - START -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-security-controller</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-artifact-repository-filesystem</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository-jpa</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-ddi-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- hawkBit - END -->
|
||||
|
||||
<!-- Spring - START -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -44,28 +72,5 @@
|
||||
<artifactId>spring-security-aspects</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring - END -->
|
||||
|
||||
<!-- hawkBit - START -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-ddi-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-security-controller</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository-jpa</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- hawkBit - END -->
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -19,25 +19,30 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>hawkbit-mgmt-starter</artifactId>
|
||||
<name>hawkBit :: Spring Boot Starter Management API</name>
|
||||
<name>hawkBit :: Management API :: Spring Boot Starter</name>
|
||||
|
||||
<dependencies>
|
||||
<!-- hawkBit - START -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-mgmt-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-security-controller</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-artifact-repository-filesystem</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository-jpa</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-mgmt-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||
|
||||
@@ -36,11 +36,6 @@
|
||||
<artifactId>hawkbit-repository-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-artifact-repository-filesystem</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
|
||||
@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@@ -173,6 +174,7 @@ import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
@@ -181,6 +183,7 @@ import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -872,9 +875,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
ArtifactManagement artifactManagement(
|
||||
final EntityManager entityManager, final LocalArtifactRepository localArtifactRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, final ArtifactRepository artifactRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, final Optional<ArtifactRepository> artifactRepository,
|
||||
final QuotaManagement quotaManagement, final TenantAware tenantAware) {
|
||||
return new JpaArtifactManagement(entityManager, localArtifactRepository, softwareModuleRepository, artifactRepository,
|
||||
return new JpaArtifactManagement(entityManager, localArtifactRepository, softwareModuleRepository, artifactRepository.orElse(null),
|
||||
quotaManagement, tenantAware);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,10 @@ package org.eclipse.hawkbit.repository.jpa.management;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -74,6 +76,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
|
||||
private final SoftwareModuleRepository softwareModuleRepository;
|
||||
|
||||
@Nullable
|
||||
private final ArtifactRepository artifactRepository;
|
||||
|
||||
private final TenantAware tenantAware;
|
||||
@@ -82,7 +85,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
|
||||
public JpaArtifactManagement(final EntityManager entityManager,
|
||||
final LocalArtifactRepository localArtifactRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, final ArtifactRepository artifactRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, @Nullable final ArtifactRepository artifactRepository,
|
||||
final QuotaManagement quotaManagement, final TenantAware tenantAware) {
|
||||
this.entityManager = entityManager;
|
||||
this.localArtifactRepository = localArtifactRepository;
|
||||
@@ -102,6 +105,10 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Artifact create(final ArtifactUpload artifactUpload) {
|
||||
if (artifactRepository == null) {
|
||||
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
||||
}
|
||||
|
||||
final long moduleId = artifactUpload.getModuleId();
|
||||
assertArtifactQuota(moduleId, 1);
|
||||
final JpaSoftwareModule softwareModule =
|
||||
@@ -190,8 +197,11 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DbArtifact> loadArtifactBinary(final String sha1Hash, final long softwareModuleId,
|
||||
final boolean isEncrypted) {
|
||||
public Optional<DbArtifact> loadArtifactBinary(final String sha1Hash, final long softwareModuleId, final boolean isEncrypted) {
|
||||
if (artifactRepository == null) {
|
||||
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
||||
}
|
||||
|
||||
assertSoftwareModuleExists(softwareModuleId);
|
||||
|
||||
final String tenant = tenantAware.getCurrentTenant();
|
||||
@@ -217,10 +227,13 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
* Software module related UPDATE permission shall be checked by the callers!
|
||||
*
|
||||
* @param sha1Hash no longer needed
|
||||
* @param softwareModuleId the garbage collection call is made for
|
||||
*/
|
||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void clearArtifactBinary(final String sha1Hash) {
|
||||
if (artifactRepository == null) {
|
||||
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
||||
}
|
||||
|
||||
// countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse will skip ACM checks and
|
||||
// will return total count as it should be
|
||||
final long count = localArtifactRepository.countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse(
|
||||
|
||||
Reference in New Issue
Block a user