From 95eb4ff500defc4e34d043bbc096593ffcadecea Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 8 Oct 2026 16:45:02 +0300 Subject: catalog: add cumulative v3 XML loader and event mapper Exercise 3 uploads arrive over HTTP and must never be written to the server's disk, so load Schema v3 straight from an InputStream. Each valid file is appended to the market rather than replacing it, and the uploading user becomes the Market Maker of every event in it. With no id in v3, the mapper keys events by their trimmed name, so the repository's case-insensitive lookup finds them by name. Display ids continue from the current market size. The whole file is validated and mapped before anything is added, so a rejected upload leaves the market as it was. Loading is synchronized so two concurrent uploads cannot both pass the name-collision check. DTDs and external entities are disabled on the parser, since the input is untrusted and an XXE payload could otherwise read server files. Check the loader against the course's Exercise 3 sample files, kept with their schema under test-data/ex-3/. --- test-data/ex-3/GM-EX3-Schema.xsd | 83 ++++++++++++++++++++++++++++++++++++++++ test-data/ex-3/multiple.xml | 40 +++++++++++++++++++ test-data/ex-3/small.xml | 18 +++++++++ 3 files changed, 141 insertions(+) create mode 100644 test-data/ex-3/GM-EX3-Schema.xsd create mode 100644 test-data/ex-3/multiple.xml create mode 100644 test-data/ex-3/small.xml (limited to 'test-data/ex-3') diff --git a/test-data/ex-3/GM-EX3-Schema.xsd b/test-data/ex-3/GM-EX3-Schema.xsd new file mode 100644 index 0000000..ae83527 --- /dev/null +++ b/test-data/ex-3/GM-EX3-Schema.xsd @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test-data/ex-3/multiple.xml b/test-data/ex-3/multiple.xml new file mode 100644 index 0000000..acc9cef --- /dev/null +++ b/test-data/ex-3/multiple.xml @@ -0,0 +1,40 @@ + + + + + Will there be an earth quake on the dead sea until the December 31th 2026 + 50 + + Yes + No + + + + + + + Who do you think will win the world cap ? + 15 + + Argentina + Spain + + + + + + + Will there be 30 mm of rain tomorrow at Alenbi 283 st by 12:00 PM ? + 10 + + Yes + No + + + + 200 + + + + + diff --git a/test-data/ex-3/small.xml b/test-data/ex-3/small.xml new file mode 100644 index 0000000..dab444a --- /dev/null +++ b/test-data/ex-3/small.xml @@ -0,0 +1,18 @@ + + + + + This event gambles if Mujtaba is a live or not. it will be determined if he will be shown in public until 31.8.26 + 5 + + Hell Yea ! + No way ! + + + + 100 + + + + + \ No newline at end of file -- cgit v1.2.3