diff --git a/pom.xml b/pom.xml
index caaf993..8b480ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
org.apache.uima
uimaj-core
- 3.5.0
+ 2.11.0
org.apache.poi
diff --git a/src/main/java/com/github/donvip/glamscrap/GlamScrap.java b/src/main/java/com/github/donvip/glamscrap/GlamScrap.java
index fec3a8f..b78f7da 100644
--- a/src/main/java/com/github/donvip/glamscrap/GlamScrap.java
+++ b/src/main/java/com/github/donvip/glamscrap/GlamScrap.java
@@ -19,6 +19,11 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpRequest.BodyPublishers;
+import java.net.http.HttpResponse;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
@@ -48,6 +53,7 @@
import com.github.donvip.glamscrap.domain.Notice;
import com.github.donvip.glamscrap.institutions.paris.ParisArchivesGlamScrap;
import com.github.donvip.glamscrap.institutions.toulouse.ToulouseArchivesGlamScrap;
+import com.github.donvip.glamscrap.institutions.toulouse.ToulousePhotothequeGlamScrap;
import com.github.donvip.glamscrap.uploadtools.Pattypan;
import com.github.donvip.glamscrap.uploadtools.UploadTool;
import com.github.donvip.glamscrap.wikidata.Author;
@@ -124,7 +130,7 @@ public final void close() throws IOException {
}
public static void usage() {
- LOGGER.info("Usage: GlamScrap [paris|toulouse] scrap [[,]*] | check [[,]*] | download [[,]*] | pattypan [] | gui");
+ LOGGER.info("Usage: GlamScrap [paris_archives|toulouse_archives|toulouse_photos] scrap [[,]*] | check [[,]*] | download [[,]*] | pattypan [] | gui");
}
public static void main(String[] args) {
@@ -173,11 +179,12 @@ private void doUploadTool(String[] args, UploadTool tool) throws IOException {
public abstract String getInstitution();
- private static GlamScrap buildApp(String city) {
- switch (city) {
- case "paris": return new ParisArchivesGlamScrap();
- case "toulouse": return new ToulouseArchivesGlamScrap();
- default: throw new IllegalArgumentException("Unsupported city: " + city);
+ private static GlamScrap buildApp(String institution) {
+ switch (institution) {
+ case "paris_archives": return new ParisArchivesGlamScrap();
+ case "toulouse_archives": return new ToulouseArchivesGlamScrap();
+ case "toulouse_photos": return new ToulousePhotothequeGlamScrap();
+ default: throw new IllegalArgumentException("Unsupported institution: " + institution);
}
}
@@ -375,6 +382,19 @@ protected final Document fetch(String doc) throws IOException {
return Jsoup.connect(getBaseUrl() + doc).get();
}
+ protected final String fetchPost(String doc, String body, String...headers) throws IOException, InterruptedException {
+ return fetchPost(HttpRequest.newBuilder()
+ .headers(headers)
+ .method("POST", BodyPublishers.ofString(body))
+ .uri(URI.create(getBaseUrl() + doc)).build());
+ }
+
+ protected final String fetchPost(HttpRequest request) throws IOException, InterruptedException {
+ try (HttpClient client = HttpClient.newHttpClient()) {
+ return client.send(request, HttpResponse.BodyHandlers.ofString()).body();
+ }
+ }
+
public abstract String getOtherFields(Notice n);
public abstract List getCategories(Notice n);
diff --git a/src/main/java/com/github/donvip/glamscrap/Gwt.java b/src/main/java/com/github/donvip/glamscrap/Gwt.java
new file mode 100644
index 0000000..63615d6
--- /dev/null
+++ b/src/main/java/com/github/donvip/glamscrap/Gwt.java
@@ -0,0 +1,126 @@
+package com.github.donvip.glamscrap;
+
+import static java.util.Objects.requireNonNull;
+
+import java.net.URI;
+import java.net.http.HttpRequest;
+import java.net.http.HttpRequest.BodyPublishers;
+import java.net.http.HttpRequest.Builder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
+
+public class Gwt {
+
+ public static final String BOOLEAN = "java.lang.Boolean/476441737";
+ public static final String INTEGER = "java.lang.Integer/3438268394";
+ public static final String STRING = "java.lang.String/2004016611";
+
+ private static final ScriptEngine NASHORN = new ScriptEngineManager().getEngineByName("nashorn");
+
+ public record TypedValue(String declaredType, String runtimeType, String stringValue, int intValue, List fieldsInAlphabeticalOrder) {
+ }
+
+ public record GwtResponse(int protocolVersion, int flags, List strings, List