diff --git a/.classpath b/.classpath
index fa8681c..266f5b3 100644
--- a/.classpath
+++ b/.classpath
@@ -1,5 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -8,8 +21,8 @@
-
+
@@ -23,18 +36,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/eu/dnetlib/app/directindex/service/DirectIndexService.java b/src/main/java/eu/dnetlib/app/directindex/service/DirectIndexService.java
new file mode 100644
index 0000000..24cc8ec
--- /dev/null
+++ b/src/main/java/eu/dnetlib/app/directindex/service/DirectIndexService.java
@@ -0,0 +1,18 @@
+package eu.dnetlib.app.directindex.service;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class DirectIndexService {
+
+ public void prepareMetadataDeletion() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void prepareMetadataReplacement() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java
index 803126a..66e6ae3 100644
--- a/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordMetadataUrlController.java
@@ -1,42 +1,69 @@
package eu.dnetlib.app.directindex.sword;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
+import eu.dnetlib.app.directindex.service.DirectIndexService;
+import eu.dnetlib.app.directindex.sword.model.SwordMetadataDocument;
+
@RestController("/api/directindex/metadata")
public class SwordMetadataUrlController {
+ @Autowired
+ private DirectIndexService service;
+
@GetMapping("/")
- public @ResponseBody Object getMetadata(
+ public ResponseEntity getMetadata(
@RequestHeader("Authorization") final String authorization,
@RequestHeader("On-Behalf-Of") final String onBehalfOf) {
+
// TODO
- return null;
+
+ final SwordMetadataDocument metadata = null;
+
+ final HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.set("ETag", null);
+
+ return new ResponseEntity<>(metadata, responseHeaders, HttpStatus.OK);
}
@PutMapping("/")
- public @ResponseBody Object replaceMetadata(@RequestHeader("Authorization") final String authorization,
+ public ResponseEntity 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) {
+ @RequestHeader(value = "Metadata-Format", defaultValue = "http://purl.org/net/sword/3.0/types/Metadata") final String mdFormat,
+ @RequestBody final SwordMetadataDocument document) {
+
+ service.prepareMetadataReplacement();
+
// TODO
- return null;
+ final HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.set("ETag", null);
+
+ return new ResponseEntity<>(responseHeaders, HttpStatus.NO_CONTENT);
}
@DeleteMapping("/")
- public @ResponseBody Object deleteMetadata(
+ public ResponseEntity deleteMetadata(
@RequestHeader("Authorization") final String authorization,
@RequestHeader("If-Match") final boolean ifMatch,
@RequestHeader("On-Behalf-Of") final String onBehalfOf) {
- // TODO
- return null;
+
+ service.prepareMetadataDeletion();
+
+ return new ResponseEntity<>(HttpStatus.ACCEPTED);
+
}
}
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java b/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java
index 502d91f..6b46b88 100644
--- a/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/SwordServiceUrlController.java
@@ -1,16 +1,22 @@
package eu.dnetlib.app.directindex.sword;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
+import eu.dnetlib.app.directindex.sword.model.SwordService;
+import eu.dnetlib.app.directindex.sword.model.SwordStatusDocument;
+
@RestController("/api/directindex/")
public class SwordServiceUrlController {
@GetMapping("/")
- public @ResponseBody Object getServiceDocument(
+ public SwordService getServiceDocument(
@RequestHeader("Authorization") final String authorization,
@RequestHeader("On-Behalf-Of") final String onBehalfOf) {
// TODO
@@ -18,7 +24,7 @@ public class SwordServiceUrlController {
}
@PostMapping("/")
- public @ResponseBody Object makeNewObject(
+ public ResponseEntity makeNewObject(
@RequestHeader("Authorization") final String authorization,
@RequestHeader("Content-Disposition") final String contentDisposition,
@RequestHeader("Content-Length") final String contentLength,
@@ -28,9 +34,25 @@ public class SwordServiceUrlController {
@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) {
+ @RequestHeader("Slug") final String slug,
+
+ // Content used to create new Object. This can be one of: Metadata, By-Reference, Metadata+By-Reference, Binary File, Packaged
+ // Content, Empty Body
+ @RequestBody final Object content) {
+
// TODO
- return null;
+ final SwordStatusDocument status = null;
+
+ final HttpHeaders responseHeaders = new HttpHeaders();
+ responseHeaders.setLocation(null);
+ responseHeaders.set("ETag", null);
+
+ return new ResponseEntity<>(status, responseHeaders, isCreated() ? HttpStatus.CREATED : HttpStatus.ACCEPTED);
+ }
+
+ private boolean isCreated() {
+ // TODO Auto-generated method stub
+ return false;
}
}
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/BaseInfo.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordCommonInfo.java
similarity index 92%
rename from src/main/java/eu/dnetlib/app/directindex/sword/model/BaseInfo.java
rename to src/main/java/eu/dnetlib/app/directindex/sword/model/SwordCommonInfo.java
index da303ca..e6f565f 100644
--- a/src/main/java/eu/dnetlib/app/directindex/sword/model/BaseInfo.java
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordCommonInfo.java
@@ -2,7 +2,7 @@ package eu.dnetlib.app.directindex.sword.model;
import com.fasterxml.jackson.annotation.JsonProperty;
-public class BaseInfo {
+public class SwordCommonInfo {
@JsonProperty("@id")
private String id;
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/Link.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordLink.java
similarity index 96%
rename from src/main/java/eu/dnetlib/app/directindex/sword/model/Link.java
rename to src/main/java/eu/dnetlib/app/directindex/sword/model/SwordLink.java
index 392e103..5bca1dd 100644
--- a/src/main/java/eu/dnetlib/app/directindex/sword/model/Link.java
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordLink.java
@@ -5,7 +5,7 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
-public class Link {
+public class SwordLink {
@JsonProperty("@id")
private String id;
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordMetadataDocument.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordMetadataDocument.java
new file mode 100644
index 0000000..ea3c5e5
--- /dev/null
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordMetadataDocument.java
@@ -0,0 +1,6 @@
+package eu.dnetlib.app.directindex.sword.model;
+
+
+public class SwordMetadataDocument {
+
+}
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/ServiceInfo.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java
similarity index 92%
rename from src/main/java/eu/dnetlib/app/directindex/sword/model/ServiceInfo.java
rename to src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java
index 30476ce..2cac46a 100644
--- a/src/main/java/eu/dnetlib/app/directindex/sword/model/ServiceInfo.java
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordService.java
@@ -6,7 +6,7 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
-public class ServiceInfo extends BaseInfo {
+public class SwordService extends SwordCommonInfo {
@JsonProperty("@context")
private static final String context = "https://swordapp.github.io/swordv3/swordv3.jsonld";
@@ -14,9 +14,9 @@ public class ServiceInfo extends BaseInfo {
@JsonProperty("@type")
private final String type = "Status";
- private BaseInfo metadata;
+ private SwordCommonInfo metadata;
- private BaseInfo fileSet;
+ private SwordCommonInfo fileSet;
private String service;
@@ -26,17 +26,17 @@ public class ServiceInfo extends BaseInfo {
static {
actions.put("getMetadata", true);
- actions.put("getFiles", true);
+ actions.put("getFiles", false);
actions.put("appendMetadata", true);
- actions.put("appendFiles", true);
+ actions.put("appendFiles", false);
actions.put("replaceMetadata", true);
- actions.put("replaceFiles", true);
+ actions.put("replaceFiles", false);
actions.put("deleteMetadata", true);
- actions.put("deleteFiles", true);
- actions.put("deleteObject", true);
+ actions.put("deleteFiles", false);
+ actions.put("deleteObject", false);
}
- private final List links = new ArrayList<>();
+ private final List links = new ArrayList<>();
// @formatter:off
diff --git a/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordStatusDocument.java b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordStatusDocument.java
new file mode 100644
index 0000000..718cccb
--- /dev/null
+++ b/src/main/java/eu/dnetlib/app/directindex/sword/model/SwordStatusDocument.java
@@ -0,0 +1,6 @@
+package eu.dnetlib.app.directindex.sword.model;
+
+
+public class SwordStatusDocument {
+
+}