Commits

Sam Adams committed 7d1267f

Added DepositRequestMapper

  • Participants
  • Parent commits f7d757d

Comments (0)

Files changed (3)

File chempound-client/src/main/java/net/chempound/client/DefaultChempoundClient.java

 import net.chempound.rdf.RdfIO;
 import net.chempound.storage.LocalResource;
 import org.apache.abdera.Abdera;
+import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Link;
 import org.apache.commons.io.IOUtils;
 import org.swordapp.client.*;
 
     }
 
     private static CreateCollectionResponse mapCreateCollectionResponse(final DepositReceipt receipt) {
-        return new CreateCollectionResponse(URI.create(receipt.getSplashPageIRI().toString()), null);
+        final IRI splashPage = receipt.getSplashPageIRI();
+        final IRI contentSrc = receipt.getContentSrc();
+        final Link editLink = receipt.getEditLink();                // * MUST
+        final Link editMediaLink = receipt.getEditMediaLink();      // * MUST
+        final Link swordEditLink = receipt.getSwordEditLink();      // * MUST
+
+        // It MAY contain information about the metadata associated with the deposit as it is stored on the server.
+        // If it does, it SHOULD provide this metadata in extended Dublin Core [DublinCore], although it MAY also
+        // provide it in other formats. Any Dublin Core markup should be in Dublin Core XML and embedded directly
+        // in the atom:entry element, not in a dcterms:metadata element.
+
+        // It MUST contain a Media Entry IRI (Edit-IRI), defined by atom:link@rel="edit"
+
+        // It MUST contain a Media Resource IRI (EM-IRI), defined by atom:link@rel="edit-media"
+
+        // It MUST contain a SWORD Edit IRI (SE-IRI), defined by atom:link@rel="http://purl.org/net/sword/terms/add"
+        // which MAY be the same as the Edit-IRI
+
+        // It MAY contain an arbitrary number of sword:packaging elements declaring the formats that the Media
+        // Resource can be retrieved in
+
+        // It MUST contain a single sword:treatment element [SWORD003] which contains either a human-readable
+        // statement describing treatment the deposited resource has received or a IRI that dereferences to such a
+        // description.
+
+        // It MAY contain a single sword:verboseDescription element [SWORD003] which should contain a verbose
+        // description of the deposit process. This MUST only be used for debugging and development purposes,
+        // and clients MUST NOT rely on this field to contain anything in particular.
+
+        // It MAY contain one or more atom:link element with the rel attribute of
+        // http://purl.org/net/sword/terms/statement, and the href to a IRI where the statement can be retrieved.
+        // The atom:link element MUST contain a type attribute which indicates the mime-type of the statement
+        // (for example application/atom+xml;type=feed or application/rdf+xml)
+
+        // It MAY contain an atom:link@rel="alternate" element with an href attribute which points to the splash page
+        // of the item on the server
+
+        // It SHOULD contain a single atom:link element with the rel attribute of
+        // http://purl.org/net/sword/terms/originalDeposit which provides the IRI identifying the package or file
+        // deposited in the current request. This information is transient and will only be present when responding
+        // to a deposit, it is not required that it be available in the Entry Document retreived from the EM-IRI.
+
+        // It SHOULD, if relevant, contain zero or more atom:link elements with the rel attribute of
+        // http://purl.org.net/sword/terms/derivedResource which provides the IRIs identifying any content resources
+        // which were derived or extracted from the originally deposited resource (e.g. the files unpacked from a
+        // zip file). These IRIs SHOULD be actionable as per Section 6.10: SWORD Actionable IRIs.
+
+
+        return new CreateCollectionResponse(URI.create(splashPage.toString()), null);
     }
 
     private static Deposit mapDepositItemRequest(final DepositItemRequest request) {
     }
 
     private static DepositItemResponse mapDepositItemResponse(final DepositReceipt receipt) {
-        return new DepositItemResponse(URI.create(receipt.getSplashPageIRI().toString()));
+        return new DepositItemResponse(
+                                       URI.create(receipt.getSplashPageIRI().toString()),
+                                       receipt.getEditLink().getHref()
+        );
     }
 
     private static void attachMetadata(final EntryPart entryPart, final Model metadataModel) {

File chempound-client/src/main/java/net/chempound/client/DepositItemResponse.java

 package net.chempound.client;
 
+import org.apache.abdera.i18n.iri.IRI;
+
 import java.net.URI;
 
 /**
 public class DepositItemResponse {
 
     private final URI uri;
+    private final IRI mediaEntry;
 
-    public DepositItemResponse(final URI uri) {
+    public DepositItemResponse(final URI uri, final IRI mediaEntry) {
         this.uri = uri;
+        this.mediaEntry = mediaEntry;
     }
 
     public URI getUri() {
         return uri;
     }
 
+    public IRI getMediaEntry() {
+        return mediaEntry;
+    }
 }

File chempound-client/src/main/java/net/chempound/client/DepositRequestMapper.java

+package net.chempound.client;
+
+import net.chempound.content.DepositRequest;
+import net.chempound.storage.DepositResource;
+import net.chempound.storage.LocalResource;
+
+/**
+ * @author Sam Adams
+ */
+public class DepositRequestMapper {
+    public static DepositItemRequest map(final DepositRequest deposit) {
+        final DepositItemRequest request = new DepositItemRequest()
+                                            .withTitle(deposit.getTitle())
+                                            .withSlug(deposit.getSlug());
+        for (final DepositResource resource : deposit.getAggregatedResources()) {
+            request.addResource((LocalResource) resource);
+        }
+
+        return request;
+    }
+}