JCLOUDS-1111: Overwrite objects via remove and put

This partially reverts commit
e446b5b8b4.  AT&T Synaptic returns a
bogus error on with x-emc-force-overwrite:

HTTP 400, code=1012, message=There was a mismatch between the object
size and the specified extent size.
This commit is contained in:
Andrew Gaul 2017-11-06 17:43:12 -08:00
parent 343897d6d8
commit b2ced53e16
3 changed files with 13 additions and 3 deletions

View File

@ -267,7 +267,6 @@ public class AtmosBlobStore extends BaseBlobStore {
if (options.getBlobAccess() == BlobAccess.PUBLIC_READ) {
atmosOptions.publicRead();
}
atmosOptions.overwrite();
return AtmosUtils.putBlob(sync, crypto, blob2Object, container, blob, atmosOptions);
}

View File

@ -53,7 +53,11 @@ public class PutOptions extends BaseHttpRequestOptions {
return this;
}
/** By default Atmos does not allow overwriting objects. */
/**
* By default Atmos does not allow overwriting objects.
*
* Note: older versions of Atmos do not support this header.
*/
public PutOptions overwrite() {
this.replaceHeader("x-emc-force-overwrite", "true");
return this;

View File

@ -33,6 +33,7 @@ import org.jclouds.atmos.options.PutOptions;
import org.jclouds.atmos.reference.AtmosErrorCode;
import org.jclouds.atmos.xml.ErrorHandler;
import org.jclouds.blobstore.ContainerNotFoundException;
import org.jclouds.blobstore.KeyAlreadyExistsException;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.crypto.Crypto;
import org.jclouds.http.HttpCommand;
@ -71,7 +72,13 @@ public class AtmosUtils {
Blob blob, PutOptions options) {
final String path = container + "/" + blob.getMetadata().getName();
final AtmosObject object = blob2Object.apply(blob);
sync.createFile(container, object, options);
try {
sync.createFile(container, object, options);
} catch (KeyAlreadyExistsException e) {
deletePathAndEnsureGone(sync, path);
sync.createFile(container, object, options);
}
return path;
}