Fix sonar finding for string duplications (#2023)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.management;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import jakarta.annotation.Nullable;
|
import jakarta.annotation.Nullable;
|
||||||
@@ -105,9 +104,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Artifact create(final ArtifactUpload artifactUpload) {
|
public Artifact create(final ArtifactUpload artifactUpload) {
|
||||||
if (artifactRepository == null) {
|
assertArtifactRepositoryAvailable();
|
||||||
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
final long moduleId = artifactUpload.getModuleId();
|
final long moduleId = artifactUpload.getModuleId();
|
||||||
assertArtifactQuota(moduleId, 1);
|
assertArtifactQuota(moduleId, 1);
|
||||||
@@ -198,9 +195,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
|
|
||||||
@Override
|
@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) {
|
assertArtifactRepositoryAvailable();
|
||||||
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
assertSoftwareModuleExists(softwareModuleId);
|
assertSoftwareModuleExists(softwareModuleId);
|
||||||
|
|
||||||
@@ -230,9 +225,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
void clearArtifactBinary(final String sha1Hash) {
|
void clearArtifactBinary(final String sha1Hash) {
|
||||||
if (artifactRepository == null) {
|
assertArtifactRepositoryAvailable();
|
||||||
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
// countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse will skip ACM checks and
|
// countBySha1HashAndTenantAndSoftwareModuleDeletedIsFalse will skip ACM checks and
|
||||||
// will return total count as it should be
|
// will return total count as it should be
|
||||||
@@ -339,4 +332,10 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
throw new EntityNotFoundException(SoftwareModule.class, softwareModuleId);
|
throw new EntityNotFoundException(SoftwareModule.class, softwareModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertArtifactRepositoryAvailable() {
|
||||||
|
if (artifactRepository == null) {
|
||||||
|
throw new UnsupportedOperationException("ArtifactRepository is unavailable");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user