diff --git a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java index b1a451e6fcc6..838a092f08d9 100644 --- a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java +++ b/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java @@ -313,7 +313,7 @@ public String open(StorageObject object, Map options) throws StorageE } @Override - public String getUploadId(String signURL) { + public String open(String signURL) { return null; } diff --git a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java index 306214b65d6b..56acd6ac4546 100644 --- a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java +++ b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/BlobWriteChannel.java @@ -36,7 +36,7 @@ class BlobWriteChannel extends BaseWriteChannel { } BlobWriteChannel(StorageOptions options, URL signURL) { - this(options, getUploadId(signURL.toString(), options)); + this(options, open(signURL.toString(), options)); } BlobWriteChannel(StorageOptions options, BlobInfo blobInfo, String uploadId) { @@ -92,13 +92,13 @@ public String call() { } } - private static String getUploadId(final String signURL, final StorageOptions options) { + private static String open(final String signURL, final StorageOptions options) { try { return runWithRetries( new Callable() { @Override public String call() { - return options.getStorageRpcV1().getUploadId(signURL); + return options.getStorageRpcV1().open(signURL); } }, options.getRetrySettings(), diff --git a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java index c82f37546d2a..d47d7f59258a 100644 --- a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java +++ b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java @@ -22,8 +22,13 @@ import com.google.api.gax.paging.Page; import com.google.auth.ServiceAccountSigner; import com.google.auth.ServiceAccountSigner.SigningException; -import com.google.cloud.*; +import com.google.cloud.FieldSelector; import com.google.cloud.FieldSelector.Helper; +import com.google.cloud.Policy; +import com.google.cloud.ReadChannel; +import com.google.cloud.Service; +import com.google.cloud.Tuple; +import com.google.cloud.WriteChannel; import com.google.cloud.storage.Acl.Entity; import com.google.cloud.storage.spi.v1.StorageRpc; import com.google.common.collect.ImmutableList; @@ -34,7 +39,14 @@ import java.io.Serializable; import java.net.URL; import java.security.Key; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.TimeUnit; /** diff --git a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index f22ec53fd6e5..c05a5301d25e 100644 --- a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -823,7 +823,7 @@ public String open(StorageObject object, Map options) { } @Override - public String getUploadId(String signURL) { + public String open(String signURL) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_OPEN); Scope scope = tracer.withSpan(span); try { diff --git a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java index faaec7824939..6ffd1f5a2ba8 100644 --- a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java +++ b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java @@ -294,7 +294,7 @@ StorageObject compose( * * @throws StorageException upon failure */ - String getUploadId(String signURL); + String open(String signURL); /** * Writes the provided bytes to a storage object at the provided location. diff --git a/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java b/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java index 7de0b0174654..f44a59b0018c 100644 --- a/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java +++ b/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/BlobWriteChannelTest.java @@ -270,7 +270,7 @@ public void testStateEquals() { @Test public void testWriteWithSignURLAndWithoutFlush() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); replay(storageRpcMock); writer = new BlobWriteChannel(options, new URL(SIGN_URL)); assertEquals(MIN_CHUNK_SIZE, writer.write(ByteBuffer.allocate(MIN_CHUNK_SIZE))); @@ -278,7 +278,7 @@ public void testWriteWithSignURLAndWithoutFlush() throws IOException { @Test public void testWriteWithSignURLAndWithFlush() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); Capture capturedBuffer = Capture.newInstance(); storageRpcMock.write( eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(CUSTOM_CHUNK_SIZE), eq(false)); @@ -292,7 +292,7 @@ public void testWriteWithSignURLAndWithFlush() throws IOException { @Test public void testWriteWithSignURLAndFlush() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); Capture capturedBuffer = Capture.newInstance(); storageRpcMock.write( eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(DEFAULT_CHUNK_SIZE), eq(false)); @@ -313,7 +313,7 @@ public void testWriteWithSignURLAndFlush() throws IOException { @Test public void testCloseWithSignURLWithoutFlush() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); Capture capturedBuffer = Capture.newInstance(); storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(0), eq(true)); replay(storageRpcMock); @@ -326,7 +326,7 @@ public void testCloseWithSignURLWithoutFlush() throws IOException { @Test public void testCloseWithSignURLWithFlush() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); Capture capturedBuffer = Capture.newInstance(); ByteBuffer buffer = randomBuffer(MIN_CHUNK_SIZE); storageRpcMock.write( @@ -343,7 +343,7 @@ public void testCloseWithSignURLWithFlush() throws IOException { @Test public void testWriteWithSignURLClosed() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); Capture capturedBuffer = Capture.newInstance(); storageRpcMock.write(eq(UPLOAD_ID), capture(capturedBuffer), eq(0), eq(0L), eq(0), eq(true)); replay(storageRpcMock); @@ -359,7 +359,7 @@ public void testWriteWithSignURLClosed() throws IOException { @Test public void testSaveAndRestoreWithSignURL() throws IOException { - expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn(UPLOAD_ID); + expect(storageRpcMock.open(SIGN_URL)).andReturn(UPLOAD_ID); Capture capturedBuffer = Capture.newInstance(CaptureType.ALL); Capture capturedPosition = Capture.newInstance(CaptureType.ALL); storageRpcMock.write( diff --git a/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java b/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java index 5e9b9032d264..8c2c301b9bfa 100644 --- a/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java +++ b/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java @@ -2842,7 +2842,7 @@ public void testRuntimeException() { @Test public void testWriterWithSignURL() throws MalformedURLException { - EasyMock.expect(storageRpcMock.getUploadId(SIGN_URL)).andReturn("upload-id"); + EasyMock.expect(storageRpcMock.open(SIGN_URL)).andReturn("upload-id"); EasyMock.replay(storageRpcMock); initializeService(); WriteChannel writer = new BlobWriteChannel(options, new URL(SIGN_URL));