From b1580917f7e8c13f84770ddca453224715e6a0c4 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 11 Nov 2024 14:35:41 +0100 Subject: [PATCH] partial implementation --- .../controllers/SwordApiController.java | 4 +- .../sword/model/SwordIdDescProperty.java | 27 ++ .../directindex/sword/model/SwordService.java | 109 +++--- .../sword/model/SwordServiceDocument.java | 309 ++++++++++++++++++ 4 files changed, 397 insertions(+), 52 deletions(-) create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/model/SwordIdDescProperty.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/model/SwordServiceDocument.java diff --git a/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java b/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java index 76bea1e..5d00c69 100644 --- a/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java +++ b/src/main/java/eu/dnetlib/app/directindex/controllers/SwordApiController.java @@ -34,7 +34,7 @@ import eu.dnetlib.app.directindex.mapping.OafMapper; import eu.dnetlib.app.directindex.service.DirectIndexService; import eu.dnetlib.app.directindex.solr.SolrIndexClient; import eu.dnetlib.app.directindex.solr.SolrIndexClientFactory; -import eu.dnetlib.app.directindex.sword.model.SwordService; +import eu.dnetlib.app.directindex.sword.model.SwordServiceDocument; import eu.dnetlib.app.directindex.sword.model.SwordStatusDocument; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -55,7 +55,7 @@ public class SwordApiController { private String baseUrl; @GetMapping("/") - public SwordService getServiceDocument() { + public SwordServiceDocument getServiceDocument() { // TODO return null; } diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordIdDescProperty.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordIdDescProperty.java new file mode 100644 index 0000000..2ce1fb9 --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordIdDescProperty.java @@ -0,0 +1,27 @@ +package eu.dnetlib.app.directindex.sword.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SwordIdDescProperty { + + @JsonProperty("@id") + public String id; + + public String description; + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java index 3996e4b..81330c7 100644 --- a/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java +++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java @@ -1,71 +1,80 @@ package eu.dnetlib.app.directindex.sword.model; -import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; -@JsonInclude(JsonInclude.Include.NON_NULL) public class SwordService { - // @formatter:off + @JsonProperty("id") + public String id; - /* - { - "@context" : "https://swordapp.github.io/swordv3/swordv3.jsonld", + @JsonProperty("dc:title") + public String title; - "@id" : "http://example.com/service-document", - "@type" : "ServiceDocument", + @JsonProperty("dcterms:abstract") + public String description; - "dc:title" : "Site Name", - "dcterms:abstract" : "Site Description", + public String root; + public String parent; + public boolean acceptDeposits; - "root" : "http://example.com/service-document", - "acceptDeposits": true, + public List services; - "version": "http://purl.org/net/sword/3.0", - "maxUploadSize" : 16777216000, - "maxByReferenceSize" : 30000000000000000, - "maxSegmentSize" : 16777216000, - "minSegmentSize" : 1, - "maxAssembledSize" : 30000000000000, - "maxSegments" : 1000, + public String getId() { + return id; + } - "accept" : ["* /*"], - "acceptArchiveFormat" : ["application/zip"], - "acceptPackaging" : ["*"], - "acceptMetadata" : ["http://purl.org/net/sword/3.0/types/Metadata"], + public void setId(final String id) { + this.id = id; + } - "collectionPolicy" : { - "@id" : "http://www.myorg.ac.uk/collectionpolicy", - "description" : "...." - }, - "treatment" : { - "@id" : "http://www.myorg.ac.uk/treatment", - "description" : "..." - }, + public String getTitle() { + return title; + } - "staging" : "http://example.com/staging", - "stagingMaxIdle" : 3600, + public void setTitle(final String title) { + this.title = title; + } - "byReferenceDeposit" : true, - "onBehalfOf" : true, + public String getDescription() { + return description; + } - "digest" : ["SHA-256", "SHA", "MD5"], - "authentication": ["Basic", "OAuth", "Digest", "APIKey"], + public void setDescription(final String description) { + this.description = description; + } - "services" : [ - { - "@id": "http://swordapp.org/deposit/43", + public String getRoot() { + return root; + } - "dc:title" : "Deposit Service Name", - "dcterms:abstract" : "Deposit Service Description", + public void setRoot(final String root) { + this.root = root; + } - "root" : "http://example.com/service-document", - "parent" : "http://example.com/service-document", - "acceptDeposits": true, + public String getParent() { + return parent; + } - "services" : [] - } - ] - } + public void setParent(final String parent) { + this.parent = parent; + } + + public boolean isAcceptDeposits() { + return acceptDeposits; + } + + public void setAcceptDeposits(final boolean acceptDeposits) { + this.acceptDeposits = acceptDeposits; + } + + public List getServices() { + return services; + } + + public void setServices(final List services) { + this.services = services; + } - */ } diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordServiceDocument.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordServiceDocument.java new file mode 100644 index 0000000..f23e4cd --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordServiceDocument.java @@ -0,0 +1,309 @@ +package eu.dnetlib.app.directindex.sword.model; + +import java.util.Arrays; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SwordServiceDocument { + + @JsonProperty("@context") + public final String context = "https://swordapp.github.io/swordv3/swordv3.jsonld"; + + @JsonProperty("@id") + public String id; + + @JsonProperty("@type") + public final String type = "ServiceDocument"; + + @JsonProperty("dc:title") + public String title; + + @JsonProperty("dcterms:abstract") + public String description; + + public String root; + public boolean acceptDeposits; + public String version; + public long maxUploadSize; + public long maxByReferenceSize; + public long maxSegmentSize; + public int minSegmentSize; + public long maxAssembledSize; + public int maxSegments; + public List accept = Arrays.asList(); + public List acceptArchiveFormat = Arrays.asList(); + public List acceptPackaging = Arrays.asList(); + public List acceptMetadata = Arrays.asList(); + public SwordIdDescProperty collectionPolicy; + public SwordIdDescProperty treatment; + public String staging; + public int stagingMaxIdle; + public boolean byReferenceDeposit; + public boolean onBehalfOf; + public final List digest = Arrays.asList(); + public final List authentication = Arrays.asList(); + public final List services = Arrays.asList(); + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(final String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public String getRoot() { + return root; + } + + public void setRoot(final String root) { + this.root = root; + } + + public boolean isAcceptDeposits() { + return acceptDeposits; + } + + public void setAcceptDeposits(final boolean acceptDeposits) { + this.acceptDeposits = acceptDeposits; + } + + public String getVersion() { + return version; + } + + public void setVersion(final String version) { + this.version = version; + } + + public long getMaxUploadSize() { + return maxUploadSize; + } + + public void setMaxUploadSize(final long maxUploadSize) { + this.maxUploadSize = maxUploadSize; + } + + public long getMaxByReferenceSize() { + return maxByReferenceSize; + } + + public void setMaxByReferenceSize(final long maxByReferenceSize) { + this.maxByReferenceSize = maxByReferenceSize; + } + + public long getMaxSegmentSize() { + return maxSegmentSize; + } + + public void setMaxSegmentSize(final long maxSegmentSize) { + this.maxSegmentSize = maxSegmentSize; + } + + public int getMinSegmentSize() { + return minSegmentSize; + } + + public void setMinSegmentSize(final int minSegmentSize) { + this.minSegmentSize = minSegmentSize; + } + + public long getMaxAssembledSize() { + return maxAssembledSize; + } + + public void setMaxAssembledSize(final long maxAssembledSize) { + this.maxAssembledSize = maxAssembledSize; + } + + public int getMaxSegments() { + return maxSegments; + } + + public void setMaxSegments(final int maxSegments) { + this.maxSegments = maxSegments; + } + + public List getAccept() { + return accept; + } + + public void setAccept(final List accept) { + this.accept = accept; + } + + public List getAcceptArchiveFormat() { + return acceptArchiveFormat; + } + + public void setAcceptArchiveFormat(final List acceptArchiveFormat) { + this.acceptArchiveFormat = acceptArchiveFormat; + } + + public List getAcceptPackaging() { + return acceptPackaging; + } + + public void setAcceptPackaging(final List acceptPackaging) { + this.acceptPackaging = acceptPackaging; + } + + public List getAcceptMetadata() { + return acceptMetadata; + } + + public void setAcceptMetadata(final List acceptMetadata) { + this.acceptMetadata = acceptMetadata; + } + + public SwordIdDescProperty getCollectionPolicy() { + return collectionPolicy; + } + + public void setCollectionPolicy(final SwordIdDescProperty collectionPolicy) { + this.collectionPolicy = collectionPolicy; + } + + public SwordIdDescProperty getTreatment() { + return treatment; + } + + public void setTreatment(final SwordIdDescProperty treatment) { + this.treatment = treatment; + } + + public String getStaging() { + return staging; + } + + public void setStaging(final String staging) { + this.staging = staging; + } + + public int getStagingMaxIdle() { + return stagingMaxIdle; + } + + public void setStagingMaxIdle(final int stagingMaxIdle) { + this.stagingMaxIdle = stagingMaxIdle; + } + + public boolean isByReferenceDeposit() { + return byReferenceDeposit; + } + + public void setByReferenceDeposit(final boolean byReferenceDeposit) { + this.byReferenceDeposit = byReferenceDeposit; + } + + public boolean isOnBehalfOf() { + return onBehalfOf; + } + + public void setOnBehalfOf(final boolean onBehalfOf) { + this.onBehalfOf = onBehalfOf; + } + + public String getContext() { + return context; + } + + public String getType() { + return type; + } + + public List getDigest() { + return digest; + } + + public List getAuthentication() { + return authentication; + } + + public List getServices() { + return services; + } + + // @formatter:off + + /* + { + "@context" : "https://swordapp.github.io/swordv3/swordv3.jsonld", + + "@id" : "http://example.com/service-document", + "@type" : "ServiceDocument", + + "dc:title" : "Site Name", + "dcterms:abstract" : "Site Description", + + "root" : "http://example.com/service-document", + "acceptDeposits": true, + + "version": "http://purl.org/net/sword/3.0", + "maxUploadSize" : 16777216000, + "maxByReferenceSize" : 30000000000000000, + "maxSegmentSize" : 16777216000, + "minSegmentSize" : 1, + "maxAssembledSize" : 30000000000000, + "maxSegments" : 1000, + + "accept" : ["* /*"], + "acceptArchiveFormat" : ["application/zip"], + "acceptPackaging" : ["*"], + "acceptMetadata" : ["http://purl.org/net/sword/3.0/types/Metadata"], + + "collectionPolicy" : { + "@id" : "http://www.myorg.ac.uk/collectionpolicy", + "description" : "...." + }, + "treatment" : { + "@id" : "http://www.myorg.ac.uk/treatment", + "description" : "..." + }, + + "staging" : "http://example.com/staging", + "stagingMaxIdle" : 3600, + + "byReferenceDeposit" : true, + "onBehalfOf" : true, + + "digest" : ["SHA-256", "SHA", "MD5"], + "authentication": ["Basic", "OAuth", "Digest", "APIKey"], + + "services" : [ + { + "@id": "http://swordapp.org/deposit/43", + + "dc:title" : "Deposit Service Name", + "dcterms:abstract" : "Deposit Service Description", + + "root" : "http://example.com/service-document", + "parent" : "http://example.com/service-document", + "acceptDeposits": true, + + "services" : [] + } + ] + } + + */ +}