From 9e702667a495219eb8f53710abca85e23601a979 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 30 Oct 2024 14:23:46 +0100 Subject: [PATCH] first part --- .classpath | 40 ++ .gitignore | 1 + .java-version | 1 + .project | 23 + pom.xml | 458 ++++++++++++++++++ .../directindex/DirectIndexApplication.java | 13 + .../sword/SwordFileSetUrlController.java | 34 ++ .../sword/SwordFileUrlController.java | 43 ++ .../sword/SwordMetadataUrlController.java | 42 ++ .../sword/SwordObjectUrlController.java | 62 +++ .../sword/SwordServiceUrlController.java | 36 ++ .../sword/SwordTemporaryUrlController.java | 58 +++ src/main/resources/application.properties | 1 + 13 files changed, 812 insertions(+) create mode 100644 .classpath create mode 100644 .java-version create mode 100644 .project create mode 100644 pom.xml create mode 100644 src/main/java/eu/dnetlib/app/directindex/DirectIndexApplication.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/SwordFileSetUrlController.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/SwordFileUrlController.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/SwordObjectUrlController.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java create mode 100644 src/main/java/eu/dnetlib/app/directindex/sword/SwordTemporaryUrlController.java create mode 100644 src/main/resources/application.properties diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fa8681c --- /dev/null +++ b/.classpath @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 3df9a13..8aec20e 100644 --- a/.gitignore +++ b/.gitignore @@ -86,3 +86,4 @@ local.properties # Typically, this file would be tracked if it contains build/dependency configurations: #.project +/target/ diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..e000eb8 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17.0.9 diff --git a/.project b/.project new file mode 100644 index 0000000..9b0fe6d --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + dnet-directindex-application + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..11a40fc --- /dev/null +++ b/pom.xml @@ -0,0 +1,458 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 3.3.5 + + + + 4.0.0 + eu.dnetlib.dhp + dnet-directindex-application + 1.0.0-SNAPSHOT + jar + + + + GNU Affero General Public License v3.0 or later + https://spdx.org/licenses/AGPL-3.0-or-later.html#licenseText + repo + This program is free software: you can redistribute it and/or modify it under the terms of the + GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + + + + Redmine + https://issue.openaire.research-infrastructures.eu/projects/openaire + + + + jenkins + https://jenkins-dnet.d4science.org/ + + + + scm:git:gitea@code-repo.d4science.org:D-Net/dnet-directindex-applcation.git + scm:git:gitea@code-repo.d4science.org:D-Net/dnet-directindex-applcation.git + https://code-repo.d4science.org/D-Net/dnet-directindex-applcation/ + HEAD + + + Direct Index API using the SWORD protocol + + + + dnet45-releases-snapshot + D-Net 45 snapshot + https://maven.d4science.org/nexus/content/repositories/dnet45-snapshots + default + + true + + + true + + + + dnet45-releases + D-Net 45 releases + https://maven.d4science.org/nexus/content/repositories/dnet45-releases + default + + false + + + true + + + + + true + + + false + + cloudera + Cloudera Repository + https://repository.cloudera.com/artifactory/cloudera-repos + + + dnet-deps + D-Net Dependencies + https://maven.d4science.org/nexus/content/repositories/dnet-deps/ + + true + + + false + + default + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-configuration-processor + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-cache + + + + + + + org.apache.commons + commons-lang3 + + + + commons-codec + commons-codec + + + + commons-io + commons-io + + + + org.apache.commons + commons-pool2 + + + + org.junit.jupiter + junit-jupiter + test + + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + + + + + commons-cli + commons-cli + 1.4 + + + + commons-codec + commons-codec + 1.9 + + + + commons-io + commons-io + 2.10.0 + + + + dom4j + dom4j + 1.6.1 + + + + xml-apis + xml-apis + 1.4.01 + + + + jaxen + jaxen + 1.1.6 + + + + org.apache.maven + maven-model + 3.8.1 + + + + com.vladmihalcea + hibernate-types-52 + 2.9.13 + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.2 + + + + + org.glassfish.jaxb + jaxb-runtime + 2.3.2 + + + + + javax.mail + mail + 1.4.7 + + + + + org.springdoc + springdoc-openapi-ui + 1.6.10 + + + + + org.apache.hadoop + hadoop-client + 2.6.0-cdh5.9.2 + + + org.slf4j + slf4j-log4j12 + + + javax.servlet + servlet-api + + + com.google.guava + guava + + + org.apache.hadoop + hadoop-aws + + + + + + + hwu.elixir + bmuse-core + 0.5.4 + + + org.apache.any23 + apache-any23-core + 2.3 + + + org.eclipse.rdf4j + rdf4j-rio-rdfxml + 3.7.1 + + + org.eclipse.rdf4j + rdf4j-model + 3.7.1 + + + org.jsoup + jsoup + 1.13.1 + + + org.seleniumhq.selenium + selenium-java + 3.141.59 + + + commons-validator + commons-validator + 1.6 + + + + + + + target + target/classes + ${project.artifactId}-${project.version} + target/test-classes + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + org.apache.maven.plugins + maven-site-plugin + 3.7.1 + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + verify + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + true + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + true + none + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.0.0 + + + + + + + org.apache.maven.plugins + maven-site-plugin + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + + + + + org.apache.maven.wagon + wagon-ssh + 2.10 + + + + + + dnet45-snapshots + DNet45 Snapshots + https://maven.d4science.org/nexus/content/repositories/dnet45-snapshots + default + + + dnet45-releases + https://maven.d4science.org/nexus/content/repositories/dnet45-releases + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + true + none + + + + + + + UTF-8 + UTF-8 + 3.6.0 + 17 + 2.14.0 + 7.1.0 + 3.4.2 + 0.10.0 + 1.71.0 + false + 1.3.6 + 2.6 + + diff --git a/src/main/java/eu/dnetlib/app/directindex/DirectIndexApplication.java b/src/main/java/eu/dnetlib/app/directindex/DirectIndexApplication.java new file mode 100644 index 0000000..120bb96 --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/DirectIndexApplication.java @@ -0,0 +1,13 @@ +package eu.dnetlib.app.directindex; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DirectIndexApplication { + + public static void main(final String[] args) { + SpringApplication.run(DirectIndexApplication.class, args); + } + +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordFileSetUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordFileSetUrlController.java new file mode 100644 index 0000000..6e6372d --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordFileSetUrlController.java @@ -0,0 +1,34 @@ +package eu.dnetlib.app.directindex.sword; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController("/api/directindex/file") +public class SwordFileSetUrlController { + + @PutMapping("/") + public @ResponseBody Object replaceFileSet( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Content-Type") final String contentType, + @RequestHeader("Digest") final String digest, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @RequestHeader(value = "Packaging", defaultValue = "http://purl.org/net/sword/3.0/package/Binary") final String packaging) { + // TODO + return null; + } + + @DeleteMapping("/") + public @ResponseBody Object deleteFileSet( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordFileUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordFileUrlController.java new file mode 100644 index 0000000..34300ac --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordFileUrlController.java @@ -0,0 +1,43 @@ +package eu.dnetlib.app.directindex.sword; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController("/api/directindex/files") +public class SwordFileUrlController { + + @GetMapping("/") + public @ResponseBody Object getFile( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + + @PutMapping("/") + public @ResponseBody Object replaceFile( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Content-Type") final String contentType, + @RequestHeader("Digest") final String digest, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + + @DeleteMapping("/") + public @ResponseBody Object deleteFile( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java new file mode 100644 index 0000000..803126a --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java @@ -0,0 +1,42 @@ +package eu.dnetlib.app.directindex.sword; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController("/api/directindex/metadata") +public class SwordMetadataUrlController { + + @GetMapping("/") + public @ResponseBody Object getMetadata( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + + @PutMapping("/") + public @ResponseBody Object replaceMetadata(@RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Content-Type") final String contentType, + @RequestHeader("Digest") final String digest, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @RequestHeader(value = "Metadata-Format", defaultValue = "http://purl.org/net/sword/3.0/types/Metadata") final String mdFormat) { + // TODO + return null; + } + + @DeleteMapping("/") + public @ResponseBody Object deleteMetadata( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordObjectUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordObjectUrlController.java new file mode 100644 index 0000000..b0ec1de --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordObjectUrlController.java @@ -0,0 +1,62 @@ +package eu.dnetlib.app.directindex.sword; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController("/api/directindex/obj") +public class SwordObjectUrlController { + + @GetMapping("/") + public @ResponseBody Object getObjectStatus( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + + @PostMapping("/") + public @ResponseBody Object appendObjectData( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Content-Type") final String contentType, + @RequestHeader("Digest") final String digest, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader(value = "In-Progress", defaultValue = "false") final boolean inProgress, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @RequestHeader(value = "Packaging", defaultValue = "http://purl.org/net/sword/3.0/package/Binary") final String packaging, + @RequestHeader(value = "Metadata-Format", defaultValue = "http://purl.org/net/sword/3.0/types/Metadata") final String mdFormat) { + // TODO + return null; + } + + @PutMapping("/") + public @ResponseBody Object replaceObject( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Content-Type") final String contentType, + @RequestHeader("Digest") final String digest, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader(value = "In-Progress", defaultValue = "false") final boolean inProgress, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @RequestHeader(value = "Packaging", defaultValue = "http://purl.org/net/sword/3.0/package/Binary") final String packaging, + @RequestHeader(value = "Metadata-Format", defaultValue = "http://purl.org/net/sword/3.0/types/Metadata") final String mdFormat) { + // TODO + return null; + } + + @DeleteMapping("/") + public @ResponseBody Object deleteObject( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("If-Match") final boolean ifMatch, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java new file mode 100644 index 0000000..b8687d7 --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java @@ -0,0 +1,36 @@ +package eu.dnetlib.app.directindex.sword; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController("/api/swordv3/XXXXXX") +public class SwordServiceUrlController { + + @GetMapping("/") + public @ResponseBody Object getServiceDocument( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + + @PostMapping("/") + public @ResponseBody Object makeNewObject( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Content-Type") final String contentType, + @RequestHeader("Digest") final String digest, + @RequestHeader(value = "In-Progress", defaultValue = "false") final boolean inProgress, + @RequestHeader(value = "Metadata-Format", defaultValue = "http://purl.org/net/sword/3.0/types/Metadata") final String mdFormat, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @RequestHeader(value = "Packaging", defaultValue = "http://purl.org/net/sword/3.0/package/Binary") final String packaging, + @RequestHeader("Slug") final String slug) { + // TODO + return null; + } + +} diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordTemporaryUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordTemporaryUrlController.java new file mode 100644 index 0000000..3003363 --- /dev/null +++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordTemporaryUrlController.java @@ -0,0 +1,58 @@ +package eu.dnetlib.app.directindex.sword; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController("/api/directindex/staging") +public class SwordTemporaryUrlController { + + @Value("${dnet.directindex.baseurl}") + public String baseUrl; + + @PostMapping("/") + // Create a Temporary-URL for Segmented File Upload + public @ResponseBody Object createTempUrl( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("On-Behalf-Of") final String onBehalfOf) { + // TODO + return null; + } + + @GetMapping("/{tempfile}") + public @ResponseBody Object getUploadInfo( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @PathVariable final String tempfile) { + // TODO + return null; + } + + @PostMapping("/{tempfile}") + public @ResponseBody Object uploadSegment( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("Content-Disposition") final String contentDisposition, + @RequestHeader("Content-Length") final String contentLength, + @RequestHeader("Digest") final String digest, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @PathVariable final String tempfile) { + // TODO + return null; + } + + @DeleteMapping("/{tempfile}") + public @ResponseBody Object abortUplodad( + @RequestHeader("Authorization") final String authorization, + @RequestHeader("On-Behalf-Of") final String onBehalfOf, + @PathVariable final String tempfile) { + // TODO + return null; + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..639add3 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +dnet.directindex.baseurl = http://localhost:8280 \ No newline at end of file