Skip to content

Commit 9604e79

Browse files
Merge pull request #446 from FAIRDataTeam/fix/version-metadata
Hotfix 1.17.1
2 parents 9fe3442 + 26e1b2a commit 9604e79

File tree

14 files changed

+261
-10
lines changed

14 files changed

+261
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88
## [Unreleased]
99

1010

11+
## [1.17.1]
12+
13+
❗Manual check of custom and customized metadata schemas is required.
14+
15+
### Fixed
16+
17+
- Use `dcterms:hasVersion` has been changed to `dcat:version`
18+
1119
## [1.17.0]
1220

1321
### Added
@@ -368,3 +376,4 @@ The first release of reference FAIR Data Point implementation.
368376
[1.16.1]: /../../tree/v1.16.1
369377
[1.16.2]: /../../tree/v1.16.2
370378
[1.17.0]: /../../tree/v1.17.0
379+
[1.17.1]: /../../tree/v1.17.1

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ We support the latest major and minor version with patch versions that fix vulne
66

77
| Version | Supported |
88
|---------| ------------------ |
9-
| 1.17.0 | :white_check_mark: |
9+
| 1.17.1 | :white_check_mark: |
1010
| < 1.17 | :x: |
1111

1212
## Current Recommendations

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>nl.dtls</groupId>
1212
<artifactId>fairdatapoint</artifactId>
13-
<version>1.17.0</version>
13+
<version>1.17.1</version>
1414
<packaging>jar</packaging>
1515

1616
<name>FairDataPoint</name>

