Skip to content

Commit 02a8550

Browse files
committed
work in progress
1 parent 82c1ffb commit 02a8550

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/main/java/com/google/gcloud/spi/StorageRpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/* * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.google.gcloud.spi;import com.google.api.services.storage.model.Bucket;import com.google.api.services.storage.model.StorageObject;import com.google.gcloud.storage.BlobReadChannel;import com.google.gcloud.storage.BlobWriteChannel;import java.io.IOException;import java.nio.ByteBuffer;import java.util.Iterator;public interface StorageRpc { Bucket create(Bucket bucket) throws IOException; StorageObject create(StorageObject object, ByteBuffer content) throws IOException; Iterator<Bucket> list() throws IOException; Iterator<StorageObject> list(String bucket, String prefix, String delimiter, String cursor, boolean versions, int limit) throws IOException; Bucket get(Bucket bucket) throws IOException; StorageObject get(StorageObject object) throws IOException; Bucket patch(Bucket bucket) throws IOException; StorageObject patch(StorageObject storageObject) throws IOException; void delete(Bucket bucket) throws IOException; void delete(StorageObject object) throws IOException; StorageObject compose(String bucket, Iterable<String> src, StorageObject dest) throws IOException; StorageObject copy(StorageObject from, StorageObject to) throws IOException; BlobReadChannel reader(StorageObject from) throws IOException; BlobWriteChannel writer(StorageObject to) throws IOException;}
1+
/* * Copyright 2015 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.google.gcloud.spi;import com.google.api.services.storage.model.Bucket;import com.google.api.services.storage.model.StorageObject;import com.google.gcloud.storage.BlobReadChannel;import com.google.gcloud.storage.BlobWriteChannel;import java.io.IOException;import java.nio.ByteBuffer;import java.util.Iterator;public interface StorageRpc { Bucket create(Bucket bucket) throws IOException; StorageObject create(StorageObject object, ByteBuffer content) throws IOException; Iterator<Bucket> list() throws IOException; Iterator<StorageObject> list(String bucket, String prefix, String delimiter, String cursor, boolean versions, int limit) throws IOException; Bucket get(String bucket) throws IOException; StorageObject get(String bucket, String object) throws IOException; Bucket patch(Bucket bucket) throws IOException; StorageObject patch(StorageObject storageObject) throws IOException; void delete(Bucket bucket) throws IOException; void delete(StorageObject object) throws IOException; StorageObject compose(String bucket, Iterable<String> src, StorageObject dest) throws IOException; StorageObject copy(StorageObject from, StorageObject to) throws IOException; BlobReadChannel reader(StorageObject from) throws IOException; BlobWriteChannel writer(StorageObject to) throws IOException;}

src/main/java/com/google/gcloud/storage/StorageService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@
2424
public interface StorageService extends Service<StorageServiceOptions> {
2525

2626
// todo: consider what to do with predefinedAcl
27+
2728
// todo: consider supplying create/update/delete options (varargs) for
2829
// ifGenerationMatch, ifGenerationNotMatch, ifMetagenerationMatch,
2930
// ifMetagenerationNotMatch, ifSourceGenerationMatch, ifSourceGenerationNotMatch
3031
// ifSourceMetagenerationMatch and ifSourceMetagenerationNotMatch
3132

33+
// todo: provide way for construct signed URLs - https://cloud.google.com/storage/docs/access-control#Signed-URLs
34+
3235
Bucket create(Bucket bucket);
3336

3437
Blob create(Blob blob, ByteBuffer content);
3538

36-
Bucket get(Bucket bucket);
39+
Bucket get(String bucket);
3740

38-
Blob get(Blob blob);
41+
Blob get(String bucket, String blob);
3942

4043
Iterator<Bucket> list();
4144

42-
Iterator<Blob> list(Bucket bucket, ListOptions settings);
45+
Iterator<Blob> list(String bucket, ListOptions settings);
4346

4447
Bucket update(Bucket bucket);
4548

src/main/java/com/google/gcloud/storage/StorageServiceImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ public Blob create(Blob blob, ByteBuffer content) {
5353
}
5454

5555
@Override
56-
public Bucket get(Bucket bucket) {
56+
public Bucket get(String bucket) {
5757
try {
58-
return Bucket.fromPb(storageRpc.get(bucket.toPb()));
58+
return Bucket.fromPb(storageRpc.get(bucket));
5959
} catch (IOException ex) {
6060
throw new StorageServiceException(ex);
6161
}
6262
}
6363

6464
@Override
65-
public Blob get(Blob blob) {
65+
public Blob get(String bucket, String blob) {
6666
try {
67-
return Blob.fromPb(storageRpc.get(blob.toPb()));
67+
return Blob.fromPb(storageRpc.get(bucket, blob));
6868
} catch (IOException ex) {
6969
throw new StorageServiceException(ex);
7070
}
@@ -80,11 +80,11 @@ public Iterator<Bucket> list() {
8080
}
8181

8282
@Override
83-
public Iterator<Blob> list(Bucket bucket, ListOptions settings) {
83+
public Iterator<Blob> list(String bucket, ListOptions settings) {
8484
try {
8585
String delimiter = settings.recursive() ? options().pathDelimiter() : null;
8686
return Iterators.transform(
87-
storageRpc.list(bucket.name(), settings.prefix(), delimiter, settings.cursor(),
87+
storageRpc.list(bucket, settings.prefix(), delimiter, settings.cursor(),
8888
settings.includeOlderVersions(), settings.maxResults()),
8989
Blob.FROM_PB_FUNCTION);
9090
} catch (IOException ex) {

0 commit comments

Comments
 (0)