Reduce dependency on Guava 2 (#1590)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -33,15 +33,14 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.eclipse.hawkbit.repository.ConfirmationManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
@@ -473,7 +472,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
private Void updateLastTargetQueries(final String tenant, final List<TargetPoll> polls) {
|
||||
LOG.debug("Persist {} targetqueries.", polls.size());
|
||||
|
||||
final List<List<String>> pollChunks = Lists.partition(
|
||||
final List<List<String>> pollChunks = ListUtils.partition(
|
||||
polls.stream().map(TargetPoll::getControllerId).collect(Collectors.toList()),
|
||||
Constants.MAX_ENTRIES_IN_STATEMENT);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
@@ -37,6 +36,7 @@ import jakarta.persistence.criteria.JoinType;
|
||||
import jakarta.persistence.criteria.ListJoin;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
@@ -281,7 +281,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
private void checkCompatibilityForSingleDsAssignment(final Long distSetId, final List<String> controllerIds) {
|
||||
final DistributionSetType distSetType = distributionSetManagement.getValidAndComplete(distSetId).getType();
|
||||
final Set<String> incompatibleTargetTypes = Lists.partition(controllerIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||
final Set<String> incompatibleTargetTypes = ListUtils.partition(controllerIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||
.stream()
|
||||
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids)
|
||||
.and(TargetSpecifications.notCompatibleWithDistributionSetType(distSetType.getId()))))
|
||||
@@ -377,7 +377,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
final List<String> providedTargetIds = targetsWithActionType.stream().map(TargetWithActionType::getControllerId)
|
||||
.distinct().toList();
|
||||
|
||||
final List<String> existingTargetIds = Lists.partition(providedTargetIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||
final List<String> existingTargetIds = ListUtils.partition(providedTargetIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||
.stream()
|
||||
.map(ids -> targetRepository.findAll(AccessController.Operation.UPDATE,
|
||||
TargetSpecifications.hasControllerIdIn(ids)))
|
||||
@@ -442,7 +442,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
* statements
|
||||
*/
|
||||
private static List<List<Long>> getTargetEntitiesAsChunks(final List<JpaTarget> targetEntities) {
|
||||
return Lists.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()),
|
||||
return ListUtils.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()),
|
||||
Constants.MAX_ENTRIES_IN_STATEMENT);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
@@ -29,6 +28,7 @@ import jakarta.persistence.criteria.MapJoin;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
@@ -40,7 +40,6 @@ import org.eclipse.hawkbit.repository.TimestampCalculator;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.TargetUpdate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
@@ -49,7 +48,6 @@ import org.eclipse.hawkbit.repository.jpa.acm.AccessController;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetUpdate;
|
||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata_;
|
||||
@@ -553,7 +551,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
private List<JpaTarget> findTargetsByInSpecification(final Collection<String> controllerIds,
|
||||
final Specification<JpaTarget> specification) {
|
||||
return Lists.partition(new ArrayList<>(controllerIds), Constants.MAX_ENTRIES_IN_STATEMENT).stream()
|
||||
return ListUtils.partition(new ArrayList<>(controllerIds), Constants.MAX_ENTRIES_IN_STATEMENT).stream()
|
||||
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids).and(specification)))
|
||||
.flatMap(List::stream).toList();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||
@@ -75,7 +75,7 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
Arrays.asList(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId),
|
||||
TargetSpecifications.notEqualToTargetUpdateStatus(TargetUpdateStatus.PENDING))));
|
||||
}
|
||||
return Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||
return ListUtils.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||
.flatMap(List::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||
import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent;
|
||||
@@ -109,7 +109,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
mapper = ids -> targetRepository
|
||||
.findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId));
|
||||
}
|
||||
return Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||
return ListUtils.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||
.flatMap(List::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
@@ -159,7 +159,20 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
||||
if (messages == null) {
|
||||
messages = new ArrayList<>((message.length() / MESSAGE_ENTRY_LENGTH) + 1);
|
||||
}
|
||||
Splitter.fixedLength(MESSAGE_ENTRY_LENGTH).split(message).forEach(messages::add);
|
||||
if (message.length() > MESSAGE_ENTRY_LENGTH) {
|
||||
// split
|
||||
for (int off = 0; off < message.length();) {
|
||||
final int end = off + MESSAGE_ENTRY_LENGTH;
|
||||
if (end < message.length()) {
|
||||
messages.add(message.substring(off, end));
|
||||
} else {
|
||||
messages.add(message.substring(off));
|
||||
}
|
||||
off = end;
|
||||
}
|
||||
} else {
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -36,9 +37,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cz.jirutka.rsql.parser.ParseException;
|
||||
import cz.jirutka.rsql.parser.RSQLParserException;
|
||||
|
||||
@@ -254,22 +252,14 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
// sensitive help on search query.
|
||||
private static final class TokenDescription {
|
||||
|
||||
private static final Multimap<Integer, String> TOKEN_MAP = ArrayListMultimap.create();
|
||||
private static final Map<Integer, List<String>> TOKEN_MAP = new HashMap<>();
|
||||
|
||||
private static final int LOGICAL_OP = 8;
|
||||
private static final int COMPARATOR = 12;
|
||||
|
||||
static {
|
||||
TOKEN_MAP.put(LOGICAL_OP, "and");
|
||||
TOKEN_MAP.put(LOGICAL_OP, "or");
|
||||
TOKEN_MAP.put(COMPARATOR, "==");
|
||||
TOKEN_MAP.put(COMPARATOR, "!=");
|
||||
TOKEN_MAP.put(COMPARATOR, "=ge=");
|
||||
TOKEN_MAP.put(COMPARATOR, "=le=");
|
||||
TOKEN_MAP.put(COMPARATOR, "=gt=");
|
||||
TOKEN_MAP.put(COMPARATOR, "=lt=");
|
||||
TOKEN_MAP.put(COMPARATOR, "=in=");
|
||||
TOKEN_MAP.put(COMPARATOR, "=out=");
|
||||
TOKEN_MAP.put(LOGICAL_OP, List.of("and", "or"));
|
||||
TOKEN_MAP.put(COMPARATOR, List.of("==", "!=", "=ge=", "=le=", "=gt=", "=lt=", "=in=", "=out="));
|
||||
}
|
||||
|
||||
private TokenDescription() {
|
||||
@@ -279,7 +269,6 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
private static Collection<String> getTokenImage(final int tokenIndex) {
|
||||
return TOKEN_MAP.get(tokenIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final class FieldNameDescription {
|
||||
|
||||
Reference in New Issue
Block a user