diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index 0a3838354..53f47dae7 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -321,14 +321,10 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) public DistributionSet createDistributionSet(@NotNull final DistributionSet dSet) { prepareDsSave(dSet); - if (dSet.getType() == null) { dSet.setType(systemManagement.getTenantMetadata().getDefaultDsType()); } - - final DistributionSet result = distributionSetRepository.save(dSet); - - return result; + return distributionSetRepository.save(dSet); } private void prepareDsSave(final DistributionSet dSet) { @@ -400,7 +396,7 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds, final SoftwareModule softwareModule) { - final Set softwareModules = new HashSet(); + final Set softwareModules = new HashSet<>(); softwareModules.add(softwareModule); ds.removeModule(softwareModule); checkDistributionSetSoftwareModulesIsAllowedToModify(ds, softwareModules); @@ -491,20 +487,16 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) private DistributionSet findDistributionSetsByFiltersAndInstalledOrAssignedTarget( final DistributionSetFilter distributionSetFilter) { - final List> specList = buildDistributionSetSpecifications(distributionSetFilter); - - Specifications specs = null; if (!specList.isEmpty()) { - specs = Specifications.where(specList.get(0)); - } - if (specList.size() > 1) { + Specifications specs = Specifications.where(specList.get(0)); specList.remove(0); for (final Specification s : specList) { specs = specs.and(s); } + return distributionSetRepository.findOne(specs); } - return distributionSetRepository.findOne(specs); + return null; } /** @@ -531,7 +523,7 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findDistributionSetsAll(@NotNull final Pageable pageReq, final Boolean deleted, final Boolean complete) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); if (deleted != null) { final Specification spec = DistributionSetSpecification.isDeleted(deleted); @@ -563,7 +555,7 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Page findDistributionSetsAll(@NotNull final Specification spec, @NotNull final Pageable pageReq, final Boolean deleted) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); if (deleted != null) { specList.add(DistributionSetSpecification.isDeleted(deleted)); } @@ -689,7 +681,7 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public Long countDistributionSetsAll() { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); final Specification spec = DistributionSetSpecification.isDeleted(Boolean.FALSE); specList.add(spec); @@ -873,11 +865,8 @@ public class DistributionSetManagement { @Override public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { - - final Predicate predicate = cb.equal( - root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), distributionSetId); - - return predicate; + return cb.equal(root.get(DistributionSetMetadata_.distributionSet).get(DistributionSet_.id), + distributionSetId); } }, pageable); @@ -969,9 +958,9 @@ public class DistributionSetManagement { private List> buildDistributionSetSpecifications( final DistributionSetFilter distributionSetFilter) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); - Specification spec = null; + Specification spec; if (null != distributionSetFilter.getIsComplete()) { spec = DistributionSetSpecification.isCompleted(distributionSetFilter.getIsComplete());