-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpom.xml
More file actions
540 lines (484 loc) · 25 KB
/
pom.xml
File metadata and controls
540 lines (484 loc) · 25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dk.kb.dsparent</groupId>
<artifactId>ds-parent</artifactId>
<version>100.0.0-SNAPSHOT</version>
</parent>
<groupId>dk.kb.storage</groupId>
<artifactId>ds-storage</artifactId>
<version>100.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<description>
# Ds-storage(Digitale Samlinger) by the Royal Danish Library.
## A metadata storage.
Ds-storage is a storage for metadata to describe objects in collections.
The metadata format is UTF-8 encoded but format can be anything from text,XML,JSON etc. depending on the metadata format for that collection.
The basic idea behind ds-storage is a single access point to metadata describing objects belonging to many different collections. Having a simple API to
store and retrieve the records. Instead of integrating to wide range of different APIs located on different servers, the ds-storage offers
a unified API for all of them and is optimized for retrieving a specific record very fast.
## Records
Objects in ds-storage are called records. A record has a metadata field that is UTF-8 encoded. The value of the metadata will typical be same as
in the originating collection if harvested with OAI-PMH etc.
## cTime and mTime format
The format of cTime and mTime is milliseconds since Epoch (1970) with 3 added digits and is guaranteed to be unique values. The additional
3 digits is used to ensure uniqueness. If multiple records are created/updated within same millis the last 3 digits will be consecutive.
## Creating and updating records
A record must has a origin that is prefined in the ds-storage configuration. This is the name of the collection in ds-storage.
The recordId must also have the origin as prefix so it is easy from a recordid to see where it belongs.
When a record is created it will be given a creation time (cTime) that will never be changed and a modification time (mTime). If a
record is later update only the mTime will be updated.
## Naming convention for origin and id
The origin must only contain lowercase letters and dot (.) as separator.
The id must start with the origin followed by colon (:). The part after origin must only contain of upper of lower case letters, digits and
the following characters: : . _ -
Regexp for origin: ([a-z0-9.]+)
Regexp for id: ([a-z0-9.]+):([a-zA-Z0-9:._-]+)
## ID normalisation
If a record contains a invalid character after the origin part, it will be normalised and the invalid characters will be replaced.
The original (invalid) id will be stored in the 'orgid' field and flagged for invalid id. Having the original id will make it possible
to track it back to the collection it came from. The record can still be retrieved and updated using the invalid id, but also by the normalised id.
## Record hierarchy
The datamodel is a tree structure with a single parent but no limit on number of children. The tree can be several levels deep (tree depth).
Due to the tree structre, there can not exist a cycle in the graph.
Every origin is configured with a transitive update strategy that makes sense for the origin. When a record is created or update it can update the mTime of parent and all children
if defined for the origin. The possible updatestrategies are: NONE, ALL, PARENT, CHILDREN. (see #updatestrategy schema)
## Record type
Records must have one of the 3 enum types define in RecordTypeDto. The recordtype is an easy way to determine depth in the hierachy and can be collection specific.
COLLECTION This is top parent (root) with information about the collection.
DELIVERABLEUNIT Parent for a manifestation.
MANIFESTATION A record that has metadata that relates to single digital preservation unit (image, video, audio etc.).
## API
Records can be extracted by recordId or as a list by specified origin and last modification time (mTime). The uniqueness of mTime
will ensure batching through the records using mTime will not return same record twice.
</description>
<scm>
<url>https://github.com/kb-dk/ds-storage</url>
<connection>scm:git:git@github.com:kb-dk/ds-storage.git</connection>
<developerConnection>scm:git:git@github.com:kb-dk/ds-storage.git</developerConnection>
<tag>HEAD</tag>
</scm>
<licenses>
<!--SBForge stuff should have a license-->
<license>
<name>${license.name}</name>
<url>${license.url}</url>
</license>
</licenses>
<properties>
<!-- Enable forbiddenapis plugin, do disable set to none -->
<api.check.phase>process-test-classes</api.check.phase>
<!--Specify the licenses here, so they can be picked up by openAPI-->
<license.name>Apache License, Version 2.0</license.name>
<license.url>https://www.apache.org/licenses/LICENSE-2.0.txt</license.url>
<timestamp>${maven.build.timestamp}</timestamp>
<project.package>dk.kb.storage</project.package>
</properties>
<dependencies>
<dependency>
<groupId>dk.kb.dsshared</groupId>
<artifactId>ds-shared</artifactId>
<version>100.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>dk.kb.util</groupId>
<artifactId>kb-util</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<!-- Apache CXF and servlet stuff -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<exclusions>
<!-- Project has jakarta.xml.bind-api v. 2.3.3 from cxf-rt-transports-http-->
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<!-- Project has jakarta.annotation-api v.1.3.5 through KB-util dependency.-->
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-xml-provider</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
</dependency>
<dependency>
<!--For the openapi endpoint /openapi.json-->
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
</dependency>
<dependency>
<!--For the swagger UI endpoint /api-docs?url=openapi.json-->
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
</dependency>
<!-- To get client generation to work -->
<!-- https://mvnrepository.com/artifact/org.openapitools/openapi-generator -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<exclusions>
<exclusion>
<!-- The slf4j-simple logs to stderr and stdout, ignoring logback.xml -->
<artifactId>slf4j-simple</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
</dependency>
<!-- openapitools dependency -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
</dependency>
<!-- Database dependencies-->
<!-- database -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!--For the standard unit test-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- Logging dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- Unit test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito -->
<!-- https://mvnrepository.com/artifact/org.mock-server/mockserver-junit-jupiter -->
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/openapi</directory>
<filtering>true</filtering>
</resource>
<!-- Needed as specifying <resources> overrides all previous definitions -->
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
<!-- 2: Copy only build.properties with filtering -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>ds-storage.build.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<!--This ensures that the openapi_*.yaml have been filtered and copied to target/classes
BEFORE being used by the openapi generator above-->
<phase>generate-sources</phase>
<!--as both the openapi codegen and this execution happens at phase generate-sources, ensure
this happens first by having this placed above codegen in the pom-->
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>copy-resources</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/jetty-res</outputDirectory>
<resources>
<resource>
<directory>src/test/jetty</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.1</version>
<!-- Running this gives
[WARNING] The value (generator's option) must be either boolean or string. Default to `false`.
which seems to be an unresolved issue: https://github.com/OpenAPITools/openapi-generator/issues/9008 -->
<configuration>
<generatorName>jaxrs-cxf-extended</generatorName>
<inputSpec>${project.build.outputDirectory}/openapi.yaml</inputSpec><!-- Will always be overridden -->
<modelNameSuffix>Dto</modelNameSuffix>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiTests>false</generateApiTests>
<generateModelDocumentation>true</generateModelDocumentation>
<generateApis>true</generateApis>
<output>${project.basedir}</output>
<templateDirectory>src/main/templates/</templateDirectory>
<configOptions>
<!--https://openapi-generator.tech/docs/generators/jaxrs-cxf-extended/-->
<!-- https://openapi-generator.tech/docs/generators/java/ -->
<sourceFolder>target/generated-sources</sourceFolder>
<useSwaggerFeature>true</useSwaggerFeature>
<useSwaggerUI>true</useSwaggerUI>
<apiPackage>${project.package}.api</apiPackage>
<modelPackage>${project.package}.model</modelPackage>
<dateLibrary>threetenbp</dateLibrary>
<!--<dateLibrary>Java11</dateLibrary>-->
<implFolder>src/main/java</implFolder>
<invokerPackage>${project.package}</invokerPackage>
</configOptions>
<packageName>${project.package}</packageName>
</configuration>
<executions>
<!-- Version 1 -->
<!-- When a new version is needed, make a copy of two v1-related executions below, then change
v1 to v2 in the copy.
Go to plugin.configuration.webResources.resource.includes in this pom.xml and extend the list
with v2 versions of the JSON & YAML files.
Also remember to:
* Create dk.kb.storage.webservice.Application_v2
* Create src/main/openapi/openapi_v2.yaml
* Update src/main/webapp/WEB-INF/web.xml
* Update src/main/webapp/api/index.html
-->
<execution>
<!-- Generate API and Model-files from the OpenAPI specification (positioned under the target/generated-sources/ folder).
These files are overwritten on all builds, so they should never be edited manually. -->
<id>v1: generate api classes</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.outputDirectory}/ds-storage-openapi_v1.yaml</inputSpec>
<ignoreFileOverride>
${project.basedir}/.openapi-codegen-ignore-api
</ignoreFileOverride>
<configOptions>
<apiPackage>${project.package}.api.v1</apiPackage>
<modelPackage>${project.package}.model.v1</modelPackage>
<!-- Setting this to true overwrites existing implementations.
Only set it temporarily when creating a new project -->
<generateOperationBody>false</generateOperationBody>
<sourceFolder>target/generated-sources</sourceFolder>
</configOptions>
</configuration>
</execution>
<execution>
<!-- The purpose it to generate skeleton implementation classes, if such classes are not already existing.
Since we always want to overwrite existing api & model-files when the OpenAPI specification is changed,
but never want to overwrite existing implementation-files, we need to do the generation in 2 steps. -->
<id>v1: generate skeleton impl</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.outputDirectory}/ds-storage-openapi_v1.yaml</inputSpec>
<ignoreFileOverride>
${project.basedir}/.openapi-codegen-ignore-impl
</ignoreFileOverride>
<configOptions>
<apiPackage>${project.package}.api.v1</apiPackage>
<modelPackage>${project.package}.model.v1</modelPackage>
<generateOperationBody>false</generateOperationBody><!-- To avoid stack overflow for DsRecord -->
</configOptions>
<skipOverwrite>true</skipOverwrite>
</configuration>
</execution>
</executions>
</plugin>
<!-- The generated classes for the OpenAPI client are problematic. Disable checking of those for now -->
<plugin>
<groupId>de.thetaphi</groupId>
<artifactId>forbiddenapis</artifactId>
<!-- No version or configuration here as it inherits from parent pom -->
<configuration>
<excludes>
<exclude>**/DsStorageApi.class</exclude>
<exclude>**/ServiceApi.class</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<!-- Generate a JAR with client classes and openapi-YAML for easy use by other services -->
<attachClasses>true</attachClasses>
<!--Enable maven filtering for the web.xml-->
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<webResources>
<webResource> <!-- Store application name, version and build time -->
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>ds-storage.build.properties</include>
</includes>
<filtering>true</filtering>
</webResource>
<resource>
<!--Include the openapi spec files so we can serve them-->
<directory>${project.build.outputDirectory}</directory>
<targetPath>.</targetPath>
<includes>
<include>ds-storage-openapi_v1.json</include>
<include>ds-storage-openapi_v1.yaml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<!-- Used only for mvn jetty:run jetty:run-war -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>10.0.12</version>
<configuration>
<deployMode>FORK</deployMode>
<jvmArgs>-Xmx1g -Djetty.port=9072</jvmArgs>
<jettyXmls>${project.basedir}/target/jetty-res/jetty-env.xml</jettyXmls>
<useTestScope>true</useTestScope>
<!-- https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#jetty-run-goal -->
<!-- https://stackoverflow.com/questions/12493798/jetty-maven-plugin-using-scan -->
<scan>-1</scan>
<webApp>
<contextPath>/${project.artifactId}/</contextPath>
<descriptor>${project.basedir}/target/${project.build.finalName}/WEB-INF/web.xml</descriptor>
<jettyEnvXml>${project.basedir}/target/jetty-res/jetty-env.xml</jettyEnvXml>
</webApp>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<tarLongFileMode>posix</tarLongFileMode>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<!-- Plugin used to extract information on the current git setup.
See: https://github.com/git-commit-id/git-commit-id-maven-plugin -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>7.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<includeOnlyProperties>
<includeOnlyProperty>git.commit.id</includeOnlyProperty>
<includeOnlyProperty>git.branch</includeOnlyProperty>
<includeOnlyProperty>git.closest.tag.name</includeOnlyProperty>
<includeOnlyProperty>git.commit.author.time</includeOnlyProperty>
</includeOnlyProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>