You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2023/06/17 12:33:56 UTC
[incubator-baremaps] branch server-refactoring updated (1cc5fa85 -> 3217fd1e)
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a change to branch server-refactoring
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
omit 1cc5fa85 Adapt geocoder and iploc command
new 3217fd1e Adapt geocoder and iploc command
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (1cc5fa85)
\
N -- N -- N refs/heads/server-refactoring (3217fd1e)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/main/java/org/apache/baremaps/server/ChangeResource.java | 3 ---
1 file changed, 3 deletions(-)
[incubator-baremaps] 01/01: Adapt geocoder and iploc command
Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch server-refactoring
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit 3217fd1ea84fe7366541bb281c330c26e923c070
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Sat Jun 17 14:29:35 2023 +0200
Adapt geocoder and iploc command
---
.../java/org/apache/baremaps/cli/geocoder/Serve.java | 12 +++++++++---
.../main/java/org/apache/baremaps/cli/iploc/Serve.java | 10 +++++++---
.../src/main/java/org/apache/baremaps/cli/map/Dev.java | 5 ++---
.../org/apache/baremaps/server/ChangeResource.java | 3 ++-
.../org/apache/baremaps/server/GeocoderResource.java | 16 ----------------
.../java/org/apache/baremaps/server/IpLocResource.java | 18 ------------------
6 files changed, 20 insertions(+), 44 deletions(-)
diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/geocoder/Serve.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/geocoder/Serve.java
index 7a3282c1..1d9abe0f 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/geocoder/Serve.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/geocoder/Serve.java
@@ -18,6 +18,7 @@ import io.servicetalk.http.netty.HttpServers;
import io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder;
import java.nio.file.Path;
import java.util.concurrent.Callable;
+import org.apache.baremaps.server.ClassPathResource;
import org.apache.baremaps.server.CorsFilter;
import org.apache.baremaps.server.GeocoderResource;
import org.apache.lucene.search.SearcherFactory;
@@ -51,11 +52,16 @@ public class Serve implements Callable<Integer> {
try (
var directory = MMapDirectory.open(indexDirectory);
var searcherManager = new SearcherManager(directory, new SearcherFactory())) {
- // Configure the application
- var application = new ResourceConfig().register(CorsFilter.class)
- .register(GeocoderResource.class).register(new AbstractBinder() {
+
+ var application = new ResourceConfig()
+ .register(CorsFilter.class)
+ .register(GeocoderResource.class)
+ .register(ClassPathResource.class)
+ .register(new AbstractBinder() {
@Override
protected void configure() {
+ bind("geocoder").to(String.class).named("directory");
+ bind("index.html").to(String.class).named("index");
bind(searcherManager).to(SearcherManager.class).named("searcherManager");
}
});
diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/iploc/Serve.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/iploc/Serve.java
index 371c395b..86379fea 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/iploc/Serve.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/iploc/Serve.java
@@ -22,6 +22,7 @@ import java.nio.file.Path;
import java.util.concurrent.Callable;
import javax.sql.DataSource;
import org.apache.baremaps.iploc.IpLocRepository;
+import org.apache.baremaps.server.ClassPathResource;
import org.apache.baremaps.server.CorsFilter;
import org.apache.baremaps.server.IpLocResource;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
@@ -56,16 +57,19 @@ public class Serve implements Callable<Integer> {
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
- // config.setReadOnly(true);
DataSource dataSource = new HikariDataSource(config);
IpLocRepository ipLocRepository = new IpLocRepository(dataSource);
- // Configure the application
- var application = new ResourceConfig().register(CorsFilter.class).register(IpLocResource.class)
+ var application = new ResourceConfig()
+ .register(CorsFilter.class)
+ .register(IpLocResource.class)
+ .register(ClassPathResource.class)
.register(new AbstractBinder() {
@Override
protected void configure() {
+ bind("iploc").to(String.class).named("directory");
+ bind("index.html").to(String.class).named("index");
bind(ipLocRepository).to(IpLocRepository.class).named("iplocRepository");
}
});
diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
index f11b70a8..619b0e44 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
@@ -116,11 +116,10 @@ public class Dev implements Callable<Integer> {
.register(new AbstractBinder() {
@Override
protected void configure() {
- bind(tilesetPath).to(Path.class).named("tileset");
- bind(stylePath).to(Path.class).named("style");
- bind("assets").to(String.class).named("directory");
bind("assets").to(String.class).named("directory");
bind("viewer.html").to(String.class).named("index");
+ bind(tilesetPath).to(Path.class).named("tileset");
+ bind(stylePath).to(Path.class).named("style");
bind(tileStoreSupplier).to(tileStoreType);
bind(styleSupplier).to(styleSupplierType);
bind(tileJSONSupplier).to(tileJSONSupplierType);
diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/ChangeResource.java b/baremaps-server/src/main/java/org/apache/baremaps/server/ChangeResource.java
index 183ff19c..633647dd 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/ChangeResource.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/ChangeResource.java
@@ -17,6 +17,7 @@ import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
import java.nio.file.*;
import javax.inject.Inject;
import javax.inject.Named;
@@ -104,7 +105,7 @@ public class ChangeResource {
}
key.reset();
}
- } catch (Exception e) {
+ } catch (InterruptedException | IOException e) {
logger.error("Error while watching for changes", e);
}
}
diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/GeocoderResource.java b/baremaps-server/src/main/java/org/apache/baremaps/server/GeocoderResource.java
index b28ad224..4043db85 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/GeocoderResource.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/GeocoderResource.java
@@ -17,7 +17,6 @@ import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -94,19 +93,4 @@ public class GeocoderResource {
throw new RuntimeException(e);
}
}
-
- @GET
- @javax.ws.rs.Path("/{path:.*}")
- public Response get(@PathParam("path") String path) {
- if (path.equals("") || path.endsWith("/")) {
- path += "index.html";
- }
- path = String.format("geocoder/%s", path);
- try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(path)) {
- var bytes = inputStream.readAllBytes();
- return Response.ok().entity(bytes).build();
- } catch (NullPointerException | IOException e) {
- return Response.status(404).build();
- }
- }
}
diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/IpLocResource.java b/baremaps-server/src/main/java/org/apache/baremaps/server/IpLocResource.java
index c06e7c2f..79b7b0cf 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/IpLocResource.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/IpLocResource.java
@@ -18,15 +18,12 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import com.google.common.net.InetAddresses;
import io.servicetalk.http.api.StreamingHttpRequest;
import io.servicetalk.transport.api.ConnectionContext;
-import java.io.IOException;
-import java.io.InputStream;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.GET;
-import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.*;
import org.apache.baremaps.iploc.IpLocObject;
@@ -99,21 +96,6 @@ public class IpLocResource {
}
}
- @GET
- @javax.ws.rs.Path("/{path:.*}")
- public Response get(@PathParam("path") String path) {
- if (path.equals("") || path.endsWith("/")) {
- path += "index.html";
- }
- path = String.format("iploc/%s", path);
- try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(path)) {
- var bytes = inputStream.readAllBytes();
- return Response.ok().entity(bytes).build();
- } catch (NullPointerException | IOException e) {
- return Response.status(404).build();
- }
- }
-
public record InetnumLocationDto(
String address,
String inetStart,