partial implementation

This commit is contained in:
Michele Artini 2024-11-11 14:35:41 +01:00
parent d5b6c4e409
commit b1580917f7
4 changed files with 397 additions and 52 deletions

View File

@ -34,7 +34,7 @@ import eu.dnetlib.app.directindex.mapping.OafMapper;
import eu.dnetlib.app.directindex.service.DirectIndexService; import eu.dnetlib.app.directindex.service.DirectIndexService;
import eu.dnetlib.app.directindex.solr.SolrIndexClient; import eu.dnetlib.app.directindex.solr.SolrIndexClient;
import eu.dnetlib.app.directindex.solr.SolrIndexClientFactory; 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 eu.dnetlib.app.directindex.sword.model.SwordStatusDocument;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
@ -55,7 +55,7 @@ public class SwordApiController {
private String baseUrl; private String baseUrl;
@GetMapping("/") @GetMapping("/")
public SwordService getServiceDocument() { public SwordServiceDocument getServiceDocument() {
// TODO // TODO
return null; return null;
} }

View File

@ -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;
}
}

View File

@ -1,71 +1,80 @@
package eu.dnetlib.app.directindex.sword.model; 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 { public class SwordService {
// @formatter:off @JsonProperty("id")
public String id;
/* @JsonProperty("dc:title")
{ public String title;
"@context" : "https://swordapp.github.io/swordv3/swordv3.jsonld",
"@id" : "http://example.com/service-document", @JsonProperty("dcterms:abstract")
"@type" : "ServiceDocument", public String description;
"dc:title" : "Site Name", public String root;
"dcterms:abstract" : "Site Description", public String parent;
public boolean acceptDeposits;
"root" : "http://example.com/service-document", public List<?> services;
"acceptDeposits": true,
"version": "http://purl.org/net/sword/3.0", public String getId() {
"maxUploadSize" : 16777216000, return id;
"maxByReferenceSize" : 30000000000000000, }
"maxSegmentSize" : 16777216000,
"minSegmentSize" : 1, public void setId(final String id) {
"maxAssembledSize" : 30000000000000, this.id = id;
"maxSegments" : 1000, }
"accept" : ["* /*"], public String getTitle() {
"acceptArchiveFormat" : ["application/zip"], return title;
"acceptPackaging" : ["*"], }
"acceptMetadata" : ["http://purl.org/net/sword/3.0/types/Metadata"],
public void setTitle(final String title) {
"collectionPolicy" : { this.title = title;
"@id" : "http://www.myorg.ac.uk/collectionpolicy", }
"description" : "...."
}, public String getDescription() {
"treatment" : { return description;
"@id" : "http://www.myorg.ac.uk/treatment", }
"description" : "..."
}, public void setDescription(final String description) {
this.description = description;
"staging" : "http://example.com/staging", }
"stagingMaxIdle" : 3600,
public String getRoot() {
"byReferenceDeposit" : true, return root;
"onBehalfOf" : true, }
"digest" : ["SHA-256", "SHA", "MD5"], public void setRoot(final String root) {
"authentication": ["Basic", "OAuth", "Digest", "APIKey"], this.root = root;
}
"services" : [
{ public String getParent() {
"@id": "http://swordapp.org/deposit/43", return parent;
}
"dc:title" : "Deposit Service Name",
"dcterms:abstract" : "Deposit Service Description", public void setParent(final String parent) {
this.parent = parent;
"root" : "http://example.com/service-document", }
"parent" : "http://example.com/service-document",
"acceptDeposits": true, public boolean isAcceptDeposits() {
return acceptDeposits;
"services" : [] }
}
] public void setAcceptDeposits(final boolean acceptDeposits) {
this.acceptDeposits = acceptDeposits;
}
public List<?> getServices() {
return services;
}
public void setServices(final List<?> services) {
this.services = services;
} }
*/
} }

View File

@ -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<String> accept = Arrays.asList();
public List<String> acceptArchiveFormat = Arrays.asList();
public List<String> acceptPackaging = Arrays.asList();
public List<String> acceptMetadata = Arrays.asList();
public SwordIdDescProperty collectionPolicy;
public SwordIdDescProperty treatment;
public String staging;
public int stagingMaxIdle;
public boolean byReferenceDeposit;
public boolean onBehalfOf;
public final List<String> digest = Arrays.asList();
public final List<String> authentication = Arrays.asList();
public final List<SwordService> 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<String> getAccept() {
return accept;
}
public void setAccept(final List<String> accept) {
this.accept = accept;
}
public List<String> getAcceptArchiveFormat() {
return acceptArchiveFormat;
}
public void setAcceptArchiveFormat(final List<String> acceptArchiveFormat) {
this.acceptArchiveFormat = acceptArchiveFormat;
}
public List<String> getAcceptPackaging() {
return acceptPackaging;
}
public void setAcceptPackaging(final List<String> acceptPackaging) {
this.acceptPackaging = acceptPackaging;
}
public List<String> getAcceptMetadata() {
return acceptMetadata;
}
public void setAcceptMetadata(final List<String> 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<String> getDigest() {
return digest;
}
public List<String> getAuthentication() {
return authentication;
}
public List<SwordService> 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" : []
}
]
}
*/
}