Commits

Sam Adams  committed 5c6e7c3

Updates for CLI tools

  • Participants
  • Parent commits 44d4fd5

Comments (0)

Files changed (3)

File client-cli/src/main/java/net/chempound/client/cli/command/DepositCommand.java

 
     }
 
-    private void setTitle(final DepositBuilder depositBuilder) {
+    protected void setTitle(final DepositBuilder depositBuilder) {
         if (depositOptions.title != null) {
             depositBuilder.setTitle(depositOptions.title);
         }
     }
 
-    private void setSlug(final DepositBuilder depositBuilder) {
+    protected void setSlug(final DepositBuilder depositBuilder) {
         if (depositOptions.slug != null) {
             depositBuilder.setSlug(depositOptions.slug);
         }
     }
 
-    private void attachFiles(final GlobalOptions globalOptions, final DepositBuilder depositBuilder) {
+    protected void attachFiles(final GlobalOptions globalOptions, final DepositBuilder depositBuilder) {
         if (depositOptions.files != null) {
             for (final String filename : depositOptions.files) {
                 final File file = globalOptions.workingDirectory == null ? new File(filename) : new File(globalOptions.workingDirectory, filename);

File client-utils/src/main/java/net/chempound/client/MultipartRelatedEntity.java

 
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
-import org.apache.http.entity.mime.FormBodyPart;
 import org.apache.http.entity.mime.HttpMultipart;
 import org.apache.http.entity.mime.HttpMultipartMode;
 import org.apache.http.entity.mime.content.ContentBody;
     public boolean isRepeatable() {
         List<?> parts = this.multipart.getBodyParts();
         for (Iterator<?> it = parts.iterator(); it.hasNext(); ) {
-            FormBodyPart part = (FormBodyPart) it.next();
+            AttachmentBodyPart part = (AttachmentBodyPart) it.next();
             ContentBody body = (ContentBody) part.getBody();
             if (body.getContentLength() < 0) {
                 return false;

File client-utils/src/main/java/net/chempound/client/SwordClient.java

 
     public DepositReceipt deposit(final URI uri, final DepositRequest deposit, final boolean discoveryEnabled) throws Exception {
         final URI depositUri = discoveryEnabled ? discoverDepositUri(uri) : uri;
+        System.err.println("deposit to: "+depositUri);
 
         final HttpPost request = createDepositRequest(depositUri, deposit);
         final HttpResponse response = httpClient.execute(request);
         try {
             if (response.getStatusLine().getStatusCode() == SC_OK) {
                 final Document doc = readHtml(response);
-                final Nodes nodes = doc.query("/h:html/h:head/h:link[@rel='http://purl.org/net/sword/terms/deposit']/@href", HTML_CONTEXT);
+                Nodes nodes = doc.query("/h:html/h:head/h:link[@rel='http://purl.org/net/sword/terms/deposit']/@href", HTML_CONTEXT);
+                if (nodes.size() == 0) {
+                    nodes =  doc.query("/html/head/link[@rel='http://purl.org/net/sword/terms/deposit']/@href");
+                }
                 return nodes.size() == 0 ? uri : URI.create(nodes.get(0).getValue());
             }
         } finally {