src/main/java/nl/dtls/fairdatapoint/database/mongo/migration/development/settings/data/SettingsFixtures.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class SettingsFixtures {
8080
.builder()
8181
.type(SearchFilterType.LITERAL)
8282
.label("Version")
83-
.predicate("http://purl.org/dc/terms/hasVersion")
83+
.predicate("http://www.w3.org/ns/dcat#version")
8484
.queryFromRecords(true)
8585
.presetValues(Collections.emptyList())
8686
.build();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/**
2+
* The MIT License
3+
* Copyright © 2017 DTL
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package nl.dtls.fairdatapoint.database.mongo.migration.production;
24+
25+
import com.mongodb.client.MongoCollection;
26+
import com.mongodb.client.model.Filters;
27+
import com.mongodb.client.model.Updates;
28+
import io.mongock.api.annotations.ChangeUnit;
29+
import io.mongock.api.annotations.Execution;
30+
import io.mongock.api.annotations.RollbackExecution;
31+
import nl.dtls.fairdatapoint.Profiles;
32+
import nl.dtls.fairdatapoint.entity.schema.SemVer;
33+
import nl.dtls.fairdatapoint.util.KnownUUIDs;
34+
import org.bson.Document;
35+
import org.springframework.context.annotation.Profile;
36+
import org.springframework.data.mongodb.core.MongoTemplate;
37+
38+
@ChangeUnit(
39+
id = "Migration_0015_FixMetadataVersion",
40+
order = "0015",
41+
author = "migrationBot"
42+
)
43+
@Profile(Profiles.PRODUCTION)
44+
public class Migration_0015_FixMetadataVersion {
45+
46+
private static final String FIELD_UUID = "uuid";
47+
private static final String FIELD_VER_UUID = "versionUuid";
48+
private static final String FIELD_LATEST = "latest";
49+
private static final String FIELD_VERSION = "versionString";
50+
private static final String FIELD_DEF = "definition";
51+
private static final String COL_SCHEMAS = "metadataSchema";
52+
53+
private final MongoTemplate database;
54+
55+
private String previousVersionUuid;
56+
57+
public Migration_0015_FixMetadataVersion(MongoTemplate template) {
58+
this.database = template;
59+
}
60+
61+
@Execution
62+
public void run() {
63+
final MongoCollection<Document> schemasCol = database.getCollection(COL_SCHEMAS);
64+
final Document latestResourcesSchema = schemasCol.find(
65+
Filters.and(
66+
Filters.eq(FIELD_UUID, KnownUUIDs.SCHEMA_RESOURCE_UUID),
67+
Filters.eq(FIELD_LATEST, true)
68+
)
69+
).first();
70+
if (latestResourcesSchema == null) {
71+
return;
72+
}
73+
previousVersionUuid = latestResourcesSchema.getString(FIELD_VER_UUID);
74+
latestResourcesSchema.put(
75+
FIELD_DEF,
76+
latestResourcesSchema
77+
.getString(FIELD_DEF)
78+
.replace(
79+
"""
80+
sh:path dct:hasVersion ;
81+
sh:name "version" ;
82+
sh:nodeKind sh:Literal ;
83+
""",
84+
"""
85+
sh:path dcat:version ;
86+
sh:nodeKind sh:Literal ;
87+
"""
88+
)
89+
);
90+
latestResourcesSchema.remove("_id");
91+
latestResourcesSchema.put(FIELD_VER_UUID, KnownUUIDs.SCHEMA_V2_RESOURCE_UUID);
92+
latestResourcesSchema.put(FIELD_LATEST, true);
93+
final SemVer semVer = new SemVer(latestResourcesSchema.getString(FIELD_VERSION));
94+
semVer.setPatch(semVer.getPatch() + 1);
95+
latestResourcesSchema.put(FIELD_VERSION, semVer.toString());
96+
schemasCol.updateMany(
97+
Filters.and(
98+
Filters.eq(FIELD_UUID, KnownUUIDs.SCHEMA_RESOURCE_UUID),
99+
Filters.eq(FIELD_VER_UUID, previousVersionUuid)
100+
),
101+
Updates.set(FIELD_LATEST, false)
102+
);
103+
schemasCol.insertOne(latestResourcesSchema);
104+
}
105+
106+
@RollbackExecution
107+
public void rollback() {
108+
final MongoCollection<Document> schemasCol = database.getCollection(COL_SCHEMAS);
109+
schemasCol.deleteOne(
110+
Filters.and(
111+
Filters.eq(FIELD_UUID, KnownUUIDs.SCHEMA_RESOURCE_UUID),
112+
Filters.eq(FIELD_VER_UUID, KnownUUIDs.SCHEMA_V2_RESOURCE_UUID)
113+
)
114+
);
115+
schemasCol.updateOne(
116+
Filters.and(
117+
Filters.eq(FIELD_UUID, KnownUUIDs.SCHEMA_RESOURCE_UUID),
118+
Filters.eq(FIELD_VER_UUID, previousVersionUuid)
119+
),
120+
Updates.set(FIELD_LATEST, true)
121+
);
122+
}
123+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* The MIT License
3+
* Copyright © 2017 DTL
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package nl.dtls.fairdatapoint.database.rdf.migration.production;
24+
25+
import lombok.extern.slf4j.Slf4j;
26+
import nl.dtls.fairdatapoint.vocabulary.DCAT3;
27+
import nl.dtls.rdf.migration.entity.RdfMigrationAnnotation;
28+
import nl.dtls.rdf.migration.runner.RdfProductionMigration;
29+
import org.eclipse.rdf4j.model.Statement;
30+
import org.eclipse.rdf4j.model.vocabulary.DCTERMS;
31+
import org.eclipse.rdf4j.repository.Repository;
32+
import org.eclipse.rdf4j.repository.RepositoryConnection;
33+
import org.eclipse.rdf4j.repository.RepositoryException;
34+
import org.eclipse.rdf4j.repository.RepositoryResult;
35+
import org.springframework.beans.factory.annotation.Autowired;
36+
import org.springframework.stereotype.Service;
37+
38+
import static nl.dtls.fairdatapoint.util.ValueFactoryHelper.s;
39+
40+
@RdfMigrationAnnotation(
41+
number = 5,
42+
name = "Fix Metadata Version",
43+
description = "Use dcat:version instead of dcterms:hasVersion")
44+
@Slf4j
45+
@Service
46+
public class Rdf_Migration_0005_FixMetadataVersion implements RdfProductionMigration {
47+
48+
private static final String MSG_ADD = "Adding: {} {} {}";
49+
private static final String MSG_REMOVE = "Removing: {} {} {}";
50+
51+
@Autowired
52+
private Repository repository;
53+
54+
public void runMigration() {
55+
updateVersionStatements();
56+
}
57+
58+
private void updateVersionStatements() {
59+
// change dcterms:hasVersion to dcat:version property (if object is literal)
60+
try (RepositoryConnection conn = repository.getConnection()) {
61+
final RepositoryResult<Statement> queryResult = conn.getStatements(null, DCTERMS.HAS_VERSION, null);
62+
while (queryResult.hasNext()) {
63+
final Statement st = queryResult.next();
64+
if (st.getObject().isLiteral()) {
65+
log.debug(MSG_ADD, st.getSubject(), DCAT3.VERSION, st.getObject());
66+
conn.add(s(st.getSubject(), DCAT3.VERSION, st.getObject(), st.getSubject()));
67+
log.debug(MSG_REMOVE, st.getSubject(), st.getPredicate(), st.getObject());
68+
conn.remove(st);
69+
}
70+
}
71+
}
72+
catch (RepositoryException exception) {
73+
log.error(exception.getMessage(), exception);
74+
}
75+
}
76+
}

src/main/java/nl/dtls/fairdatapoint/entity/metadata/MetadataSetter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
package nl.dtls.fairdatapoint.entity.metadata;
2424

25+
import nl.dtls.fairdatapoint.vocabulary.DCAT3;
2526
import nl.dtls.fairdatapoint.vocabulary.FDP;
2627
import nl.dtls.fairdatapoint.vocabulary.Sio;
2728
import org.eclipse.rdf4j.model.IRI;
@@ -79,7 +80,7 @@ public static void setDescription(Model metadata, IRI uri, Literal description)
7980
}
8081

8182
public static void setVersion(Model metadata, IRI uri, Literal version) {
82-
update(metadata, uri, DCTERMS.HAS_VERSION, version);
83+
update(metadata, uri, DCAT3.VERSION, version);
8384
}
8485

8586
public static void setLanguage(Model metadata, IRI uri, IRI language) {

src/main/java/nl/dtls/fairdatapoint/service/index/event/MetadataRetrievalUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import nl.dtls.fairdatapoint.entity.index.http.ExchangeDirection;
3131
import nl.dtls.fairdatapoint.entity.index.http.ExchangeState;
3232
import nl.dtls.fairdatapoint.service.index.entry.IndexEntryService;
33+
import nl.dtls.fairdatapoint.vocabulary.DCAT3;
3334
import nl.dtls.fairdatapoint.vocabulary.FDP;
3435
import nl.dtls.fairdatapoint.vocabulary.R3D;
3536
import org.eclipse.rdf4j.model.IRI;
@@ -73,7 +74,7 @@ public class MetadataRetrievalUtils {
7374
private static final Map<IRI, String> MAPPING = Map.of(
7475
DCTERMS.TITLE, "title",
7576
DCTERMS.DESCRIPTION, "description",
76-
DCTERMS.HAS_VERSION, "version",
77+
DCAT3.VERSION, "version",
7778
DCTERMS.PUBLISHER, "publisher",
7879
R3D.COUNTRY, "country"
7980
);

src/main/java/nl/dtls/fairdatapoint/service/reset/FactoryDefaults.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import nl.dtls.fairdatapoint.service.schema.MetadataSchemaShaclUtils;
3636
import nl.dtls.fairdatapoint.util.KnownUUIDs;
3737
import nl.dtls.fairdatapoint.vocabulary.DATACITE;
38+
import nl.dtls.fairdatapoint.vocabulary.DCAT3;
3839
import nl.dtls.fairdatapoint.vocabulary.FDP;
3940
import nl.dtls.fairdatapoint.vocabulary.R3D;
4041
import org.bson.BasicBSONObject;
@@ -450,7 +451,7 @@ public static List<Statement> repositoryStatements(String persistentUrl, IRI lic
450451
FactoryDefaults.add(s, RDF.TYPE, i("http://www.w3.org/ns/dcat#Resource"), baseUrl);
451452
FactoryDefaults.add(s, DCTERMS.TITLE, l(DEFAULT_FDP_TITLE), baseUrl);
452453
FactoryDefaults.add(s, RDFS.LABEL, l(DEFAULT_FDP_TITLE), baseUrl);
453-
FactoryDefaults.add(s, DCTERMS.HAS_VERSION, l(1.0f), baseUrl);
454+
FactoryDefaults.add(s, DCAT3.VERSION, l(1.0f), baseUrl);
454455
FactoryDefaults.add(s, FDP.METADATAISSUED, l(OffsetDateTime.now()), baseUrl);
455456
FactoryDefaults.add(s, FDP.METADATAMODIFIED, l(OffsetDateTime.now()), baseUrl);
456457
FactoryDefaults.add(s, DCTERMS.LICENSE, license, baseUrl);
@@ -488,7 +489,7 @@ public static List<Statement> fdpStatements(String persistentUrl, IRI license,
488489
FactoryDefaults.add(s, RDF.TYPE, DCAT.RESOURCE, baseUrl);
489490
FactoryDefaults.add(s, DCTERMS.TITLE, l(DEFAULT_FDP_TITLE), baseUrl);
490491
FactoryDefaults.add(s, RDFS.LABEL, l(DEFAULT_FDP_TITLE), baseUrl);
491-
FactoryDefaults.add(s, DCTERMS.HAS_VERSION, l(1.0f), baseUrl);
492+
FactoryDefaults.add(s, DCAT3.VERSION, l(1.0f), baseUrl);
492493
FactoryDefaults.add(s, FDP.METADATAISSUED, l(OffsetDateTime.now()), baseUrl);
493494
FactoryDefaults.add(s, FDP.METADATAMODIFIED, l(OffsetDateTime.now()), baseUrl);
494495
FactoryDefaults.add(s, DCTERMS.LICENSE, license, baseUrl);

src/main/java/nl/dtls/fairdatapoint/util/KnownUUIDs.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public class KnownUUIDs {
6969
public static final String SCHEMA_V1_RESOURCE_UUID =
7070
"71d77460-f919-4f72-b265-ed26567fe361";
7171

72+
public static final String SCHEMA_V2_RESOURCE_UUID =
73+
"4c65bdf7-bb56-4bca-ae22-74977b148b16";
74+
7275
public static final String SCHEMA_V1_FDP_UUID =
7376
"4e64208d-f102-45a0-96e3-17b002e6213e";
7477

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* The MIT License
3+
* Copyright © 2017 DTL
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package nl.dtls.fairdatapoint.vocabulary;
24+
25+
import org.eclipse.rdf4j.model.IRI;
26+
import org.eclipse.rdf4j.model.vocabulary.DCAT;
27+
28+
import static nl.dtls.fairdatapoint.util.ValueFactoryHelper.i;
29+
30+
/**
31+
* Temporary solution for DCAT3 which currently not supported in RDR4J vocabularies
32+
*
33+
* @TODO: remove once RDF4J supports DCAT3
34+
*/
35+
public class DCAT3 extends DCAT {
36+
public static final IRI VERSION = i(NAMESPACE + "version");
37+
}

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ metadataProperties:
6464

6565
openapi:
6666
title: FAIR Data Point API
67-
version: 1.17.0
67+
version: 1.17.1
6868
description: "The reference implementation of the metadata registration service: A service implementing the API specification. It contains an authentication system to allow maintainers to define and update metadata. Read-only access to the data is public."
6969
contact:
7070
name: Luiz Bonino

src/main/resources/nl/dtls/fairdatapoint/database/mongo/migration/development/schema/data/shape-resource.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
sh:maxCount 1 ;
2727
dash:editor dash:BlankNodeEditor ;
2828
], [
29-
sh:path dct:hasVersion ;
29+
sh:path dcat:version ;
3030
sh:name "version" ;
3131
sh:nodeKind sh:Literal ;
3232
sh:minCount 1 ;

src/main/resources/nl/dtls/fairdatapoint/service/reset/shape-resource.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
sh:maxCount 1 ;
2727
dash:editor dash:BlankNodeEditor ;
2828
], [
29-
sh:path dct:hasVersion ;
29+
sh:path dcat:version ;
3030
sh:name "version" ;
3131
sh:nodeKind sh:Literal ;
3232
sh:minCount 1 ;

0 commit comments

Comments
 (0)