GCS support for conditional copies

This commit is contained in:
Andrew Gaul 2016-02-12 19:33:10 -08:00
parent 165e9afd9f
commit 2499cb0ac2
2 changed files with 61 additions and 0 deletions

View File

@ -308,6 +308,19 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
@Override @Override
public String copyBlob(String fromContainer, String fromName, String toContainer, String toName, public String copyBlob(String fromContainer, String fromName, String toContainer, String toName,
CopyOptions options) { CopyOptions options) {
if (options.ifMatch() != null) {
throw new UnsupportedOperationException("GCS does not support ifMatch");
}
if (options.ifNoneMatch() != null) {
throw new UnsupportedOperationException("GCS does not support ifNoneMatch");
}
if (options.ifModifiedSince() != null) {
throw new UnsupportedOperationException("GCS does not support ifModifiedSince");
}
if (options.ifUnmodifiedSince() != null) {
throw new UnsupportedOperationException("GCS does not support ifUnmodifiedSince");
}
if (options.contentMetadata() == null && options.userMetadata() == null) { if (options.contentMetadata() == null && options.userMetadata() == null) {
return api.getObjectApi().copyObject(toContainer, Strings2.urlEncode(toName), fromContainer, return api.getObjectApi().copyObject(toContainer, Strings2.urlEncode(toName), fromContainer,
Strings2.urlEncode(fromName)).etag(); Strings2.urlEncode(fromName)).etag();

View File

@ -268,4 +268,52 @@ public class GoogleCloudStorageBlobIntegrationLiveTest extends BaseBlobIntegrati
throw new SkipException("request signing not supported on GCS", uoe); throw new SkipException("request signing not supported on GCS", uoe);
} }
} }
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfMatch() throws Exception {
super.testCopyIfMatch();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfMatchNegative() throws Exception {
super.testCopyIfMatch();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfNoneMatch() throws Exception {
super.testCopyIfNoneMatch();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfNoneMatchNegative() throws Exception {
super.testCopyIfNoneMatch();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfModifiedSince() throws Exception {
super.testCopyIfModifiedSince();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfModifiedSinceNegative() throws Exception {
super.testCopyIfModifiedSince();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfUnmodifiedSince() throws Exception {
super.testCopyIfUnmodifiedSince();
}
@Override
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testCopyIfUnmodifiedSinceNegative() throws Exception {
super.testCopyIfUnmodifiedSince();
}
} }