From ca11575be5f6afe1d2d5f3a1192cebeecefb461b Mon Sep 17 00:00:00 2001 From: Andrew Berezovskyi Date: Thu, 9 Jan 2025 16:35:17 +0100 Subject: [PATCH] refactor: get rid of Guava (#669) --- .../eclipse/lyo/client/OslcOAuthClient.java | 4 +- core/lyo-core-settings/pom.xml | 4 - .../eclipse/lyo/core/util/StringUtils.java | 77 +++++++++++++++++++ .../eclipse/lyo/oslc4j/core/OSLC4JUtils.java | 4 +- core/oslc4j-jena-provider/pom.xml | 5 -- .../provider/jena/JenaModelHelperTest.java | 4 +- .../oslc4j/provider/jena/test/JsonLdTest.java | 11 +-- core/shacl/pom.xml | 4 - .../java/org/eclipse/lyo/shacl/Shape.java | 5 +- pom.xml | 8 -- server/oslc-ui-model/pom.xml | 4 - .../lyo/server/ui/model/PreviewFactory.java | 4 +- store/store-core/pom.xml | 4 - .../lyo/store/internals/SparqlStoreImpl.java | 12 +-- .../lyo/store/SparqlStoreImplTest.java | 12 +-- .../org/eclipse/lyo/store/StoreTestBase.java | 11 +-- trs/client/trs-client/pom.xml | 4 - trs/server/pom.xml | 4 - .../service/TrackedResourceSetService.java | 4 +- .../oslc4j/trs/server/InmemPagedTrsTest.java | 18 ++--- .../server/service/TRSServiceResource.java | 12 +-- validation/pom.xml | 5 -- 22 files changed, 125 insertions(+), 95 deletions(-) create mode 100644 core/lyo-core-settings/src/main/java/org/eclipse/lyo/core/util/StringUtils.java diff --git a/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java b/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java index 49ee64059..996702bf5 100644 --- a/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java +++ b/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java @@ -21,8 +21,8 @@ import java.util.Map; import java.util.Optional; -import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; +import org.eclipse.lyo.core.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public OslcOAuthClient( oauthRealmName = "Jazz"; // Change if a different name was detected - if (!StringUtils.isEmpty(realm)) { + if (!StringUtils.isNullOrEmpty(realm)) { oauthRealmName = realm; } diff --git a/core/lyo-core-settings/pom.xml b/core/lyo-core-settings/pom.xml index ad9dc12a3..af63fcb9d 100644 --- a/core/lyo-core-settings/pom.xml +++ b/core/lyo-core-settings/pom.xml @@ -82,10 +82,6 @@ jersey-common test - - com.google.guava - guava - diff --git a/core/lyo-core-settings/src/main/java/org/eclipse/lyo/core/util/StringUtils.java b/core/lyo-core-settings/src/main/java/org/eclipse/lyo/core/util/StringUtils.java new file mode 100644 index 000000000..5fc9196bc --- /dev/null +++ b/core/lyo-core-settings/src/main/java/org/eclipse/lyo/core/util/StringUtils.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0 + * which is available at http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.lyo.core.util; + +import java.text.Normalizer; +import java.util.regex.Pattern; + +/** + * @since 7.0.0 + */ +public class StringUtils { + /** + * Pattern to match control characters in the Unicode Cc category that are not CR, LF, or TAB + */ + private static final Pattern CONTROL_CHAR_PATTERN = Pattern.compile("^\\p{Cc}&&[^\\r\\n\\t]+$"); + + /** + * Trim and strip control chars (in the Unicode Cc category that are not CR, LF, or TAB) + */ + public static String cleanWithoutNormalization(String str) { + if (str == null) return null; + + return CONTROL_CHAR_PATTERN.matcher(str).replaceAll("").trim(); + } + + /** + * Trim and strip control chars (in the Unicode Cc category that are not CR, LF, or TAB); + * returns an empty string if a null is encountered + */ + public static String cleanWithoutNormalizationNonNull(String str) { + if (str == null) return ""; + + return CONTROL_CHAR_PATTERN.matcher(str).replaceAll("").trim(); + } + + /** + * Trim, strip control chars (in the Unicode Cc category that are not CR, LF, or TAB), and + * normalize the string to NFC as per W3C recommendations + */ + public static String clean(String str) { + if (str == null) return null; + + return Normalizer.normalize(CONTROL_CHAR_PATTERN.matcher(str).replaceAll("").trim(), + Normalizer.Form.NFC); + } + + /** + * Trim, strip control chars (in the Unicode Cc category that are not CR, LF, or TAB), and + * normalize the string to NFC as per W3C recommendations; + * returns an empty string if a null is encountered + */ + public static String cleanNonNull(String str) { + if (str == null) return ""; + + return Normalizer.normalize(CONTROL_CHAR_PATTERN.matcher(str).replaceAll("").trim(), + Normalizer.Form.NFC); + } + + public static boolean isNullOrWhitespace(String str) { + return str == null || str.isBlank(); + } + + public static boolean isNullOrEmpty(String str) { + return str == null || str.isEmpty(); + } +} diff --git a/core/lyo-core-settings/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java b/core/lyo-core-settings/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java index 81e4784e8..a188d8282 100644 --- a/core/lyo-core-settings/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java +++ b/core/lyo-core-settings/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java @@ -36,7 +36,6 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import com.google.common.base.Strings; import org.apache.jena.datatypes.DatatypeFormatException; import org.apache.jena.datatypes.RDFDatatype; import org.apache.jena.datatypes.TypeMapper; @@ -44,6 +43,7 @@ import org.apache.jena.datatypes.xsd.XSDDateTime; import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.rdf.model.Property; +import org.eclipse.lyo.core.util.StringUtils; import org.eclipse.lyo.oslc4j.core.model.ResourceShape; import org.eclipse.lyo.oslc4j.core.model.XMLLiteral; import org.slf4j.Logger; @@ -550,7 +550,7 @@ private static Boolean parseBooleanPropertyOrDefault(final String key, final boolean defaultValue) { Boolean value; final String property = System.getProperty(key); - if (Strings.isNullOrEmpty(property)) { + if (StringUtils.isNullOrEmpty(property)) { value = defaultValue; } else { try { diff --git a/core/oslc4j-jena-provider/pom.xml b/core/oslc4j-jena-provider/pom.xml index b293b3957..96149cde8 100644 --- a/core/oslc4j-jena-provider/pom.xml +++ b/core/oslc4j-jena-provider/pom.xml @@ -131,11 +131,6 @@ ${v.jersey} test - - com.google.guava - guava - test - diff --git a/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelperTest.java b/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelperTest.java index b24745641..434753068 100644 --- a/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelperTest.java +++ b/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelperTest.java @@ -17,9 +17,9 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.URI; +import java.util.List; import javax.xml.datatype.DatatypeConfigurationException; -import com.google.common.collect.ImmutableList; import org.apache.jena.datatypes.DatatypeFormatException; import org.apache.jena.rdf.model.Model; import org.eclipse.lyo.oslc4j.core.exception.LyoModelException; @@ -53,7 +53,7 @@ public void testSeqMarshalling() final Model expectedModel = RDFHelper.loadResourceModel("container-element.ttl"); final Container container = new Container(); container.setAbout(URI.create("urn:containerA")); - final ImmutableList children = ImmutableList.of(element("A"), element("B")); + final List children = List.of(element("A"), element("B")); container.setChildrenL(children); container.setChildrenB(children); diff --git a/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/JsonLdTest.java b/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/JsonLdTest.java index c900ba152..22d53174e 100644 --- a/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/JsonLdTest.java +++ b/core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/JsonLdTest.java @@ -18,10 +18,11 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; +import java.util.List; -import com.google.common.collect.ImmutableList; import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; import org.eclipse.lyo.oslc4j.core.model.ServiceProvider; import org.eclipse.lyo.oslc4j.provider.jena.OslcJsonLdArrayProvider; @@ -72,7 +73,7 @@ public void testWrite() throws Exception { .getAnnotations(), OslcMediaType.APPLICATION_JSON_LD_TYPE, new MultivaluedHashMap<>(), outputStream); - final String jsonLD = outputStream.toString("UTF-8"); + final String jsonLD = outputStream.toString(StandardCharsets.UTF_8); assertTrue("Provider was not read", jsonLD.contains("Hello world")); @@ -94,7 +95,7 @@ public void testWriteArray() throws Exception { new MultivaluedHashMap<>(), outputStream); - final String jsonLD = outputStream.toString("UTF-8"); + final String jsonLD = outputStream.toString(StandardCharsets.UTF_8); assertTrue("Provider was not read", jsonLD.contains("Hello world")); } @@ -107,7 +108,7 @@ public void testWriteCollection() throws Exception { ServiceProvider sp = new ServiceProvider(); sp.setDescription("Hello world"); - final Collection objects = ImmutableList.of(sp); + final Collection objects = List.of(sp); provider.writeTo( new ArrayList<>(objects), objects.getClass(), @@ -117,7 +118,7 @@ public void testWriteCollection() throws Exception { new MultivaluedHashMap<>(), outputStream); - final String jsonLD = outputStream.toString("UTF-8"); + final String jsonLD = outputStream.toString(StandardCharsets.UTF_8); assertTrue("Provider was not read", jsonLD.contains("Hello world")); } diff --git a/core/shacl/pom.xml b/core/shacl/pom.xml index 3b7659914..0ee92f0f6 100644 --- a/core/shacl/pom.xml +++ b/core/shacl/pom.xml @@ -27,10 +27,6 @@ oslc4j-jena-provider - - com.google.guava - guava - diff --git a/core/shacl/src/main/java/org/eclipse/lyo/shacl/Shape.java b/core/shacl/src/main/java/org/eclipse/lyo/shacl/Shape.java index 7b8b09281..3237db4b8 100644 --- a/core/shacl/src/main/java/org/eclipse/lyo/shacl/Shape.java +++ b/core/shacl/src/main/java/org/eclipse/lyo/shacl/Shape.java @@ -14,7 +14,6 @@ package org.eclipse.lyo.shacl; -import com.google.common.collect.ImmutableList; import java.net.URI; import java.util.HashMap; import java.util.List; @@ -26,7 +25,6 @@ /** * @author Yash Khatri - * @version $version-stub$ * @since 2.3.0 */ @OslcNamespace(ShaclConstants.SHACL_CORE_NAMESPACE) @@ -133,8 +131,7 @@ public void setTargetObjectsOf(final URI targetObjectsOf) { @OslcTitle("Properties") @OslcValueType(ValueType.LocalResource) public List getShaclProperties() { - return ImmutableList.copyOf( - properties.values().toArray(new Property[properties.size()])); + return List.of(properties.values().toArray(new Property[0])); } public void setShaclProperties(final List properties) { diff --git a/pom.xml b/pom.xml index 0480ac3d6..87fd8a24c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,8 +28,6 @@ 2.18.2 4.5.14 2.0.16 - - 33.3.1-jre @@ -393,11 +391,6 @@ commons-codec 1.17.2 - - com.google.guava - guava - ${v.guava} - jakarta.activation jakarta.activation-api @@ -476,7 +469,6 @@ https://jakarta.ee/specifications/platform/9/apidocs/ https://jena.apache.org/documentation/javadoc/jena/ https://jena.apache.org/documentation/javadoc/arq/ - https://guava.dev/releases/${v.guava}/api/docs/ diff --git a/server/oslc-ui-model/pom.xml b/server/oslc-ui-model/pom.xml index 1205915c4..582996974 100644 --- a/server/oslc-ui-model/pom.xml +++ b/server/oslc-ui-model/pom.xml @@ -25,10 +25,6 @@ com.fasterxml.jackson.core jackson-core - - org.apache.commons - commons-lang3 - diff --git a/server/oslc-ui-model/src/main/java/org/eclipse/lyo/server/ui/model/PreviewFactory.java b/server/oslc-ui-model/src/main/java/org/eclipse/lyo/server/ui/model/PreviewFactory.java index fc5dfe803..477e200b7 100644 --- a/server/oslc-ui-model/src/main/java/org/eclipse/lyo/server/ui/model/PreviewFactory.java +++ b/server/oslc-ui-model/src/main/java/org/eclipse/lyo/server/ui/model/PreviewFactory.java @@ -15,7 +15,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.StringUtils; +import org.eclipse.lyo.core.util.StringUtils; import org.eclipse.lyo.oslc4j.core.annotation.OslcName; import org.eclipse.lyo.oslc4j.core.annotation.OslcOccurs; import org.eclipse.lyo.oslc4j.core.annotation.OslcPropertyDefinition; @@ -143,7 +143,7 @@ private static org.eclipse.lyo.server.ui.model.Link constructLink(Link link) { if (null == link) { return null; } - if (StringUtils.isBlank(link.getLabel())) { + if (StringUtils.isNullOrWhitespace(link.getLabel())) { return constructLink(link.getValue().toString(), link.getValue().toString()); } else { return constructLink(link.getValue().toString(), link.getLabel()); diff --git a/store/store-core/pom.xml b/store/store-core/pom.xml index 0ed47365f..26b9ad191 100644 --- a/store/store-core/pom.xml +++ b/store/store-core/pom.xml @@ -101,10 +101,6 @@ org.slf4j slf4j-api - - com.google.guava - guava - diff --git a/store/store-core/src/main/java/org/eclipse/lyo/store/internals/SparqlStoreImpl.java b/store/store-core/src/main/java/org/eclipse/lyo/store/internals/SparqlStoreImpl.java index 3c3000360..c191f4af1 100644 --- a/store/store-core/src/main/java/org/eclipse/lyo/store/internals/SparqlStoreImpl.java +++ b/store/store-core/src/main/java/org/eclipse/lyo/store/internals/SparqlStoreImpl.java @@ -33,7 +33,6 @@ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause */ -import org.apache.commons.lang3.StringUtils; import org.apache.jena.arq.querybuilder.DescribeBuilder; import org.apache.jena.arq.querybuilder.ExprFactory; import org.apache.jena.arq.querybuilder.Order; @@ -67,6 +66,7 @@ import org.eclipse.lyo.core.query.UriRefValue; import org.eclipse.lyo.core.query.Value; import org.eclipse.lyo.core.query.WhereClause; +import org.eclipse.lyo.core.util.StringUtils; import org.eclipse.lyo.oslc4j.core.OSLC4JUtils; import org.eclipse.lyo.oslc4j.core.annotation.OslcName; import org.eclipse.lyo.oslc4j.core.annotation.OslcNamespace; @@ -295,8 +295,8 @@ public List getResources(final URI namedGraph, final Cl String _prefixes = prefixes; String _where = where; - _prefixes = (StringUtils.isEmpty(_prefixes) ? "" : _prefixes + ",") + oslcQueryPrefixes(clazz); - _where = (StringUtils.isEmpty(_where) ? "" : _where + " and ") + oslcQueryWhere(clazz); + _prefixes = (StringUtils.isNullOrEmpty(_prefixes) ? "" : _prefixes + ",") + oslcQueryPrefixes(clazz); + _where = (StringUtils.isNullOrEmpty(_where) ? "" : _where + " and ") + oslcQueryWhere(clazz); Model model = getResources(namedGraph, _prefixes, _where, searchTerms, limit, offset, additionalDistinctVars, additionalQueryFilter); return getResourcesFromModel(model, clazz); @@ -595,7 +595,7 @@ private SelectBuilder constructSparqlWhere(final String prefixes, final String w //Setup prefixes Map prefixesMap = new HashMap<>(); try { - if (!StringUtils.isEmpty(prefixes)) { + if (!StringUtils.isNullOrEmpty(prefixes)) { prefixesMap = QueryUtils.parsePrefixes(prefixes); for (Entry prefix : prefixesMap.entrySet()) { distinctResourcesQuery.addPrefix(prefix.getKey(), prefix.getValue()); @@ -622,7 +622,7 @@ private SelectBuilder constructSparqlWhere(final String prefixes, final String w //Setup where WhereClause whereClause = null; try { - if (!StringUtils.isEmpty(where)) { + if (!StringUtils.isNullOrEmpty(where)) { whereClause = QueryUtils.parseWhere(where, prefixesMap); List parseChildren = whereClause.children(); for (SimpleTerm simpleTerm : parseChildren) { @@ -672,7 +672,7 @@ private SelectBuilder constructSparqlWhere(final String prefixes, final String w //Setup searchTerms //Add a sparql filter "FILTER regex(?o, "", "i")" to the distinctResourcesQuery - if (!StringUtils.isEmpty(searchTerms)) { + if (!StringUtils.isNullOrEmpty(searchTerms)) { ExprFactory factory = new ExprFactory(); E_Regex regex = factory.regex(factory.str("?o"), searchTerms, "i"); distinctResourcesQuery.addFilter(regex); diff --git a/store/store-core/src/test/java/org/eclipse/lyo/store/SparqlStoreImplTest.java b/store/store-core/src/test/java/org/eclipse/lyo/store/SparqlStoreImplTest.java index a5bad6957..653d3d1e3 100644 --- a/store/store-core/src/test/java/org/eclipse/lyo/store/SparqlStoreImplTest.java +++ b/store/store-core/src/test/java/org/eclipse/lyo/store/SparqlStoreImplTest.java @@ -5,6 +5,8 @@ import java.lang.reflect.InvocationTargetException; import java.net.URI; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -34,8 +36,6 @@ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause */ -import com.google.common.base.Stopwatch; - public class SparqlStoreImplTest extends StoreTestBase { private Store manager; @@ -68,7 +68,7 @@ public void storeBasicOps() { @Test public void testInsertionPerf() { final List providers = genProviders(); - final Stopwatch stopwatch = Stopwatch.createStarted(); + var start = Instant.now(); for (int i = 0; i < 10; i++) { final URI testNg = URI.create("urn:test:" + i); try { @@ -77,7 +77,7 @@ public void testInsertionPerf() { fail("Store failed", e); } } - System.out.printf("10 named graphs persisted (resources) in %s ms", stopwatch.stop().elapsed().toMillis()); + System.out.printf("10 named graphs persisted (resources) in %s ms", Duration.between(start, Instant.now()).toMillis()); } @Test @@ -85,12 +85,12 @@ public void testInsertionPerfRaw() throws InvocationTargetException, DatatypeCon OslcCoreApplicationException, IllegalAccessException { final List providers = genProviders(); final Model jenaModel = JenaModelHelper.createJenaModel(providers.toArray()); - final Stopwatch stopwatch = Stopwatch.createStarted(); + var start = Instant.now(); for (int i = 0; i < 10; i++) { final URI testNg = URI.create("urn:test:" + i); manager.insertJenaModel(testNg, jenaModel); } - System.out.printf("10 named graphs persisted (raw Model) in %s ms", stopwatch.stop().elapsed().toMillis()); + System.out.printf("10 named graphs persisted (raw Model) in %s ms", Duration.between(start, Instant.now()).toMillis()); } private List genProviders() { diff --git a/store/store-core/src/test/java/org/eclipse/lyo/store/StoreTestBase.java b/store/store-core/src/test/java/org/eclipse/lyo/store/StoreTestBase.java index 3af794175..be0477989 100644 --- a/store/store-core/src/test/java/org/eclipse/lyo/store/StoreTestBase.java +++ b/store/store-core/src/test/java/org/eclipse/lyo/store/StoreTestBase.java @@ -38,9 +38,6 @@ * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause */ -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - /** * StoreTestBase allows same tests to be run on differently set up triplestores @@ -143,7 +140,7 @@ public void testStoreSuccessiveAddCombines() ServiceProviderCatalog.class); Assertions.assertThat(catalogs).hasSize(2); - Assertions.assertThat(Lists.newArrayList(catalogs) + Assertions.assertThat(catalogs .stream() .map((serviceProviderCatalog) -> serviceProviderCatalog.getAbout().toASCIIString())) .contains(resource.getAbout().toASCIIString(), @@ -190,7 +187,7 @@ public void testSingleResourceRetrieved() resource2.getAbout(), ServiceProviderCatalog.class); Assertions.assertThat(resourceUnderKey).isNotNull(); - Assertions.assertThat(resourceUnderKey.getAbout().equals(resource2.getAbout())); + Assertions.assertThat(resourceUnderKey.getAbout()).isEqualTo(resource2.getAbout()); } @Test @@ -228,7 +225,7 @@ public void testBlankNodeRetrieval() final Store manager = buildStore(); final URI namedGraphUri = new URI("urn:test"); - manager.putResources(namedGraphUri, ImmutableList.of(r1WithBlankResource)); + manager.putResources(namedGraphUri, List.of(r1WithBlankResource)); final WithBlankResource resource = manager.getResource( namedGraphUri, @@ -259,7 +256,7 @@ public void testBlankNodeRetrievalDouble() final Store manager = buildStore(); final URI namedGraphUri = new URI("urn:test"); - manager.putResources(namedGraphUri, ImmutableList.of(aWithTwoDepthBlankResource)); + manager.putResources(namedGraphUri, List.of(aWithTwoDepthBlankResource)); final WithTwoDepthBlankResource resource = manager.getResource(namedGraphUri, blankResourceURI, diff --git a/trs/client/trs-client/pom.xml b/trs/client/trs-client/pom.xml index c4bbe0a90..82406b8ae 100644 --- a/trs/client/trs-client/pom.xml +++ b/trs/client/trs-client/pom.xml @@ -114,10 +114,6 @@ oslc-client ${v.lyo} - - com.google.guava - guava - org.eclipse.rdf4j rdf4j-repository-sparql diff --git a/trs/server/pom.xml b/trs/server/pom.xml index 7ac0c72e9..f329832c9 100644 --- a/trs/server/pom.xml +++ b/trs/server/pom.xml @@ -186,9 +186,5 @@ ${v.slf4j} test - - com.google.guava - guava - diff --git a/trs/server/src/main/java/org/eclipse/lyo/oslc4j/trs/server/service/TrackedResourceSetService.java b/trs/server/src/main/java/org/eclipse/lyo/oslc4j/trs/server/service/TrackedResourceSetService.java index c50de8801..498bc35a3 100644 --- a/trs/server/src/main/java/org/eclipse/lyo/oslc4j/trs/server/service/TrackedResourceSetService.java +++ b/trs/server/src/main/java/org/eclipse/lyo/oslc4j/trs/server/service/TrackedResourceSetService.java @@ -19,13 +19,13 @@ import jakarta.inject.Inject; -import com.google.common.base.Strings; import org.eclipse.lyo.core.trs.Base; import org.eclipse.lyo.core.trs.ChangeLog; import org.eclipse.lyo.core.trs.Page; import org.eclipse.lyo.core.trs.TRSConstants; import org.eclipse.lyo.core.trs.TrackedResourceSet; import org.eclipse.lyo.oslc4j.core.OSLC4JUtils; +import org.eclipse.lyo.core.util.StringUtils; import org.eclipse.lyo.oslc4j.core.annotation.OslcService; import org.eclipse.lyo.oslc4j.core.model.Error; import org.eclipse.lyo.oslc4j.core.model.OslcMediaType; @@ -197,7 +197,7 @@ public Response getChangeLogPage(@PathParam("page") int page) { } private UriBuilder uriBuilder() { - if(Strings.isNullOrEmpty(base)) { + if(StringUtils.isNullOrEmpty(base)) { return UriBuilder.fromUri(OSLC4JUtils.getServletURI()).path(RESOURCE_PATH); } else { return UriBuilder.fromUri(base); diff --git a/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/InmemPagedTrsTest.java b/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/InmemPagedTrsTest.java index cce827067..ca34c2004 100644 --- a/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/InmemPagedTrsTest.java +++ b/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/InmemPagedTrsTest.java @@ -1,12 +1,12 @@ package org.eclipse.lyo.oslc4j.trs.server; -import com.google.common.collect.ImmutableSet; import java.math.BigInteger; import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import org.eclipse.lyo.core.trs.Base; import org.eclipse.lyo.core.trs.ChangeEvent; @@ -30,7 +30,7 @@ public void testEmptyLog() { @Test public void testEmptyLogWithBase() { - final InmemPagedTrs inmemPagedTrs = buildPagedTrs(ImmutableSet.of(TRSTestUtil.dummyUri(), TRSTestUtil + final InmemPagedTrs inmemPagedTrs = buildPagedTrs(Set.of(TRSTestUtil.dummyUri(), TRSTestUtil .dummyUri())); final Base base = inmemPagedTrs.getBaseResource(1); @@ -40,7 +40,7 @@ public void testEmptyLogWithBase() { @Test public void testEmptyLogWithPagedBase() { final InmemPagedTrs inmemPagedTrs = buildPagedTrs( - ImmutableSet.of(TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil + Set.of(TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil .dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri())); @@ -55,7 +55,7 @@ public void testEmptyLogWithPagedBase() { @Test public void testLogWithEmptyBase() { - final InmemPagedTrs pagedTrs = buildPagedTrs(ImmutableSet.of()); + final InmemPagedTrs pagedTrs = buildPagedTrs(Set.of()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); @@ -68,7 +68,7 @@ public void testLogWithEmptyBase() { @Test public void testPagedLogWithEmptyBase() { - final InmemPagedTrs pagedTrs = buildPagedTrs(ImmutableSet.of()); + final InmemPagedTrs pagedTrs = buildPagedTrs(Set.of()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); @@ -87,7 +87,7 @@ public void testPagedLogWithEmptyBase() { @Test public void testLogOrderUnique() { - final InmemPagedTrs pagedTrs = buildPagedTrs(ImmutableSet.of()); + final InmemPagedTrs pagedTrs = buildPagedTrs(Set.of()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); @@ -112,7 +112,7 @@ public void testLogOrderUnique() { @Test public void testLogOrderMonotonic() { - final InmemPagedTrs pagedTrs = buildPagedTrs(ImmutableSet.of()); + final InmemPagedTrs pagedTrs = buildPagedTrs(Set.of()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); @@ -137,7 +137,7 @@ public void testLogOrderMonotonic() { @Test public void testLogPagesLinked() { - final InmemPagedTrs pagedTrs = buildPagedTrs(ImmutableSet.of()); + final InmemPagedTrs pagedTrs = buildPagedTrs(Set.of()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); @@ -153,7 +153,7 @@ public void testLogPagesLinked() { @Test public void testLogPagesLinkedFirstNil() { - final InmemPagedTrs pagedTrs = buildPagedTrs(ImmutableSet.of()); + final InmemPagedTrs pagedTrs = buildPagedTrs(Set.of()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); pagedTrs.onHistoryData(TRSTestUtil.createHistory()); diff --git a/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/service/TRSServiceResource.java b/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/service/TRSServiceResource.java index 40758dfe2..fbcbeec38 100644 --- a/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/service/TRSServiceResource.java +++ b/trs/server/src/test/java/org/eclipse/lyo/oslc4j/trs/server/service/TRSServiceResource.java @@ -1,5 +1,7 @@ package org.eclipse.lyo.oslc4j.trs.server.service; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.UriBuilder; import org.eclipse.lyo.oslc4j.core.OSLC4JUtils; import org.eclipse.lyo.oslc4j.trs.server.InmemPagedTrs; import org.eclipse.lyo.oslc4j.trs.server.PagedTrs; @@ -7,10 +9,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.ImmutableList; - -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.UriBuilder; +import java.util.List; @Path("/trs") public class TRSServiceResource extends TrackedResourceSetService { @@ -24,8 +23,9 @@ public TRSServiceResource() { protected PagedTrs getPagedTrs() { log.trace("Change History objects requested"); final InmemPagedTrs inmemPagedTrs = new InmemPagedTrs(5, 5, - UriBuilder.fromUri(OSLC4JUtils.getServletURI()).path("trs").build(), ImmutableList.of(TRSTestUtil.dummyUri(),TRSTestUtil.dummyUri(),TRSTestUtil.dummyUri(),TRSTestUtil.dummyUri(),TRSTestUtil.dummyUri())); -// inmemPagedTrs.onHistoryData(TRSTestUtil.createHistory()); + UriBuilder.fromUri(OSLC4JUtils.getServletURI()).path("trs").build(), + List.of(TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri(), + TRSTestUtil.dummyUri(), TRSTestUtil.dummyUri())); return inmemPagedTrs; } diff --git a/validation/pom.xml b/validation/pom.xml index 2a9474be3..56b37795e 100644 --- a/validation/pom.xml +++ b/validation/pom.xml @@ -50,11 +50,6 @@ - - com.google.guava - guava - - org.eclipse.lyo.oslc4j.core