Skip to content

Commit fdac9a7

Browse files
committed
replace local gcd hack with a fixed version of gcd
1 parent 86201c9 commit fdac9a7

3 files changed

Lines changed: 129 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44

55
public interface Bucket {
66

7+
String id();
8+
79
String name();
810

911
Acl acl();
1012

11-
void updateAcl(Acl acl);
12-
1313
Acl defaultObjectAcl();
1414

15+
Cors cors();
16+
1517
void updateDefaultObjectAcl();
18+
void updateAcl(Acl acl);
19+
1620

1721

1822

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright 2015 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.gcloud.storage;
18+
19+
import com.google.common.collect.ImmutableList;
20+
21+
import java.net.URI;
22+
import java.net.URISyntaxException;
23+
import java.util.List;
24+
25+
public class Cors {
26+
27+
private final Integer maxAgeSeconds;
28+
private final ImmutableList<Method> methods;
29+
private final ImmutableList<Origin> origins;
30+
private final ImmutableList<String> responseHeaders;
31+
32+
public enum Method {
33+
ANY, GET, HEAD, PUT, POST, DELETE
34+
}
35+
36+
public static class Origin {
37+
38+
private final URI uri;
39+
40+
public static final Origin ANY = new Origin();
41+
42+
private Origin() {
43+
uri = null;
44+
}
45+
46+
public Origin(String scheme, String host, int port) {
47+
try {
48+
this.uri = new URI(scheme, null, host, port, null, null, null);
49+
} catch (URISyntaxException e) {
50+
throw new IllegalArgumentException(e);
51+
}
52+
53+
}
54+
55+
@Override
56+
public String toString() {
57+
return uri == null ? "*" : uri.toString();
58+
}
59+
}
60+
61+
public static final class Builder {
62+
63+
private Integer maxAgeSeconds;
64+
private ImmutableList<Method> methods;
65+
private ImmutableList<Origin> origins;
66+
private ImmutableList<String> responseHeaders;
67+
68+
private Builder() {
69+
}
70+
71+
public Builder maxAgeSeconds(Integer maxAgeSeconds) {
72+
this.maxAgeSeconds = maxAgeSeconds;
73+
return this;
74+
}
75+
76+
public Builder methods(Method... methods) {
77+
this.methods = ImmutableList.copyOf(methods);
78+
return this;
79+
}
80+
81+
public Builder origins(Origin... origins) {
82+
this.origins = ImmutableList.copyOf(origins);
83+
return this;
84+
}
85+
86+
public Builder responseHeaders(String... responseHeaders) {
87+
this.responseHeaders = ImmutableList.copyOf(responseHeaders);
88+
return this;
89+
}
90+
91+
public Cors build() {
92+
return new Cors(this);
93+
}
94+
}
95+
96+
private Cors(Builder builder) {
97+
this.maxAgeSeconds = builder.maxAgeSeconds;
98+
this.methods = builder.methods;
99+
this.origins = builder.origins;
100+
this.responseHeaders = builder.responseHeaders;
101+
}
102+
103+
public Integer maxAgeSeconds() {
104+
return maxAgeSeconds;
105+
}
106+
107+
public List<Method> methods() {
108+
return methods;
109+
}
110+
111+
public List<Origin> origins() {
112+
return origins;
113+
}
114+
115+
public List<String> responseHeaders() {
116+
return responseHeaders;
117+
}
118+
119+
public static Builder builder() {
120+
return new Builder();
121+
}
122+
}

src/test/java/com/google/gcloud/datastore/LocalGcdHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class LocalGcdHelper {
3636

3737
public static final String DEFAULT_DATASET = "dataset1";
3838
public static final int PORT = 8080;
39-
private static final String GCD = "gcd-v1beta2-rev1-2.1.1";
39+
private static final String GCD = "gcd-head";
4040
private static final String GCD_LOC = '/' + GCD + ".zip";
4141

4242
private static class ProcessStreamReader extends Thread {

0 commit comments

Comments
 (0)