Rename LocalArtifactRepository to ArtifactRepository (#2643)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -538,25 +538,25 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
|||||||
return metadata.entrySet().stream().map(md -> new DmfMetadata(md.getKey(), md.getValue())).toList();
|
return metadata.entrySet().stream().map(md -> new DmfMetadata(md.getKey(), md.getValue())).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DmfArtifact> convertArtifacts(final Target target, final List<Artifact> localArtifacts) {
|
private List<DmfArtifact> convertArtifacts(final Target target, final List<Artifact> artifacts) {
|
||||||
if (localArtifacts.isEmpty()) {
|
if (artifacts.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return localArtifacts.stream().map(localArtifact -> convertArtifact(target, localArtifact)).toList();
|
return artifacts.stream().map(artifact -> convertArtifact(target, artifact)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DmfArtifact convertArtifact(final Target target, final Artifact localArtifact) {
|
private DmfArtifact convertArtifact(final Target target, final Artifact artifact) {
|
||||||
final TenantMetaData tenantMetadata = systemManagement.getTenantMetadataWithoutDetails();
|
final TenantMetaData tenantMetadata = systemManagement.getTenantMetadataWithoutDetails();
|
||||||
return new DmfArtifact(
|
return new DmfArtifact(
|
||||||
localArtifact.getFilename(),
|
artifact.getFilename(),
|
||||||
new DmfArtifactHash(localArtifact.getSha1Hash(), localArtifact.getMd5Hash()),
|
new DmfArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash()),
|
||||||
localArtifact.getSize(),
|
artifact.getSize(),
|
||||||
localArtifact.getLastModifiedAt(),
|
artifact.getLastModifiedAt(),
|
||||||
artifactUrlHandler
|
artifactUrlHandler
|
||||||
.getUrls(new DownloadDescriptor(
|
.getUrls(new DownloadDescriptor(
|
||||||
tenantMetadata.getTenant(), target.getControllerId(),
|
tenantMetadata.getTenant(), target.getControllerId(),
|
||||||
localArtifact.getSoftwareModule().getId(), localArtifact.getFilename(), localArtifact.getSha1Hash()),
|
artifact.getSoftwareModule().getId(), artifact.getFilename(), artifact.getSha1Hash()),
|
||||||
ArtifactUrlResolver.ApiType.DMF)
|
ArtifactUrlResolver.ApiType.DMF)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(ArtifactUrl::protocol, ArtifactUrl::ref))
|
.collect(Collectors.toMap(ArtifactUrl::protocol, ArtifactUrl::ref))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public interface MgmtDownloadArtifactRestApi {
|
|||||||
* Handles the GET request for downloading an artifact.
|
* Handles the GET request for downloading an artifact.
|
||||||
*
|
*
|
||||||
* @param softwareModuleId of the parent SoftwareModule
|
* @param softwareModuleId of the parent SoftwareModule
|
||||||
* @param artifactId of the related LocalArtifact
|
* @param artifactId of the related repository Artifact
|
||||||
* @return responseEntity with status ok if successful
|
* @return responseEntity with status ok if successful
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}/download")
|
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}/download")
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
* Handles the GET request of retrieving a single Artifact metadata request.
|
* Handles the GET request of retrieving a single Artifact metadata request.
|
||||||
*
|
*
|
||||||
* @param softwareModuleId of the parent SoftwareModule
|
* @param softwareModuleId of the parent SoftwareModule
|
||||||
* @param artifactId of the related LocalArtifact
|
* @param artifactId of the related artifact
|
||||||
* @return responseEntity with status ok if successful
|
* @return responseEntity with status ok if successful
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "Return single Artifact metadata", description = "Handles the GET request of retrieving a single Artifact metadata request. Required Permission: READ_REPOSITORY")
|
@Operation(summary = "Return single Artifact metadata", description = "Handles the GET request of retrieving a single Artifact metadata request. Required Permission: READ_REPOSITORY")
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import org.eclipse.hawkbit.repository.Constants;
|
|||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.LocalArtifactRepository;
|
|
||||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||||
import org.eclipse.hawkbit.repository.model.ArtifactUpload;
|
import org.eclipse.hawkbit.repository.model.ArtifactUpload;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
@@ -93,8 +92,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
"hawkbit.server.security.dos.maxArtifactStorage=500000" })
|
"hawkbit.server.security.dos.maxArtifactStorage=500000" })
|
||||||
class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTest {
|
class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTest {
|
||||||
|
|
||||||
private LocalArtifactRepository localArtifactRepository;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void assertPreparationOfRepo() {
|
public void assertPreparationOfRepo() {
|
||||||
assertThat(softwareModuleManagement.findAll(PAGE)).as("no softwaremodule should be founded").isEmpty();
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("no softwaremodule should be founded").isEmpty();
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ import org.eclipse.hawkbit.repository.jpa.model.helper.TenantAwareHolder;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.LocalArtifactRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ArtifactRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutTargetGroupRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutTargetGroupRepository;
|
||||||
@@ -184,7 +184,7 @@ public class JpaRepositoryConfiguration {
|
|||||||
@Override
|
@Override
|
||||||
public Object postProcessAfterInitialization(@NonNull final Object bean, @NonNull final String beanName)
|
public Object postProcessAfterInitialization(@NonNull final Object bean, @NonNull final String beanName)
|
||||||
throws BeansException {
|
throws BeansException {
|
||||||
if (bean instanceof LocalArtifactRepository repo) {
|
if (bean instanceof ArtifactRepository repo) {
|
||||||
return repo.withACM(artifactAccessController);
|
return repo.withACM(artifactAccessController);
|
||||||
} else if (bean instanceof SoftwareModuleTypeRepository repo) {
|
} else if (bean instanceof SoftwareModuleTypeRepository repo) {
|
||||||
return repo.withACM(softwareModuleTypeAccessController);
|
return repo.withACM(softwareModuleTypeAccessController);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaArtifact;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaArtifact;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.LocalArtifactRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ArtifactRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.SoftwareModuleRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.ArtifactSpecifications;
|
import org.eclipse.hawkbit.repository.jpa.specifications.ArtifactSpecifications;
|
||||||
import org.eclipse.hawkbit.repository.jpa.utils.DeploymentHelper;
|
import org.eclipse.hawkbit.repository.jpa.utils.DeploymentHelper;
|
||||||
@@ -67,8 +67,8 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
@ConditionalOnBooleanProperty(prefix = "hawkbit.jpa", name = { "enabled", "artifact-management" }, matchIfMissing = true)
|
@ConditionalOnBooleanProperty(prefix = "hawkbit.jpa", name = { "enabled", "artifact-management" }, matchIfMissing = true)
|
||||||
public class JpaArtifactManagement implements ArtifactManagement {
|
public class JpaArtifactManagement implements ArtifactManagement {
|
||||||
|
|
||||||
private final LocalArtifactRepository localArtifactRepository;
|
private final ArtifactRepository artifactRepository;
|
||||||
private final ArtifactStorage artifactRepository;
|
private final ArtifactStorage artifactStorage;
|
||||||
private final SoftwareModuleRepository softwareModuleRepository;
|
private final SoftwareModuleRepository softwareModuleRepository;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final PlatformTransactionManager txManager;
|
private final PlatformTransactionManager txManager;
|
||||||
@@ -76,15 +76,15 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
private final QuotaManagement quotaManagement;
|
private final QuotaManagement quotaManagement;
|
||||||
|
|
||||||
protected JpaArtifactManagement(
|
protected JpaArtifactManagement(
|
||||||
final LocalArtifactRepository localArtifactRepository,
|
final ArtifactRepository artifactRepository,
|
||||||
final Optional<ArtifactStorage> artifactRepository,
|
final Optional<ArtifactStorage> artifactStorage,
|
||||||
final SoftwareModuleRepository softwareModuleRepository,
|
final SoftwareModuleRepository softwareModuleRepository,
|
||||||
final EntityManager entityManager,
|
final EntityManager entityManager,
|
||||||
final PlatformTransactionManager txManager,
|
final PlatformTransactionManager txManager,
|
||||||
final QuotaManagement quotaManagement,
|
final QuotaManagement quotaManagement,
|
||||||
final TenantAware tenantAware) {
|
final TenantAware tenantAware) {
|
||||||
this.localArtifactRepository = localArtifactRepository;
|
this.artifactRepository = artifactRepository;
|
||||||
this.artifactRepository = artifactRepository.orElse(null);
|
this.artifactStorage = artifactStorage.orElse(null);
|
||||||
this.softwareModuleRepository = softwareModuleRepository;
|
this.softwareModuleRepository = softwareModuleRepository;
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.txManager = txManager;
|
this.txManager = txManager;
|
||||||
@@ -97,7 +97,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Artifact create(final ArtifactUpload artifactUpload) {
|
public Artifact create(final ArtifactUpload artifactUpload) {
|
||||||
if (artifactRepository == null) {
|
if (artifactStorage == null) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
moduleId, 1, quotaManagement.getMaxArtifactsPerSoftwareModule(),
|
moduleId, 1, quotaManagement.getMaxArtifactsPerSoftwareModule(),
|
||||||
Artifact.class, SoftwareModule.class,
|
Artifact.class, SoftwareModule.class,
|
||||||
// get all artifacts without user context
|
// get all artifacts without user context
|
||||||
softwareModuleId -> localArtifactRepository.count(null, ArtifactSpecifications.bySoftwareModuleId(softwareModuleId)));
|
softwareModuleId -> artifactRepository.count(null, ArtifactSpecifications.bySoftwareModuleId(softwareModuleId)));
|
||||||
|
|
||||||
final JpaSoftwareModule softwareModule = softwareModuleRepository.getById(moduleId);
|
final JpaSoftwareModule softwareModule = softwareModuleRepository.getById(moduleId);
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
try {
|
try {
|
||||||
return storeArtifactMetadata(softwareModule, filename, artifact.getHashes(), artifact.getSize(), existing);
|
return storeArtifactMetadata(softwareModule, filename, artifact.getHashes(), artifact.getSize(), existing);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
artifactRepository.deleteBySha1(tenantAware.getCurrentTenant(), artifact.getHashes().sha1());
|
artifactStorage.deleteBySha1(tenantAware.getCurrentTenant(), artifact.getHashes().sha1());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@SuppressWarnings("java:S2201") // java:S2201 - the idea is to just check if the artifact exists
|
@SuppressWarnings("java:S2201") // java:S2201 - the idea is to just check if the artifact exists
|
||||||
@Override
|
@Override
|
||||||
public ArtifactStream getArtifactStream(final String sha1Hash, final long softwareModuleId, final boolean isEncrypted) {
|
public ArtifactStream getArtifactStream(final String sha1Hash, final long softwareModuleId, final boolean isEncrypted) {
|
||||||
if (artifactRepository == null) {
|
if (artifactStorage == null) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,11 +146,11 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
if (isEncrypted) {
|
if (isEncrypted) {
|
||||||
final ArtifactEncryptionService encryptionService = ArtifactEncryptionService.getInstance();
|
final ArtifactEncryptionService encryptionService = ArtifactEncryptionService.getInstance();
|
||||||
return new ArtifactStream(
|
return new ArtifactStream(
|
||||||
encryptionService.decryptArtifact(softwareModuleId, artifactRepository.getBySha1(tenant, sha1Hash)),
|
encryptionService.decryptArtifact(softwareModuleId, artifactStorage.getBySha1(tenant, sha1Hash)),
|
||||||
artifact.getSize() - encryptionService.encryptionSizeOverhead(),
|
artifact.getSize() - encryptionService.encryptionSizeOverhead(),
|
||||||
artifact.getSha1Hash());
|
artifact.getSha1Hash());
|
||||||
} else {
|
} else {
|
||||||
return new ArtifactStream(artifactRepository.getBySha1(tenant, sha1Hash), artifact.getSize(), artifact.getSha1Hash());
|
return new ArtifactStream(artifactStorage.getBySha1(tenant, sha1Hash), artifact.getSize(), artifact.getSha1Hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,11 +162,11 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
if (artifactRepository == null) {
|
if (artifactStorage == null) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final JpaArtifact toDelete = localArtifactRepository.getById(id);
|
final JpaArtifact toDelete = artifactRepository.getById(id);
|
||||||
|
|
||||||
final JpaSoftwareModule softwareModule = toDelete.getSoftwareModule();
|
final JpaSoftwareModule softwareModule = toDelete.getSoftwareModule();
|
||||||
// clearArtifactBinary checks (unconditionally) software module UPDATE access
|
// clearArtifactBinary checks (unconditionally) software module UPDATE access
|
||||||
@@ -175,7 +175,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
softwareModule.removeArtifact(toDelete);
|
softwareModule.removeArtifact(toDelete);
|
||||||
softwareModuleRepository.save(softwareModule);
|
softwareModuleRepository.save(softwareModule);
|
||||||
|
|
||||||
localArtifactRepository.deleteById(id);
|
artifactRepository.deleteById(id);
|
||||||
|
|
||||||
final String sha1Hash = toDelete.getSha1Hash();
|
final String sha1Hash = toDelete.getSha1Hash();
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> clearArtifactBinary(sha1Hash));
|
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> clearArtifactBinary(sha1Hash));
|
||||||
@@ -195,14 +195,14 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
void clearArtifactBinary(final String sha1Hash) {
|
void clearArtifactBinary(final String sha1Hash) {
|
||||||
DeploymentHelper.runInNewTransaction(txManager, "clearArtifactBinary", status -> {
|
DeploymentHelper.runInNewTransaction(txManager, "clearArtifactBinary", status -> {
|
||||||
// countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse will skip ACM checks and will return total count as it should be
|
// countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse will skip ACM checks and will return total count as it should be
|
||||||
if (localArtifactRepository.countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse(sha1Hash,
|
if (artifactRepository.countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse(sha1Hash,
|
||||||
tenantAware.getCurrentTenant()) <= 0) { // 1 artifact is the one being deleted!
|
tenantAware.getCurrentTenant()) <= 0) { // 1 artifact is the one being deleted!
|
||||||
// removes the real artifact ONLY AFTER the delete of artifact or software module
|
// removes the real artifact ONLY AFTER the delete of artifact or software module
|
||||||
// in local history has passed successfully (caller has permission and no errors)
|
// in local history has passed successfully (caller has permission and no errors)
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> {
|
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> {
|
||||||
try {
|
try {
|
||||||
log.debug("deleting artifact from repository {}", sha1Hash);
|
log.debug("deleting artifact from repository {}", sha1Hash);
|
||||||
artifactRepository.deleteBySha1(tenantAware.getCurrentTenant(), sha1Hash);
|
artifactStorage.deleteBySha1(tenantAware.getCurrentTenant(), sha1Hash);
|
||||||
} catch (final ArtifactStoreException e) {
|
} catch (final ArtifactStoreException e) {
|
||||||
throw new ArtifactDeleteFailedException(e);
|
throw new ArtifactDeleteFailedException(e);
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
final InputStream stream = artifactUpload.inputStream();
|
final InputStream stream = artifactUpload.inputStream();
|
||||||
try (final InputStream wrappedStream = wrapInQuotaStream(
|
try (final InputStream wrappedStream = wrapInQuotaStream(
|
||||||
isSmEncrypted ? wrapInEncryptionStream(artifactUpload.moduleId(), stream) : stream)) {
|
isSmEncrypted ? wrapInEncryptionStream(artifactUpload.moduleId(), stream) : stream)) {
|
||||||
return artifactRepository.store(
|
return artifactStorage.store(
|
||||||
tenantAware.getCurrentTenant(),
|
tenantAware.getCurrentTenant(),
|
||||||
wrappedStream, artifactUpload.filename(),
|
wrappedStream, artifactUpload.filename(),
|
||||||
artifactUpload.contentType(), artifactUpload.hash());
|
artifactUpload.contentType(), artifactUpload.hash());
|
||||||
@@ -240,7 +240,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
private InputStream wrapInQuotaStream(final InputStream in) {
|
private InputStream wrapInQuotaStream(final InputStream in) {
|
||||||
final long maxArtifactSize = quotaManagement.getMaxArtifactSize();
|
final long maxArtifactSize = quotaManagement.getMaxArtifactSize();
|
||||||
|
|
||||||
final long currentlyUsed = localArtifactRepository.sumOfNonDeletedArtifactSize().orElse(0L);
|
final long currentlyUsed = artifactRepository.sumOfNonDeletedArtifactSize().orElse(0L);
|
||||||
final long maxArtifactSizeTotal = quotaManagement.getMaxArtifactStorage();
|
final long maxArtifactSizeTotal = quotaManagement.getMaxArtifactStorage();
|
||||||
|
|
||||||
return new FileSizeAndStorageQuotaCheckingInputStream(in, maxArtifactSize, maxArtifactSizeTotal - currentlyUsed);
|
return new FileSizeAndStorageQuotaCheckingInputStream(in, maxArtifactSize, maxArtifactSizeTotal - currentlyUsed);
|
||||||
@@ -262,6 +262,6 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
artifact.setFileSize(fileSize);
|
artifact.setFileSize(fileSize);
|
||||||
|
|
||||||
log.debug("storing new artifact into repository {}", artifact);
|
log.debug("storing new artifact into repository {}", artifact);
|
||||||
return localArtifactRepository.save(AccessController.Operation.CREATE, artifact);
|
return artifactRepository.save(AccessController.Operation.CREATE, artifact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.management;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.LocalArtifactRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ArtifactRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
|
||||||
import org.eclipse.hawkbit.repository.model.report.TenantUsage;
|
import org.eclipse.hawkbit.repository.model.report.TenantUsage;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
@@ -30,12 +30,12 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
public class JpaTenantStatsManagement implements TenantStatsManagement {
|
public class JpaTenantStatsManagement implements TenantStatsManagement {
|
||||||
|
|
||||||
private final TargetRepository targetRepository;
|
private final TargetRepository targetRepository;
|
||||||
private final LocalArtifactRepository artifactRepository;
|
private final ArtifactRepository artifactRepository;
|
||||||
private final ActionRepository actionRepository;
|
private final ActionRepository actionRepository;
|
||||||
private final TenantAware tenantAware;
|
private final TenantAware tenantAware;
|
||||||
|
|
||||||
protected JpaTenantStatsManagement(
|
protected JpaTenantStatsManagement(
|
||||||
final TargetRepository targetRepository, final LocalArtifactRepository artifactRepository, final ActionRepository actionRepository,
|
final TargetRepository targetRepository, final ArtifactRepository artifactRepository, final ActionRepository actionRepository,
|
||||||
final TenantAware tenantAware) {
|
final TenantAware tenantAware) {
|
||||||
this.targetRepository = targetRepository;
|
this.targetRepository = targetRepository;
|
||||||
this.artifactRepository = artifactRepository;
|
this.artifactRepository = artifactRepository;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
* {@link Artifact} repository.
|
* {@link Artifact} repository.
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface LocalArtifactRepository extends BaseEntityRepository<JpaArtifact> {
|
public interface ArtifactRepository extends BaseEntityRepository<JpaArtifact> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts artifacts size where the related software module is not deleted/archived.
|
* Counts artifacts size where the related software module is not deleted/archived.
|
||||||
@@ -32,7 +32,7 @@ import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTagRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTagRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetTypeRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.LocalArtifactRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ArtifactRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutGroupRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.RolloutTargetGroupRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.RolloutTargetGroupRepository;
|
||||||
@@ -98,7 +98,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected ActionStatusRepository actionStatusRepository;
|
protected ActionStatusRepository actionStatusRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected LocalArtifactRepository artifactRepository;
|
protected ArtifactRepository artifactRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RolloutGroupRepository rolloutGroupRepository;
|
protected RolloutGroupRepository rolloutGroupRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
Reference in New Issue
Block a user