Fix small sonar findings (#2413)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -80,6 +80,7 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
@Validated
|
@Validated
|
||||||
public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||||
|
|
||||||
|
protected static final String SOFTWARE_MODULE_METADATA = "SoftwareModuleMetadata";
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final DistributionSetRepository distributionSetRepository;
|
private final DistributionSetRepository distributionSetRepository;
|
||||||
private final SoftwareModuleRepository softwareModuleRepository;
|
private final SoftwareModuleRepository softwareModuleRepository;
|
||||||
@@ -298,7 +299,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
public SoftwareModuleMetadata getMetadata(final long id, final String key) {
|
public SoftwareModuleMetadata getMetadata(final long id, final String key) {
|
||||||
assertSoftwareModuleExists(id);
|
assertSoftwareModuleExists(id);
|
||||||
|
|
||||||
return findMetadata(id, key).orElseThrow(() -> new EntityNotFoundException("SoftwareModuleMetadata", id + ":" + key));
|
return findMetadata(id, key).orElseThrow(() -> new EntityNotFoundException(SOFTWARE_MODULE_METADATA, id + ":" + key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -337,7 +338,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
// check if exists otherwise throw entity not found exception
|
// check if exists otherwise throw entity not found exception
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findMetadata(
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findMetadata(
|
||||||
update.getSoftwareModuleId(), update.getKey())
|
update.getSoftwareModuleId(), update.getKey())
|
||||||
.orElseThrow(() -> new EntityNotFoundException("SoftwareModuleMetadata", update.getSoftwareModuleId() + ":" + update.getKey()));
|
.orElseThrow(() -> new EntityNotFoundException(SOFTWARE_MODULE_METADATA, update.getSoftwareModuleId() + ":" + update.getKey()));
|
||||||
|
|
||||||
update.getValue().ifPresent(metadata::setValue);
|
update.getValue().ifPresent(metadata::setValue);
|
||||||
update.isTargetVisible().ifPresent(metadata::setTargetVisible);
|
update.isTargetVisible().ifPresent(metadata::setTargetVisible);
|
||||||
@@ -352,7 +353,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteMetadata(final long id, final String key) {
|
public void deleteMetadata(final long id, final String key) {
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findMetadata(id, key)
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findMetadata(id, key)
|
||||||
.orElseThrow(() -> new EntityNotFoundException("SoftwareModuleMetadata", id + ":" + key));
|
.orElseThrow(() -> new EntityNotFoundException(SOFTWARE_MODULE_METADATA, id + ":" + key));
|
||||||
|
|
||||||
JpaManagementHelper.touch(entityManager, softwareModuleRepository, metadata.getSoftwareModule());
|
JpaManagementHelper.touch(entityManager, softwareModuleRepository, metadata.getSoftwareModule());
|
||||||
softwareModuleMetadataRepository.deleteById(metadata.getId());
|
softwareModuleMetadataRepository.deleteById(metadata.getId());
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.function.ToLongFunction;
|
|||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||||
@@ -20,7 +21,7 @@ import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException
|
|||||||
/**
|
/**
|
||||||
* Helper class to check quotas.
|
* Helper class to check quotas.
|
||||||
*/
|
*/
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class QuotaHelper {
|
public final class QuotaHelper {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user