Repository: komoot/photon
Pull request #645 (2022-02-27 14:19:32)

Update dependencies
Update dependencies where possible. (Still stuck with log4j and jts.)

Also removes the use of nv-i18n. It was only used for country codes. given that they are already sanitized by Nominatim, there is no need to go through a separate library for them.


Patch:
diff --git a/pom.xml b/pom.xml
index 9700bb9..75897a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,28 +64,17 @@
         <dependency>
             <groupId>com.beust</groupId>
             <artifactId>jcommander</artifactId>
-            <version>1.78</version>
+            <version>1.82</version>
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
-            <version>3.10</version>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-jaxrs</artifactId>
-            <version>1.9.13</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.neovisionaries</groupId>
-            <artifactId>nv-i18n</artifactId>
-            <version>1.27</version>
+            <version>3.12.0</version>
         </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
-            <version>1.18.6</version>
+            <version>1.18.22</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -96,7 +85,7 @@
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-dbcp2</artifactId>
-            <version>2.7.0</version>
+            <version>2.9.0</version>
             <exclusions>
                 <exclusion>
                     <groupId>commons-logging</groupId>
@@ -112,7 +101,7 @@
         <dependency>
             <groupId>com.sparkjava</groupId>
             <artifactId>spark-core</artifactId>
-            <version>2.8.0</version>
+            <version>2.9.3</version>
         </dependency>
         <dependency>
             <groupId>net.postgis</groupId>
@@ -152,17 +141,12 @@
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
-            <version>29.0-jre</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.7</version>
+            <version>31.0.1-jre</version>
         </dependency>
         <dependency>
             <groupId>org.json</groupId>
             <artifactId>json</artifactId>
-            <version>20190722</version>
+            <version>20211205</version>
         </dependency>
     </dependencies>
 
diff --git a/src/main/java/de/komoot/photon/PhotonDoc.java b/src/main/java/de/komoot/photon/PhotonDoc.java
index d96b3a5..7e27363 100644
--- a/src/main/java/de/komoot/photon/PhotonDoc.java
+++ b/src/main/java/de/komoot/photon/PhotonDoc.java
@@ -1,7 +1,6 @@
 package de.komoot.photon;
 
 import com.google.common.collect.ImmutableMap;
-import com.neovisionaries.i18n.CountryCode;
 import com.vividsolutions.jts.geom.Envelope;
 import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.Point;
@@ -31,7 +30,7 @@ public class PhotonDoc {
     private Envelope bbox = null;
     private long parentPlaceId = 0; // 0 if unset
     private double importance = 0;
-    private CountryCode countryCode = null;
+    private String countryCode = null;
     private long linkedPlaceId = 0; // 0 if unset
     private int rankAddress = 30;
 
@@ -92,7 +91,7 @@ public class PhotonDoc {
     }
 
     public PhotonDoc countryCode(String countryCode) {
-        this.countryCode = CountryCode.getByCode(countryCode, false);
+        this.countryCode = countryCode.toUpperCase();
         return this;
     }
 
diff --git a/src/main/java/de/komoot/photon/Utils.java b/src/main/java/de/komoot/photon/Utils.java
index 7625492..841711d 100644
--- a/src/main/java/de/komoot/photon/Utils.java
+++ b/src/main/java/de/komoot/photon/Utils.java
@@ -3,7 +3,6 @@ package de.komoot.photon;
 import com.google.common.base.Joiner;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.SetMultimap;
-import com.neovisionaries.i18n.CountryCode;
 import com.vividsolutions.jts.geom.Envelope;
 import de.komoot.photon.nominatim.model.AddressType;
 import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -57,9 +56,9 @@ public class Utils {
         for (Map.Entry<AddressType, Map<String, String>> entry : doc.getAddressParts().entrySet()) {
             writeIntlNames(builder, entry.getValue(), entry.getKey().getName(), languages);
         }
-        CountryCode countryCode = doc.getCountryCode();
+        String countryCode = doc.getCountryCode();
         if (countryCode != null)
-            builder.field(Constants.COUNTRYCODE, countryCode.getAlpha2());
+            builder.field(Constants.COUNTRYCODE, countryCode);
         writeContext(builder, doc.getContext(), languages);
         writeExtraTags(builder, doc.getExtratags(), extraTags);
         writeExtent(builder, doc.getBbox());


Test patch:
diff --git a/src/test/java/de/komoot/photon/PhotonDocTest.java b/src/test/java/de/komoot/photon/PhotonDocTest.java
index 28c301f..a3d301f 100644
--- a/src/test/java/de/komoot/photon/PhotonDocTest.java
+++ b/src/test/java/de/komoot/photon/PhotonDocTest.java
@@ -38,7 +38,7 @@ public class PhotonDocTest {
         PhotonDoc doc = new PhotonDoc(1, "W", 2, "highway", "residential").countryCode("de");
 
         assertNotNull(doc.getCountryCode());
-        assertEquals("DE", doc.getCountryCode().getAlpha2());
+        assertEquals("DE", doc.getCountryCode());
     }
 
     private PhotonDoc simplePhotonDoc() {