Add @PreAuthorized to RepositoryManagement impl (#2159)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -27,6 +27,7 @@ import java.util.stream.Collectors;
|
|||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
||||||
@@ -86,6 +87,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
@@ -151,6 +153,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
||||||
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
||||||
.map(this::setDefaultTypeIfMissing).map(JpaDistributionSetCreate::build).toList();
|
.map(this::setDefaultTypeIfMissing).map(JpaDistributionSetCreate::build).toList();
|
||||||
@@ -162,6 +165,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public DistributionSet create(final DistributionSetCreate c) {
|
public DistributionSet create(final DistributionSetCreate c) {
|
||||||
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
||||||
setDefaultTypeIfMissing(create);
|
setDefaultTypeIfMissing(create);
|
||||||
@@ -173,6 +177,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSet update(final DistributionSetUpdate u) {
|
public DistributionSet update(final DistributionSetUpdate u) {
|
||||||
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
||||||
|
|
||||||
@@ -204,6 +209,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public long count() {
|
public long count() {
|
||||||
return distributionSetRepository.count(DistributionSetSpecification.isNotDeleted());
|
return distributionSetRepository.count(DistributionSetSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
@@ -212,6 +218,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
delete(List.of(id));
|
delete(List.of(id));
|
||||||
}
|
}
|
||||||
@@ -220,6 +227,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final Collection<Long> distributionSetIDs) {
|
public void delete(final Collection<Long> distributionSetIDs) {
|
||||||
getDistributionSets(distributionSetIDs); // throws EntityNotFoundException if any of these do not exists
|
getDistributionSets(distributionSetIDs); // throws EntityNotFoundException if any of these do not exists
|
||||||
final List<JpaDistributionSet> setsFound = distributionSetRepository.findAll(
|
final List<JpaDistributionSet> setsFound = distributionSetRepository.findAll(
|
||||||
@@ -260,27 +268,32 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<DistributionSet> get(final Collection<Long> ids) {
|
public List<DistributionSet> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(getDistributionSets(ids));
|
return Collections.unmodifiableList(getDistributionSets(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public boolean exists(final long id) {
|
public boolean exists(final long id) {
|
||||||
return distributionSetRepository.existsById(id);
|
return distributionSetRepository.existsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Optional<DistributionSet> get(final long id) {
|
public Optional<DistributionSet> get(final long id) {
|
||||||
return distributionSetRepository.findById(id).map(DistributionSet.class::cast);
|
return distributionSetRepository.findById(id).map(DistributionSet.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<DistributionSet> findAll(final Pageable pageable) {
|
public Slice<DistributionSet> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, pageable, List.of(
|
||||||
DistributionSetSpecification.isNotDeleted()));
|
DistributionSetSpecification.isNotDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<DistributionSet> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<DistributionSet> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, pageable, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer,
|
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTagFields;
|
import org.eclipse.hawkbit.repository.DistributionSetTagFields;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||||
@@ -43,6 +44,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@@ -72,6 +74,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
||||||
final List<JpaDistributionSetTag> toCreate = dst.stream().map(JpaTagCreate.class::cast)
|
final List<JpaDistributionSetTag> toCreate = dst.stream().map(JpaTagCreate.class::cast)
|
||||||
.map(JpaTagCreate::buildDistributionSetTag).toList();
|
.map(JpaTagCreate::buildDistributionSetTag).toList();
|
||||||
@@ -83,6 +86,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public DistributionSetTag create(final TagCreate c) {
|
public DistributionSetTag create(final TagCreate c) {
|
||||||
final JpaTagCreate create = (JpaTagCreate) c;
|
final JpaTagCreate create = (JpaTagCreate) c;
|
||||||
return distributionSetTagRepository.save(AccessController.Operation.CREATE, create.buildDistributionSetTag());
|
return distributionSetTagRepository.save(AccessController.Operation.CREATE, create.buildDistributionSetTag());
|
||||||
@@ -92,6 +96,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSetTag update(final TagUpdate u) {
|
public DistributionSetTag update(final TagUpdate u) {
|
||||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||||
|
|
||||||
@@ -106,6 +111,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public long count() {
|
public long count() {
|
||||||
return distributionSetTagRepository.count();
|
return distributionSetTagRepository.count();
|
||||||
}
|
}
|
||||||
@@ -114,6 +120,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
distributionSetTagRepository.deleteById(id);
|
distributionSetTagRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
@@ -122,6 +129,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAllById(ids);
|
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAllById(ids);
|
||||||
|
|
||||||
@@ -134,26 +142,31 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<DistributionSetTag> get(final Collection<Long> ids) {
|
public List<DistributionSetTag> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(distributionSetTagRepository.findAllById(ids));
|
return Collections.unmodifiableList(distributionSetTagRepository.findAllById(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public boolean exists(final long id) {
|
public boolean exists(final long id) {
|
||||||
return distributionSetTagRepository.existsById(id);
|
return distributionSetTagRepository.existsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Optional<DistributionSetTag> get(final long id) {
|
public Optional<DistributionSetTag> get(final long id) {
|
||||||
return distributionSetTagRepository.findById(id).map(DistributionSetTag.class::cast);
|
return distributionSetTagRepository.findById(id).map(DistributionSetTag.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTagRepository, pageable, null);
|
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTagRepository, pageable, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<DistributionSetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<DistributionSetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTagFields.class,
|
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTagFields.class,
|
||||||
virtualPropertyReplacer, database);
|
virtualPropertyReplacer, database);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.util.function.LongFunction;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||||
@@ -52,6 +53,7 @@ import org.springframework.data.domain.Slice;
|
|||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -127,6 +129,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
||||||
final List<JpaDistributionSetType> typesToCreate = types.stream()
|
final List<JpaDistributionSetType> typesToCreate = types.stream()
|
||||||
.map(JpaDistributionSetTypeCreate.class::cast)
|
.map(JpaDistributionSetTypeCreate.class::cast)
|
||||||
@@ -139,6 +142,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
||||||
final JpaDistributionSetType distributionSetType = ((JpaDistributionSetTypeCreate) c).build();
|
final JpaDistributionSetType distributionSetType = ((JpaDistributionSetTypeCreate) c).build();
|
||||||
return distributionSetTypeRepository.save(AccessController.Operation.CREATE, distributionSetType);
|
return distributionSetTypeRepository.save(AccessController.Operation.CREATE, distributionSetType);
|
||||||
@@ -148,6 +152,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
||||||
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
||||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(update.getId());
|
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(update.getId());
|
||||||
@@ -181,6 +186,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public long count() {
|
public long count() {
|
||||||
return distributionSetTypeRepository.count(DistributionSetTypeSpecification.isNotDeleted());
|
return distributionSetTypeRepository.count(DistributionSetTypeSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
@@ -189,6 +195,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(id)
|
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, id));
|
||||||
@@ -207,32 +214,38 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
distributionSetTypeRepository.deleteAllById(ids);
|
distributionSetTypeRepository.deleteAllById(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<DistributionSetType> get(final Collection<Long> ids) {
|
public List<DistributionSetType> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(distributionSetTypeRepository.findAllById(ids));
|
return Collections.unmodifiableList(distributionSetTypeRepository.findAllById(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public boolean exists(final long id) {
|
public boolean exists(final long id) {
|
||||||
return distributionSetTypeRepository.existsById(id);
|
return distributionSetTypeRepository.existsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Optional<DistributionSetType> get(final long id) {
|
public Optional<DistributionSetType> get(final long id) {
|
||||||
return distributionSetTypeRepository.findById(id).map(DistributionSetType.class::cast);
|
return distributionSetTypeRepository.findById(id).map(DistributionSetType.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<DistributionSetType> findAll(final Pageable pageable) {
|
public Slice<DistributionSetType> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTypeRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTypeRepository, pageable, List.of(
|
||||||
DistributionSetTypeSpecification.isNotDeleted()));
|
DistributionSetTypeSpecification.isNotDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<DistributionSetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<DistributionSetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, pageable, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.ArtifactEncryptionService;
|
import org.eclipse.hawkbit.repository.ArtifactEncryptionService;
|
||||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||||
@@ -72,6 +73,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -118,6 +120,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
||||||
final List<JpaSoftwareModule> modulesToCreate = swModules.stream().map(JpaSoftwareModuleCreate.class::cast)
|
final List<JpaSoftwareModule> modulesToCreate = swModules.stream().map(JpaSoftwareModuleCreate.class::cast)
|
||||||
.map(JpaSoftwareModuleCreate::build).toList();
|
.map(JpaSoftwareModuleCreate::build).toList();
|
||||||
@@ -138,6 +141,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public SoftwareModule create(final SoftwareModuleCreate c) {
|
public SoftwareModule create(final SoftwareModuleCreate c) {
|
||||||
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
||||||
|
|
||||||
@@ -155,6 +159,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
||||||
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
||||||
|
|
||||||
@@ -175,6 +180,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public long count() {
|
public long count() {
|
||||||
return softwareModuleRepository.count(SoftwareModuleSpecification.isNotDeleted());
|
return softwareModuleRepository.count(SoftwareModuleSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
@@ -183,6 +189,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
delete(List.of(id));
|
delete(List.of(id));
|
||||||
}
|
}
|
||||||
@@ -191,6 +198,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findAllById(ids);
|
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findAllById(ids);
|
||||||
if (swModulesToDelete.size() < ids.size()) {
|
if (swModulesToDelete.size() < ids.size()) {
|
||||||
@@ -235,21 +243,25 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<SoftwareModule> get(final Collection<Long> ids) {
|
public List<SoftwareModule> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(softwareModuleRepository.findAllById(ids));
|
return Collections.unmodifiableList(softwareModuleRepository.findAllById(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public boolean exists(final long id) {
|
public boolean exists(final long id) {
|
||||||
return softwareModuleRepository.existsById(id);
|
return softwareModuleRepository.existsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Optional<SoftwareModule> get(final long id) {
|
public Optional<SoftwareModule> get(final long id) {
|
||||||
return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast);
|
return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<SoftwareModule> findAll(final Pageable pageable) {
|
public Slice<SoftwareModule> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, pageable, List.of(
|
||||||
SoftwareModuleSpecification.isNotDeleted(),
|
SoftwareModuleSpecification.isNotDeleted(),
|
||||||
@@ -257,6 +269,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<SoftwareModule> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<SoftwareModule> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, pageable, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer,
|
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.builder.GenericSoftwareModuleTypeUpdate;
|
import org.eclipse.hawkbit.repository.builder.GenericSoftwareModuleTypeUpdate;
|
||||||
@@ -39,6 +40,7 @@ import org.springframework.data.domain.Slice;
|
|||||||
import org.springframework.orm.jpa.vendor.Database;
|
import org.springframework.orm.jpa.vendor.Database;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
||||||
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
||||||
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
||||||
@@ -92,6 +95,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
||||||
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
||||||
|
|
||||||
@@ -102,6 +106,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
||||||
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
||||||
|
|
||||||
@@ -115,6 +120,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public long count() {
|
public long count() {
|
||||||
return softwareModuleTypeRepository.count(SoftwareModuleTypeSpecification.isNotDeleted());
|
return softwareModuleTypeRepository.count(SoftwareModuleTypeSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
@@ -123,6 +129,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(id)
|
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, id));
|
||||||
@@ -134,6 +141,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@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))
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
softwareModuleTypeRepository
|
softwareModuleTypeRepository
|
||||||
.findAll(AccessController.Operation.DELETE, softwareModuleTypeRepository.byIdsSpec(ids))
|
.findAll(AccessController.Operation.DELETE, softwareModuleTypeRepository.byIdsSpec(ids))
|
||||||
@@ -141,27 +149,32 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<SoftwareModuleType> get(final Collection<Long> ids) {
|
public List<SoftwareModuleType> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(softwareModuleTypeRepository.findAllById(ids));
|
return Collections.unmodifiableList(softwareModuleTypeRepository.findAllById(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public boolean exists(final long id) {
|
public boolean exists(final long id) {
|
||||||
return softwareModuleTypeRepository.existsById(id);
|
return softwareModuleTypeRepository.existsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Optional<SoftwareModuleType> get(final long id) {
|
public Optional<SoftwareModuleType> get(final long id) {
|
||||||
return softwareModuleTypeRepository.findById(id).map(SoftwareModuleType.class::cast);
|
return softwareModuleTypeRepository.findById(id).map(SoftwareModuleType.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<SoftwareModuleType> findAll(final Pageable pageable) {
|
public Slice<SoftwareModuleType> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleTypeRepository, pageable,
|
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleTypeRepository, pageable,
|
||||||
List.of(SoftwareModuleTypeSpecification.isNotDeleted()));
|
List.of(SoftwareModuleTypeSpecification.isNotDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Page<SoftwareModuleType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<SoftwareModuleType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, pageable,
|
||||||
List.of(
|
List.of(
|
||||||
|
|||||||
Reference in New Issue
Block a user